Restart Code

Is there a way I can restart my game without resetting all the variables?

Store the variables you don’t want to reset in game object.
for example: let game = new Phaser.Game({
type: Phaser.WEBGL,
backgroundColor: 0xffffff,
transparent: true,
});
game.musicVolume = 1;

this.scene.restart(); would restart the scene.

1 Like

It really depends, I think we have to see your code.

1 Like

You can fix this by adding this as the third argument to on(…), previous.

1 Like

It’s working now thanks so much! :smiley: do you have a github account I can credit in the repository description?

1 Like