【发布时间】:2016-07-02 16:47:10
【问题描述】:
我遇到了一个问题,当我移动我的精灵时它停止了,我必须再次按下才能让精灵再次移动。
我想要的是当用户按住他们的输入时,角色会继续向输入的方向移动,而不是在输入会使角色移动一点点并且需要手指抬起并再次输入的那一刻发生的事情.我已附上以下内容以尝试帮助解释。
目前正在发生的事情:
我想要什么:
我的代码如下,请告知为什么会这样,如果可能的话我需要改变什么
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (Gdx.input.isTouched()) {
player.b2body.applyLinearImpulse(new Vector2(5.1f, 0), player.b2body.getWorldCenter(), true);
}
}
return true;
}
这里还有一个类似的代码示例:https://github.com/BrentAureli/SuperMario/blob/master/core/src/com/brentaureli/mariobros/Screens/PlayScreen.java
【问题讨论】:
标签: java android libgdx sprite ontouch