Problem with two parallel scenes

Hello!!

I have a question about two parallel scenes.

I’m developing an object rain game. In this, several physics objects fall down (images, no sprites), but not using gravity (because the contexts is a cosmos). They move using .setVelocityY().

When player lose, the game is paused, and the main menu scene is displayed (Not changing to the another scene, rather showing the another scene over the screen).

The problem is: When an object that is falling down stops at the same XY Position that Main menu’s image, this (main menu’s image) is behind the object. I tried use setDepth() on Main menu’s image but in doesn’t work.

Is there any way to set the depth of MainMenuScene over PlayingScene?

This is my code:

export class PlayingScene extends Phaser.Scene {

  constructor(){...}

  preload(){...}

  create(){...}

  update(){

   if(game_over){

     this.scene.pause();

     this.scene.launch('MainMenuScene');

     return;

   }else{
     //Playing code
   }

  }

}

Hi,
Try:

export class PlayingScene extends Phaser.Scene {

  constructor(){...}

  preload(){...}

  create(){...}

  update(){

   if(game_over){

     this.scene.pause();

     this.scene.launch('MainMenuScene');
     this.scene.bringToTop('MainMenuScene');

     return;

   }else{
     //Playing code
   }

  }
}
1 Like

You are AWESOME!!! Thanks!!!