Controlling scenes depth is possible?

Hi!

I am trying to start a help scene from another one but am experiencing a curious issue. If I try to start it from a “simple” scene (in this case a scene with just a background a couple buttons) it works fine. This is the code I use for this:

    this.btnHelp = this.add.image(0, 0, "btnHelp").setInteractive();
    this.btnHelp.on('pointerup', (e) => {
        game.scene.start("sceneHelp");
    });

Now I am trying to start the very same scene from a “complex” scene with over a hundred elements however this time the help scene won’t display. Notice that it LOADS; it just doesn’t display. No error message and I even can log a text in console from the help scene, meaning that it IS loading. Just to be completely sure I removed everything from the “complex” scene, tested again and this time the help scene displayed.

It seems to me that it’s a depth issue and that somewhat the help scene is displaying behind the existing elements of the main scene. I tried to setDepth of one of the elements of the help scene to an absurd value such as 10000000 (that would overlap any element of the main scene) and even so I didn’t get any visible result.

There is a way of forcing a scene to load onto the scene which is starting it? If not what could be happening here?

Thanks!

https://rexrainbow.github.io/phaser3-rex-notes/docs/site/scenemanager/#order-of-scenes

setDepth is per Scene, so that won’t work.

1 Like

Milton!

Cool, thanks for helping!

This is what fixed the issue for me (in case of someone else needs)…

In the main scene:

        this.btnHelp = this.add.image(0, 0, "btnHelp").setInteractive()
        this.btnHelp.on('pointerup', (e) => {
            game.scene.start("sceneHelp");
        });

In the help scene (at the bottom of the create function):

create() {
   // all the necessary commands before here
   this.scene.bringToTop();
}

:slight_smile:

1 Like

You should use the this.scene methods instead of game.scene, usually.

1 Like

Thanks for the tip Samme!

Great, this is what Im looking for, thanks so much

I was having a similar issue, and this worked great for me! Thank you!!