I'm currently making a mobile game and I have run into a issue that I hope you guys can help me solve. Every level in my game has a soundtrack and sound fx, the problem I'm facing is when changing layout to a new level the previous soundtrack keeps playing over the new soundtrack. So how can I make it so when changing layout (level) the previous soundtrack stops and the new one plays? Thank you for your time :)
Develop games in your browser. Powerful, performant & highly capable.
You should use 2 things :
At the start of layout, start playing soundtrack with tag "soundtrack".
At end of layout, stop playing "soundtrack"
(those are actions of the Sound object)
If you add a global variable in each layout, variable containing the name of the soundtrack, you can just have those 2 sound events in every layout , just using the variable to play the wanted soundtrack.