Jump to content

Sounds keep looping after changing scene


mm
 Share

Recommended Posts

Hello, I just started doing test with phaser 3, so far is been really good. I'm having issues with sounds when changing scenes, lets call them "scene 1" and "scene 2", "scene 2" has a looping sound, when I go from "scene 1" to "scene 2" and back to "scene 1" the sound loop keeps playing in "scene 1", also if I repeat the process again the sound not only keeps looping but duplicates so I end up with two sound loops in "scene 1". Is there a way to clearing a scene when changing to another?

I'm using Phaser 3.11 btw.

 

Thanks.

Link to comment
Share on other sites

It's the right one now. A mod must've moved this over into the correct place, you were in the bit where people share projects and plugins and things.

What I do in my current game, is I have a seperate scene called the audio manager, that way the background music and sounds are not linked to the scenes changing during gameplay as such. Its the same concept as a preload scene. You may already know, but in phaser 3 you can have many scenes,  but also ones that run at the same time.  

Link to comment
Share on other sites

That's a good solution, will also help with separating game and audio pause, thank you @NoxBrutalis.

This gives me some more doubts about scene management:
- When I change a scene, what parts of it keeps working? looks like audio keeps working, what about sprites? timers? script logic?
- How can I clean/delete a scene on change?

 

 

Link to comment
Share on other sites

Last time I checked, animations remain and so when restarting scenes you often get warnings saying they're already defined. At the minute for the main file of my game, I have a separate initialise functions, that resets things manually, but I know a lot of people - including Rich, the main dev, use a separate scene for animations and various other assets. This is in part because they can use the scene as a splash screen to load things in a more seamless manner I think, but it has the added benefits, such as no warnings, and the ability to restart and swap scenes without the issues you're worried about. 

 

I've not read through this myself, so sorry if it's not the same thing, but I think it is :)

https://phaser.io/news/2018/05/phaser-3-preloader-tutorial

 

Otherwise, I can't offer any more advise,  alot of the things you mentioned, I'm not sure about. I think the scene changing etc is a bit sketchy. It's still fairly early days for phaser 3 at the minute.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...