Class GripAbility

java.lang.Object
com.codename1.gaming.platformer.Ability
com.codename1.gaming.platformer.GripAbility

public class GripAbility extends Ability

Ledge grab: falling past the top corner of a solid tile while holding toward it, the actor catches the edge and hangs (MovementState.GRIPPING). Jump or up climbs onto the ledge; down or away lets go. Hanging takes no stamina and lasts until the player decides.

Only a corner with open space above it is gripped -- the top of a wall, the lip of a platform -- never the middle of a wall, which WallJumpAbility owns. Put grip after walljump and before jump in the ability list.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    How far below the corner, fixed point, the actor's head may be and still catch it: the reach of the hands.
    int
    Ticks after letting go before the same actor can grab again, so a drop is not caught by the corner it just left.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    hashState(long h)
    Mixes the ability's own state into a hash, so two runs that diverge inside an ability are caught.
    boolean
    Whether the actor is hanging from a ledge.
    void
    Runs after the body moved, with the new contacts.
    void
    Sets velocity and claims a MovementState.
    void
    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.

    Methods inherited from class Ability

    earlyProcess, isEnabled, mix, setEnabled

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • regrabTicks

      public int regrabTicks
      Ticks after letting go before the same actor can grab again, so a drop is not caught by the corner it just left.
    • reach

      public int reach
      How far below the corner, fixed point, the actor's head may be and still catch it: the reach of the hands.
  • Constructor Details

    • GripAbility

      public GripAbility()
  • Method Details

    • isGripping

      public boolean isGripping()

      Whether the actor is hanging from a ledge.

      Returns

      true while gripping

    • process

      public void process(Actor c, PlatformWorld world)
      Description copied from class: Ability

      Sets velocity and claims a MovementState.

      Parameters
      • c: the actor
      • world: the world
      Specified by:
      process in class Ability
    • lateProcess

      public void lateProcess(Actor c, PlatformWorld world)
      Description copied from class: Ability

      Runs after the body moved, with the new contacts.

      Parameters
      • c: the actor
      • world: the world
      Overrides:
      lateProcess in class Ability
    • hashState

      public long hashState(long h)
      Description copied from class: Ability

      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: the running hash
      Returns

      the updated hash

      Overrides:
      hashState in class Ability
    • reset

      public void reset()
      Description copied from class: Ability
      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.
      Overrides:
      reset in class Ability