I want to create game like a flappy bird. I want player to jump continuously on the screen. I created this code, and it's not like a flappy bird jumping
Code:
float jump = 100; // Just example
if(Gdx.input.justTouched())
body.applyForceToCenter(0, jump * delta, true);
The problem is when user fast tap on screen, the player is shot like a rocket. Also when player falling the jump is lower. How can I fix this, and get always the same jump strength?
My solution:
jumpTimer += delta;
if(Gdx.input.justTouched()) {
if (jumpTimer > jumpTime) {
body.setLinearVelocity(body.getLinearVelocity().x, 0);
body.applyForceToCenter(0, jump * delta, true);
}
jumpTimer = 0;
}