I am able to restart scenes with almost no problems. The one problem I am having is it draws my powerup twice (over the top of each other). My restart function looks like this:
restartLevel() {
this.game.state.mode = MODE.RESTARTING;
this.isRestarting = true;
this.game.points = this.startingPoints;
Audio.turnOffMusic();
}
Any ideas on what would cause this to draw these sprites twice like this? We have a pretty complex game going now. This is the only current bug. Thanks so much for your help!
Have you tried removing this.scene.stop()? My game goes back to the menu when the player dies, and stopping the scene gave me problems with matter constraints; but calling this.scene.restart() before starting the menu scene solved it.
We have a base-scene function. In that function we use:
this.components.push(PowerUps); in preload()
We have a function called:
spawnPowerup() {
if (this.game.state.mode === MODE.FINISH) {
return;
}
We have divided each scene into phases. IN our startPhase() functions we call
this.powerupSpawnTimer = this.time.addEvent({
delay: 12000,
callback: this.spawnPowerup,
callbackScope: this,
loop: true,
});
That is the basics of it. Thanks for taking the time to look at this!!