Should "pointerover" events fire when a game object is not visible? #6389
-
I ran into a an issue where the I am seeing this behavior in Phaser v3.55.2. Here is an example code snippet that shows the functionality I am trying to achieve. const rect = this.add
.rectangle(50, 50, 100, 100, 0xffff00)
.setInteractive()
.setAlpha(0.2);
rect.on("pointerover", () => {
console.log("pointerover");
rect.setAlpha(0.6);
});
rect.on("pointerout", () => {
console.log("pointerout");
rect.setAlpha(0);
});
const rect2 = this.add
.rectangle(50, 200, 100, 100, 0xffff00)
.setInteractive()
.setAlpha(0.2);
rect2.on("pointerover", () => {
rect2.setAlpha(0.6);
});
rect2.on("pointerout", () => {
rect2.setAlpha(0.1);
}); In the code snippet above, and in the codepen link below, when you hover over the top rectangle, If you hover over the bottom rectangle, Here is a live example showing the behavior I am seeing: https://codepen.io/swesto01/pen/mdGdQvj I was able to work around the issue by setting my alpha value to a very low value like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Game Objects that don't render (i.e. visible false or alpha zero) are skipped for input, yes. This is how it was designed from the start so is the default standard behaviour. For non-rendering Game Objects that need input (i.e. for drop zones) there is the Zone Game Object. |
Beta Was this translation helpful? Give feedback.
Game Objects that don't render (i.e. visible false or alpha zero) are skipped for input, yes. This is how it was designed from the start so is the default standard behaviour. For non-rendering Game Objects that need input (i.e. for drop zones) there is the Zone Game Object.