I have one game scene, with background music. When the tab is out of focus, i’ll restart the game by using this.scene.restart();music.stop().
The problem is when i restart the game, the background music get doubled, it is very obvious there’s two same bgm where one is slower than the other. The more times i restart the game, the more bgm echoing. The same goes for some tween animation…
Any idea how may i solve it?
Are you calling music.stop(); in your update function?
Yes, i have something like this in my update function
update() {
if (restart) {
music.stop();
this.scene.restart();
restart = 0;
}
}
Depending on how your code is structured, you may need to specify the object of music and try this.music.stop();
Turn out i’d been declaring the same music twice.
var music = this.sound.add(‘music’);
Problem solved… Thanks!
1 Like