public class Animation extends Object
An Animation stores a list of TextureRegion
s representing an animated sequence, e.g. for running or jumping. Each
region of an Animation is called a key frame, multiple key frames make up the animation.
Modifier and Type | Class and Description |
---|---|
static class |
Animation.PlayMode
Defines possible playback modes for an
Animation . |
Constructor and Description |
---|
Animation(float frameDuration,
Array<? extends TextureRegion> keyFrames)
Constructor, storing the frame duration and key frames.
|
Animation(float frameDuration,
Array<? extends TextureRegion> keyFrames,
Animation.PlayMode playMode)
Constructor, storing the frame duration, key frames and play type.
|
Animation(float frameDuration,
TextureRegion... keyFrames)
Constructor, storing the frame duration and key frames.
|
Modifier and Type | Method and Description |
---|---|
float |
getAnimationDuration() |
float |
getFrameDuration() |
TextureRegion |
getKeyFrame(float stateTime)
Returns a
TextureRegion based on the so called state time. |
TextureRegion |
getKeyFrame(float stateTime,
boolean looping)
Returns a
TextureRegion based on the so called state time. |
int |
getKeyFrameIndex(float stateTime)
Returns the current frame number.
|
TextureRegion[] |
getKeyFrames()
Returns the keyFrames[] array where all the TextureRegions of the animation are stored.
|
Animation.PlayMode |
getPlayMode()
Returns the animation play mode.
|
boolean |
isAnimationFinished(float stateTime)
Whether the animation would be finished if played without looping (PlayMode#NORMAL), given the state time.
|
void |
setFrameDuration(float frameDuration)
Sets duration a frame will be displayed.
|
void |
setPlayMode(Animation.PlayMode playMode)
Sets the animation play mode.
|
public Animation(float frameDuration, Array<? extends TextureRegion> keyFrames)
frameDuration
- the time between frames in seconds.keyFrames
- the TextureRegion
s representing the frames.public Animation(float frameDuration, Array<? extends TextureRegion> keyFrames, Animation.PlayMode playMode)
frameDuration
- the time between frames in seconds.keyFrames
- the TextureRegion
s representing the frames.playMode
- the animation playback mode.public Animation(float frameDuration, TextureRegion... keyFrames)
frameDuration
- the time between frames in seconds.keyFrames
- the TextureRegion
s representing the frames.public TextureRegion getKeyFrame(float stateTime, boolean looping)
TextureRegion
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.stateTime
- the time spent in the state represented by this animation.looping
- whether the animation is looping or not.public TextureRegion getKeyFrame(float stateTime)
TextureRegion
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
setPlayMode(PlayMode)
method.stateTime
- public int getKeyFrameIndex(float stateTime)
stateTime
- public TextureRegion[] getKeyFrames()
public Animation.PlayMode getPlayMode()
public void setPlayMode(Animation.PlayMode playMode)
playMode
- The animation Animation.PlayMode
to use.public boolean isAnimationFinished(float stateTime)
stateTime
- public void setFrameDuration(float frameDuration)
frameDuration
- in secondspublic float getFrameDuration()
public float getAnimationDuration()
Copyright © 2014. All rights reserved.