I have this if statement in my LibGDX game. The problem is that my player watching left, he moves in the left direction, which is correct, but if he watshes in right direction he moves left anyway. How can I solve this problem?
public boolean keyUp(int keycode) {
if (keycode == Input.Keys.A && player.b2body.getLinearVelocity().x >=-0.5) {
SpinDashleft();
return true;
}
else if (keycode == Input.Keys.A && player.b2body.getLinearVelocity().x <=0.5) {
SpinDashright();
return true;
}
return false;
}
public void SpinDashleft() {
player.b2body.applyLinearImpulse(new Vector2(-7.1f, 0), player.b2body.getWorldCenter(),true);
}
public void SpinDashright() {
player.b2body.applyLinearImpulse(new Vector2(7.00f, 0), player.b2body.getWorldCenter(),true);
}
Aucun commentaire:
Enregistrer un commentaire