【发布时间】:2022-12-08 05:42:13
【问题描述】:
我正在尝试制作一个菜单,当玩家使用 start 方法单击按钮时场景会发生变化。起初,我把这一切都放在了 create 函数中:
var levelOne = this.add.sprite(200, 400, 'LevelOne').setInteractive();
levelOne.on('pointerdown', function (pointer) {
this.scene.start('play');
});
但这导致了一个错误,它说 this.scene.start 不是一个函数。
我查看了之前该方法有效的示例,最大的区别在于该方法在更新函数中,因此我重写了我的代码以将其包含在创建函数中:
this.choice = 0;
var levelOne = this.add.sprite(200, 400, 'LevelOne').setInteractive();
levelOne.on('pointerdown', function (pointer) {
this.choice = 1;
//game.settings = {
//gameTimer: 60000
//}
});
这在更新功能中:
if (this.choice == 1){
this.scene.start('play');
}
可悲的是,这也不起作用,甚至没有给出错误消息。我不知道哪里出了问题。请帮忙。
【问题讨论】:
标签: menu phaser-framework scene