-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Labels
Description
Version
- Phaser Version:
3.55.2 - Operating system:
Win 10 - Browser:
Opera 78.0.4093.184 (only tested here)
Description
I have a polygon GameObject
with setInteractive()
and a few on()
events.
Events trigger fine, except that the "pointerout" event still triggers once after I call disableInteractive()
.
This is probably easier to understand by looking at the code.
If I am missing something obvious then I am truly sorry.
Problem goes away if I call removeAllListeners()
after disableInteractive()
.
Example Test Code
const polyPoints = [cell.topLeft, cell.topRight, cell.bottomRight, cell.bottomLeft];
const poly = this.scene.add
.polygon(0, 0, polyPoints)
.setOrigin(0)
.setInteractive(new Phaser.Geom.Polygon(polyPoints), Phaser.Geom.Polygon.Contains)
.disableInteractive()
.setStrokeStyle(
boardStrokeConfigs.DEFAULT.width,
boardStrokeConfigs.DEFAULT.color,
boardStrokeConfigs.DEFAULT.alpha,
).on("pointerover", () => {
this.applyStrokeConfigToCellPoly(
...getCellRanks(c),
boardStrokeConfigs.OVER_TARGET,
true,
);
})
.on("pointerout", () => {
// still triggers once after call to disableCellInteraction()
// doesn't matter how long I wait before I move the mouse
this.applyStrokeConfigToCellPoly(
...getCellRanks(c),
boardStrokeConfigs.VALID_TARGET,
true,
);
});
disableCellInteraction = () => {
this.forEachCell((c) => {
this.cellPolys[c.row][c.col].disableInteractive();
});
};
enableCellInteraction = (onclick: (cell: BoardCell) => void) => {
this.disableCellInteraction();
this._activePawnAction?.getValidTargetCells().forEach((c) => {
this.cellPolys[c.row][c.col]
.setInteractive()
.on("pointerup", () => onclick(c));
});
};
natureofcode