I'm making a game in Phaser 3 but I can't seem to find how to pass the score from a GameScene to a GameOverScene.
When calling this.scene.start you can pass optional data to the scene.
this.scene.start(key, data), which has an official demo.
You can use the init in a scene to retrieve the data.
So in your GameScene you might have something like the following:
this.scene.start('GameOverScene', { score: this.playerScore });
Then in your GameOverScene you should have something like the following:
init: function (data)
{
    console.log('init', data);
    this.finalScore = data.score;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With