Class JumpAbility
java.lang.Object
com.codename1.gaming.platformer.Ability
com.codename1.gaming.platformer.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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionintUpward speed of an air jump.intTicks a press is remembered before landing.intTicks after leaving the ground that a jump is still a ground jump.intUpward speed at take-off, fixed point per tick.intJumps allowed before landing again; 2 is a double jump.intFraction of upward speed kept when the button is released early. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidearlyProcess(Actor c, PlatformWorld world) Runs before any ability sets velocity: timers and input edges.longhashState(long h) Mixes the ability's own state into a hash, so two runs that diverge inside an ability are caught.voidlateProcess(Actor c, PlatformWorld world) Runs after the body moved, with the new contacts.voidprocess(Actor c, PlatformWorld world) Sets velocity and claims aMovementState.voidreset()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.voidresetJumps(int used) Lets the actor jump again in the air, as a wall jump or a bounce does.Methods inherited from class Ability
isEnabled, mix, setEnabled
-
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
Description copied from class:AbilityRuns before any ability sets velocity: timers and input edges.
Parameters
c: the actorworld: the world
- Overrides:
earlyProcessin classAbility
-
process
Description copied from class:AbilitySets velocity and claims a
MovementState.Parameters
c: the actorworld: the world
-
lateProcess
Description copied from class:AbilityRuns after the body moved, with the new contacts.
Parameters
c: the actorworld: the world
- Overrides:
lateProcessin classAbility
-
resetJumps
public void resetJumps(int used) Lets the actor jump again in the air, as a wall jump or a bounce does.
Parameters
used: jumps to count as used afterwards
-
hashState
-
reset
-