Hi, this is my first post here.
I’m developing my own 2D platform game. I’m only at the beginning. Now I’m trying to make the player jump.
The jump itself works fine but I’m not able to stop the player. Here is some code:
public void tick() {
[ some code ]
if (_status == JUMPING) {
jumpAnimator.tick();
position.y = jumpAnimator.getValue();
}
}
jumpAnimator
is an object that calculates the current y position. It works very well and the jump follows a realistic curve.
I want the player jumping, falling and when he reaches the bottom of the screen, stopping.
To stop the jump my idea was to set the _status
variable to STOPPED
when the player reaches the bottom of the screen.
public void tick() {
[ some code ]
if (_status == JUMPING) {
jumpAnimator.tick();
position.y = jumpAnimator.getValue();
}
if ( /*reached the bottom*/ ) {
_status = STOPPED;
}
}
If I add those lines, the player won’t jump anymore because he starts to jump and immediately set his _status
to STOPPED
.
Any idea?