I'm working on a project in LibGDX. It's a 2d platform game; you can say it's like Super Mario.
So this is how I move my player to the right:
if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)){
player.b2body.applyLinearImpulse(
new Vector2(0.1f, 0),
player.b2body.getWorldCenter(),
true);
}
When I release the key, the player is still moving a bit. (It still has a "Linear Impulse" force on its physical body, I think).
How can I make it stop?
My question could be simple as: What is the best way to move a physical body on LibGDX in one direction while holding a key. When I release the key, the body stops immediately.
I have tried with "setTransform" and it's causing issues when the body is touching other objects - plus the shape comes "before" the rest of the game in the screen (you can see it on debug)
Thanks.