我有一个我无法弄清楚的错误/逻辑错误。我的播放器确实检测到其顶部和底部与瓷砖的碰撞,但未检测到其侧面。玩家是扩展 Phaser.GameObjects.Rectangle 的类的实例。我尝试将其更改为Phaser.GameObjects.Sprite,但出现了同样的问题。
this.player.body.collideWorldBounds = true
this.foregroundLayer.setCollisionBetween(1, 200)
this.physics.add.collider(this.player, this.foregroundLayer)
在更新方法中
this.physics.collide(this.player, this.foregroundLayer)
橙色是 debugGraphics,正如您所看到的,玩家(盒子)不会与水平方向的图 block 发生碰撞。是什么原因造成的? TIA。
最佳答案
好吧,错误在于我定义运动的方式。我必须使用
this.body.x += this.speed
而不是
this.x += this.speed
关于javascript - 街机物理碰撞不会与墙壁水平碰撞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60985971/