【发布时间】:2020-01-29 18:27:32
【问题描述】:
我是 Phaser 3 的新手
当我扩展精灵时
结果没有这样的属性
但我确定它有这个属性
虽然终端显示错误
游戏仍然在网络上运行良好
这是我的代码
export class Planet2 extends Phaser.GameObjects.Sprite {
cellWidth: number;
cellHeight: number;
constructor(config) {
super(config.scene, config.x, config.y, 'planet2');
config.scene.physics.world.enable(this);
config.scene.add.existing(this);
this.body.allowGravity = false;
this.cellWidth = config.scene.cameras.main.width / 100;
this.body.moves = true;
this.body.offset.x = this.cellWidth * 2;
this.body.setSize(this.cellWidth * 8, this.cellWidth * 8, 0, 0);
this.body.isCircle = true;
}
}
这里是github https://github.com/lalalalaluk/ion-phaser-test.git
非常感谢!
【问题讨论】:
-
您需要添加 Phaser 打字稿定义文件。从 Phaser 源 github.com/photonstorm/phaser?files=1 下载并添加类型文件夹或尝试将 Phaser 包更新到最新版本 3.20.0
-
我尝试将移相器更新到 3.20.0 它不起作用