问题描述
我正在使用Phaser 3(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
}