-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Version
- Phaser Version: 3.55.2
- Operating system: Ubuntu
- Browser: Tested on Chrome and Firefox
Description
It seems like the fix in #4486 is no longer working. When the visibility of the parent container is changed, the DOM node is still visible. I am able to determine that it is because preUpdate
is not being called on DOM elements, though I am not sure why.
Example Test Code
class MainScene extends Phaser.Scene {
create() {
const text = new Phaser.GameObjects.DOMElement(this, 0, 0, "span", { color: "white" }, "Hello");
const container = this.add.container(50, 50, [text]);
this.time.delayedCall(1000, () => {
console.log("Setting container visibility to false");
container.setVisible(false);
// If we forcefully call preupdate on the next update
// then the text correctly disappears
// this.events.once("update", () => {
// text.preUpdate();
// });
});
}
}
See a demo: https://codepen.io/prakol16/pen/rNwVyvv
Additional Information
In addition, perhaps the preUpdate
code should be moved to a preStep
event on the game. The reason for this is because if a scene is paused, the visibility of various objects can still change, but preUpdate
will never be called. Similarly, if the container/its children are changed to be inactive with setActive(false)
, we'd expect the visibility to still be controlled separately by setVisible
, but instead, the visibility of the DOM element will no longer change.