【发布时间】:2019-04-18 21:11:55
【问题描述】:
我需要一个 Phaser 3 精灵根据重力垂直下落和弹跳。当玩家释放控制器时,我还希望身体水平降低速度。
但似乎重力和摩擦不能很好地结合在一起......? 一旦我添加阻尼和阻力,重力就会完全搞砸。要么精灵下落非常非常缓慢,要么完全移除重力。
如何将水平拖动与垂直重力结合起来?
物理设置
this.body.setBounce(1, 1)
this.body.allowGravity = true // only works without drag/damping
this.body.allowDrag = true
this.body.useDamping = true
this.body.setDrag(0.88, 0.95) // x drag and y drag
控件
if (this.cursors.left.isDown) {
this.body.setVelocityX(-300)
}
else if (this.cursors.right.isDown) {
this.body.setVelocityX(300)
}
if (this.cursors.up.isDown) {
this.body.setVelocityY(-300)
}
【问题讨论】:
标签: javascript phaser-framework