Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload the game on Phaser 3?

How to restart the game when you click on the button? I tried the following code:

this.scene.stop();
this.scene.start();

The scene reloads, but the preload function does not work again.

like image 662
Владислав Avatar asked Nov 20 '25 02:11

Владислав


1 Answers

Try this code:

this.registry.destroy(); // destroy registry
this.events.off(); // disable all active events
this.scene.restart(); // restart current scene

Also have a look at the Phaser 3 Documentation for more info

like image 180
exciteabletom Avatar answered Nov 23 '25 23:11

exciteabletom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!