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

  1. Object
  2. Ability
  3. JumpAbility

Jumping, with the forgiveness that makes a platformer feel right:

  • Coyote time: a jump still works for coyoteTicks after walking off a ledge.
  • Jump buffering: a press up to bufferTicks before landing jumps on landing.
  • Variable height: releasing the button while rising cuts the jump.
  • Multi-jump: maxJumps above 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 jumpSpeedUpward speed at take-off, fixed point per tick.
public int airJumpSpeedUpward speed of an air jump.
public int maxJumpsJumps allowed before landing again; 2 is a double jump.
public int coyoteTicksTicks after leaving the ground that a jump is still a ground jump.
public int bufferTicksTicks a press is remembered before landing.
public int releaseCutFraction 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

Field details

jumpSpeed

public int jumpSpeed
Upward speed at take-off, fixed point per tick.

airJumpSpeed

public int airJumpSpeed
Upward speed of an air jump.

maxJumps

public int maxJumps
Jumps allowed before landing again; 2 is a double jump.

coyoteTicks

public int coyoteTicks
Ticks after leaving the ground that a jump is still a ground jump.

bufferTicks

public int bufferTicks
Ticks a press is remembered before landing.

releaseCut

public int releaseCut
Fraction 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

c Actor
the actor
world PlatformWorld
the world

process

public void process(Actor c, PlatformWorld world)
Sets velocity and claims a MovementState.

Parameters

c Actor
the actor
world PlatformWorld
the world

lateProcess

public void lateProcess(Actor c, PlatformWorld world)
Runs after the body moved, with the new contacts.

Parameters

c Actor
the actor
world PlatformWorld
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

used int
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

h long
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.