我正在尝试制作一个简单的乒乓球游戏,我想在球上启用街机物理。相反,它显示TypeError:无法读取未定义的属性“ enable”。这是代码中出现错误的部分。
function create() {
gameState.bar1 = this.add.rectangle(0, 250, 25, 100, 0x37c3be)
gameState.bar2 = this.add.rectangle(540, 250, 25, 100, 0x37c3be)
gameState.ball = this.add.circle(270, 250, 5, 0x37c3be)
this.physics.arcade.enable(gameState.ball)
gameState.cursors = this.input.keyboard.createCursorKeys()
这是配置代码
const config = {
type: Phaser.AUTO,
width: 540,
height: 500,
backgroundColor: "#5f2a55",
physics: {
default: 'arcade',
arcade: {
gravity: { y: 200 },
enableBody: true,
}
},
scene: {
create,
update,
}
};