我对运动有疑问 . 我的目标是在按下键 for its own width/height 后按 player move . 例如:
if (Gdx.input.isKeyJustPressed(Input.Keys.A))
player.position.x = player.position.x-moveSpeed;
这是精确的,但我希望它更平滑,在一秒内移动精确的距离,但每毫秒一点,而不是一次 .
这使得玩家移动顺畅,但不准确:
if (Gdx.input.isKeyJustPressed(Input.Keys.A))
player.position.x = player.position.x-moveSpeed*deltaTime;
如何进行平滑过渡,但是精确?
1 回答
更改(或扩展)您的播放器类,以便它包含以下内容:
然后在你的渲染方法中调用: