第3阶段街机物理未激活



我正在使用Phaser3(3.24(,下面是我初始化游戏的配置

GAME_CONFIG: {
type: Phaser.AUTO,
backgroundColor: '#fff',
scale: {
width: 1200,
height: 470,
mode: Phaser.Scale.ScaleModes.NONE,
},
parent: 'marathon-game',
physics: {
default: 'arcade',
fps: 60,
arcade: {
gravity: { y: 300 },
debug: true,
},
},
}

当我开始我的第一个场景并检查this.scene.physics时,它返回undefined。。。知道为什么会发生这种事,或者我做错了什么。

我认为这是因为配置中缺少场景对象。因此,如果你的场景不是一个类使用:

GAME_CONFIG: {
...the_rest_of_your_config
scene: {
preload: preload,
create: create,
update: update
}
}

或者:

GAME_CONFIG: {
...the_rest_of_your_config
scene: name_of_your_scene_class_goes_here
}

最新更新