我正在使用Phaser 3制作游戏,但我似乎找不到如何从GameScene将得分传递到GameOverScene的方法。
this.scene.start
时,您可以向场景传递可选数据。
this.scene.start(key, data)
,其中包含官方演示。init
来检索数据。GameScene
中,您可能会有以下内容:this.scene.start('GameOverScene', { score: this.playerScore });
然后在你的GameOverScene
中应该有类似以下的内容:
init: function (data)
{
console.log('init', data);
this.finalScore = data.score;
}