I am new to Phaser and I’m not sure I’m handling loading scenes correctly.
I have a LoadScene where once it reaches create() I send it to load a MenuScene by using
this.scene.start(STATIC.SCENES.MENU, { data: 0 });
Ignore the {…] that was for some testing.
From that Menu Scene, I have 3 buttons to “Play”, “Settings” and “Credits”
I load those on mouse and keyboard inputs with
this.scene.start(this.scenes[index]);
“scenes” is just an array with the keys for each scene
this.scenes = [STATIC.SCENES.PLAY, STATIC.SCENES.SETTINGS, STATIC.SCENES.CREDITS];
Finally on this scenes I have for now just a “back” button that is loading the Menu Scene again with
this.scene.start(STATIC.SCENES.MENU);
As far as I know from what I read is that using start method stops the current scene we are on. However, when I go back to the main menu, something weird happens.
My buttons for “Play”, “Settings” and “Credit” play a sound on mouse over and when selected with the arrows.
On menu first load the sound effect volume is perfect, however after coming back to that scene from the back button on the others, when using the arrows to select the menu options, the sound effect sounds louder and louder (Which makes me think, I’m loading scenes on top of scenes).
While I’m on Play, Settings or Credits, up and down arrows don’t play any effect, so clearly the menu scene isn’t on the back.
Weirdly enough (or maybe not) when on mouse over, the volume is fine. So I guess my:
this.input.keyboard.on('keydown', (event: any) => {
Is still running and I’m just adding another listener on top?
Anyone has any idea what could be going on?
Let me know if you need any more of the code.