Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class ActorAnimator

  1. Object
  2. ActorAnimator

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.

Nested types

class ActorAnimator.ClipA run of frames.
class ActorAnimator.TrackOne actor’s place in its animation.

Constructors

public ActorAnimator()

Methods

public ActorAnimator set(MovementState state, ActorAnimator.Clip clip)Sets a state’s clip.
public ActorAnimator set(MovementState state, int ticksPerFrame, boolean loop, int... frames)Sets a state’s clip from frames.
public ActorAnimator.Clip clipFor(MovementState state)The clip a state shows, borrowed if it has none.
public int frameFor(ActorAnimator.Track track)The frame for a track.

Inherited methods

Constructor details

ActorAnimator

public ActorAnimator()

Method details

set

public ActorAnimator set(MovementState state, ActorAnimator.Clip clip)
Sets a state’s clip.

Parameters

state MovementState
the state
clip ActorAnimator.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 MovementState
the state
ticksPerFrame int
ticks each frame shows
loop boolean
whether it repeats
frames int...
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 MovementState
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 ActorAnimator.Track
the actor’s track

Returns

the sheet frame index, 0 if nothing is set