Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class JumpAbility
Jumping, with the forgiveness that makes a platformer feel right:
- Coyote time: a jump still works for
coyoteTicksafter walking off a ledge. - Jump buffering: a press up to
bufferTicksbefore landing jumps on landing. - Variable height: releasing the button while rising cuts the jump.
- Multi-jump:
maxJumpsabove 1 allows double (or more) jumps in the air. - Drop through: down + jump on a one-way platform falls through it instead.
Fields
public int jumpSpeed | Upward speed at take-off, fixed point per tick. |
public int airJumpSpeed | Upward speed of an air jump. |
public int maxJumps | Jumps allowed before landing again; 2 is a double jump. |
public int coyoteTicks | Ticks after leaving the ground that a jump is still a ground jump. |
public int bufferTicks | Ticks a press is remembered before landing. |
public int releaseCut | Fraction of upward speed kept when the button is released early. |
Constructors
public JumpAbility() |
Methods
public void earlyProcess(Actor c, PlatformWorld world) | Runs before any ability sets velocity: timers and input edges. |
public void process(Actor c, PlatformWorld world) | Sets velocity and claims a MovementState. |
public void lateProcess(Actor c, PlatformWorld world) | Runs after the body moved, with the new contacts. |
public void resetJumps(int used) | Lets the actor jump again in the air, as a wall jump or a bounce does. |
public long hashState(long h) | Mixes the ability’s own state into a hash, so two runs that diverge inside an ability are caught. |
public void reset() | Forgets what the ability was in the middle of, when its actor respawns: a dash, a buffered jump or a grip does not outlive a death. |
Inherited methods
From Ability
Field details
jumpSpeed
public int jumpSpeedUpward speed at take-off, fixed point per tick.
airJumpSpeed
public int airJumpSpeedUpward speed of an air jump.
maxJumps
public int maxJumpsJumps allowed before landing again; 2 is a double jump.
coyoteTicks
public int coyoteTicksTicks after leaving the ground that a jump is still a ground jump.
bufferTicks
public int bufferTicksTicks a press is remembered before landing.
releaseCut
public int releaseCutFraction of upward speed kept when the button is released early.
Constructor details
JumpAbility
public JumpAbility()Method details
earlyProcess
public void earlyProcess(Actor c, PlatformWorld world)Runs before any ability sets velocity: timers and input edges.
Parameters
cActor- the actor
worldPlatformWorld- the world
process
public void process(Actor c, PlatformWorld world)Sets velocity and claims a
MovementState.Parameters
cActor- the actor
worldPlatformWorld- the world
lateProcess
public void lateProcess(Actor c, PlatformWorld world)Runs after the body moved, with the new contacts.
Parameters
cActor- the actor
worldPlatformWorld- the world
resetJumps
public void resetJumps(int used)Lets the actor jump again in the air, as a wall jump or a bounce does.
Parameters
usedint- jumps to count as used afterwards
hashState
public long hashState(long h)Mixes the ability’s own state into a hash, so two runs that diverge inside
an ability are caught. The default mixes nothing.
Parameters
hlong- the running hash
Returns
the updated hash
reset
public void reset()Forgets what the ability was in the middle of, when its actor
respawns: a dash, a buffered jump or a grip does not outlive a death.
The default does nothing; an ability with per-run state overrides it.