phaserjs / phaserjs/phaser

GameObject.DomElement still exists after scene sleep

Open
#6,985 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🖼️ Scene
Dominant language
JavaScript
Stars
40.3k
Forks
7.2k
PR merge metrics
No merged PRs in 30d

Description

Version

  • Phaser Version: 3.80.1
  • Operating system: Windows

Description

I am using a scene as an inventory window, so it is above another scene.
When I try to hide the scene using scene.sleep(), GameObject.DomElement still remains to be seen after scene's visibility is set to off.
I expected it to disappear, like other gameobjects like image.

Example Test Code

class Test1 extends Phaser.Scene {
constructor() { super('test1')} 
create() {

scene.launch('test2');
}
}

class Test2 extends Phaser.Scene {
constructor() { super('test2')} 
create() {

const text = this.add.dom(0, 0, 'p', {}, 'test');
this.scene.sleep();
// text remains in the screen.
  });
}
}

const game = new Phaser.Game({
    type: Phaser.AUTO,
    width: 800,
    height: 800,
    backgroundColor: '#111111',
    scale: {
        mode: Phaser.Scale.FIT,
        autoCenter: Phaser.Scale.CENTER_BOTH
    },
    scene: [  Test1, Test2  ]
})

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with Phaser 3.80.1, focusing on the DOM element created with this.add.dom() and the scene.sleep() lifecycle. Trace how scene visibility changes affect ordinary game objects versus GameObject.DomElement; done means the DOM element is no longer visible when its scene sleeps.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.