Class SwimAbility

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

public class SwimAbility extends Ability
Swimming in Tile#WATER: weak gravity, a slow sink, and a stroke upward on each jump press. Leaving the water at the surface with a stroke gives a small hop out.
  • Field Details

    • waterGravity

      public int waterGravity
      Gravity in water, fixed point per tick squared.
    • maxSink

      public int maxSink
      Fastest sink.
    • stroke

      public int stroke
      Upward speed of a stroke.
    • maxSwimSpeed

      public int maxSwimSpeed
      Horizontal speed limit in water.
  • Constructor Details

    • SwimAbility

      public SwimAbility()
  • Method Details

    • 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
    • isInWater

      public boolean isInWater()

      Whether the actor is in water.

      Returns

      true while swimming

    • 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