Class ActorAnimator

java.lang.Object
com.codename1.gaming.platformer.view.ActorAnimator

public class ActorAnimator extends Object

Chooses an Actor's animation frame from its MovementState: the presentation half of Corgi Engine's animator parameters.

Each state maps to a Clip of frame indices in a sprite sheet. A state with no clip of its own borrows a related one -- running falls back to walking, crawling to crouching, every airborne state to jumping or falling, and in the end everything to idle -- so a character drawn with only idle, walk and jump frames still animates sensibly. One animator can serve every actor of a kind; the per-actor progress lives in a Track.

  • Constructor Details

    • ActorAnimator

      public ActorAnimator()
  • Method Details

    • set

      public ActorAnimator set(MovementState state, ActorAnimator.Clip clip)

      Sets a state's clip.

      Parameters
      • state: the state
      • clip: its clip, or null to borrow a related one
      Returns

      this animator

    • set

      public ActorAnimator set(MovementState state, int ticksPerFrame, boolean loop, int... frames)

      Sets a state's clip from frames.

      Parameters
      • state: the state
      • ticksPerFrame: ticks each frame shows
      • loop: whether it repeats
      • frames: the sheet frame indices
      Returns

      this animator

    • clipFor

      public ActorAnimator.Clip clipFor(MovementState state)

      The clip a state shows, borrowed if it has none.

      Parameters
      • state: the state
      Returns

      the clip, or null if not even idle has one

    • frameFor

      public int frameFor(ActorAnimator.Track track)

      The frame for a track.

      Parameters
      • track: the actor's track
      Returns

      the sheet frame index, 0 if nothing is set