An Animation stores a list of objects representing an animated sequence, e.g. for running or jumping. Each object in the Animation is called a key frame, and multiple key frames make up the animation.
The animation's type is the class representing a frame of animation. For example, a typical 2D animation could be made up of
TextureRegions and would be specified as:
Animation<TextureRegion> myAnimation = new Animation<TextureRegion>(...);
| Modifier and Type | Class and Description |
|---|---|
| public static enum | Animation.
Defines possible playback modes for an |
| Modifier and Type | Field and Description |
|---|---|
| private float | |
| private float | |
| pack-priv T[] | keyFrames
Length must not be modified without updating |
| private int | |
| private float | |
| private Animation. |
| Access | Constructor and Description |
|---|---|
| public | Animation(float
the time between frames in seconds. frameDuration, Array<? extends T> the objects representing the frames. If this Array is type-aware, keyFrames)getKeyFrames() can return the
correct type of array. Otherwise, it returns an Object[].Constructor, storing the frame duration and key frames. |
| public | Animation(float
the time between frames in seconds. frameDuration, Array<? extends T> the objects representing the frames. If this Array is type-aware, keyFrames, Animation.getKeyFrames() can return the
correct type of array. Otherwise, it returns an Object[].Constructor, storing the frame duration and key frames. |
| public | Animation(float
the time between frames in seconds. frameDuration, T... the objects representing the frames. keyFrames)Constructor, storing the frame duration and key frames. |
| Modifier and Type | Method and Description |
|---|---|
| public float | getAnimationDuration()
Returns: the duration of the entire animation, number of frames times frame duration, in seconds |
| public float | |
| public T | Returns: the frame of animation for the given state time.the time spent in the state represented by this animation. stateTime, boolean whether the animation is looping or not. looping)Returns a frame based on the so called state time. |
| public T | Returns: the frame of animation for the given state time.Returns a frame based on the so called state time. |
| public int | |
| public T[] | Returns: The keyframes[] field. This array is an Object[] if the animation was instantiated with an Array that was not type-aware.Returns the keyframes[] array where all the frames of the animation are stored. |
| public Animation. | |
| public boolean | Returns: whether the animation is finished.Whether the animation would be finished if played without looping (PlayMode#NORMAL), given the state time. |
| public void | |
| protected void | |
| public void |
| animationDuration | back to summary |
|---|---|
| private float animationDuration | |
| frameDuration | back to summary |
|---|---|
| private float frameDuration | |
| keyFrames | back to summary |
|---|---|
| pack-priv T[] keyFrames Length must not be modified without updating | |
| lastFrameNumber | back to summary |
|---|---|
| private int lastFrameNumber | |
| lastStateTime | back to summary |
|---|---|
| private float lastStateTime | |
| playMode | back to summary |
|---|---|
| private Animation. | |
| Animation | back to summary |
|---|---|
| public Animation(float frameDuration, Array<? extends T> keyFrames) Constructor, storing the frame duration and key frames.
| |
| Animation | back to summary |
|---|---|
| public Animation(float frameDuration, Array<? extends T> keyFrames, Animation. Constructor, storing the frame duration and key frames.
| |
| Animation | back to summary |
|---|---|
| public Animation(float frameDuration, T... keyFrames) Constructor, storing the frame duration and key frames.
| |
| getAnimationDuration | back to summary |
|---|---|
public float getAnimationDuration()
| |
| getFrameDuration | back to summary |
|---|---|
public float getFrameDuration()
| |
| getKeyFrame | back to summary |
|---|---|
| public T getKeyFrame(float stateTime, boolean looping) Returns a frame based on the so called state time. This is the amount of seconds an object has spent in the state this Animation instance represents, e.g. running, jumping and so on. The mode specifies whether the animation is looping or not.
| |
| getKeyFrame | back to summary |
|---|---|
| public T getKeyFrame(float stateTime) Returns a frame based on the so called state time. This is the amount of seconds an object has spent in the state this
Animation instance represents, e.g. running, jumping and so on using the mode specified by
| |
| getKeyFrameIndex | back to summary |
|---|---|
| public int getKeyFrameIndex(float stateTime) Returns the current frame number.
| |
| getKeyFrames | back to summary |
|---|---|
| public T[] getKeyFrames() Returns the keyframes[] array where all the frames of the animation are stored.
| |
| getPlayMode | back to summary |
|---|---|
| public Animation. Returns the animation play mode. | |
| isAnimationFinished | back to summary |
|---|---|
| public boolean isAnimationFinished(float stateTime) Whether the animation would be finished if played without looping (PlayMode#NORMAL), given the state time.
| |
| setFrameDuration | back to summary |
|---|---|
| public void setFrameDuration(float frameDuration) Sets duration a frame will be displayed.
| |
| setKeyFrames | back to summary |
|---|---|
| protected void setKeyFrames(T... keyFrames) | |
| setPlayMode | back to summary |
|---|---|
| public void setPlayMode(Animation. Sets the animation play mode. | |
Animation.
| Modifier and Type | Field and Description |
|---|---|
| public static final Animation. | |
| public static final Animation. | |
| public static final Animation. | |
| public static final Animation. | |
| public static final Animation. | |
| public static final Animation. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Animation. | |
| public static Animation. |
| LOOP | back to summary |
|---|---|
| public static final Animation. | |
| LOOP_PINGPONG | back to summary |
|---|---|
| public static final Animation. | |
| LOOP_RANDOM | back to summary |
|---|---|
| public static final Animation. | |
| LOOP_REVERSED | back to summary |
|---|---|
| public static final Animation. | |
| NORMAL | back to summary |
|---|---|
| public static final Animation. | |
| REVERSED | back to summary |
|---|---|
| public static final Animation. | |
| PlayMode | back to summary |
|---|---|
| private PlayMode() | |
| valueOf | back to summary |
|---|---|
| public static Animation. | |
| values | back to summary |
|---|---|
| public static Animation. | |