|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.graphics.g2d.Animation
public class Animation
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.
Field Summary | |
---|---|
float |
animationDuration
|
float |
frameDuration
|
static int |
LOOP
|
static int |
LOOP_PINGPONG
|
static int |
LOOP_RANDOM
|
static int |
LOOP_REVERSED
|
static int |
NORMAL
|
static int |
REVERSED
|
Constructor Summary | |
---|---|
Animation(float frameDuration,
Array<? extends TextureRegion> keyFrames)
Constructor, storing the frame duration and key frames. |
|
Animation(float frameDuration,
Array<? extends TextureRegion> keyFrames,
int playType)
Constructor, storing the frame duration, key frames and play type. |
|
Animation(float frameDuration,
TextureRegion... keyFrames)
Constructor, storing the frame duration and key frames. |
Method Summary | |
---|---|
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. |
boolean |
isAnimationFinished(float stateTime)
Whether the animation would be finished if played without looping (PlayMode Animation#NORMAL), given the state time. |
void |
setPlayMode(int playMode)
Sets the animation play mode. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NORMAL
public static final int REVERSED
public static final int LOOP
public static final int LOOP_REVERSED
public static final int LOOP_PINGPONG
public static final int LOOP_RANDOM
public final float frameDuration
public final float animationDuration
Constructor Detail |
---|
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, int playType)
frameDuration
- the time between frames in seconds.keyFrames
- the TextureRegion
s representing the frames.playType
- the type of animation play (NORMAL, REVERSED, LOOP, LOOP_REVERSED, LOOP_PINGPONG, LOOP_RANDOM)public Animation(float frameDuration, TextureRegion... keyFrames)
frameDuration
- the time between frames in seconds.keyFrames
- the TextureRegion
s representing the frames.Method Detail |
---|
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(int)
method.
stateTime
-
public int getKeyFrameIndex(float stateTime)
stateTime
-
public void setPlayMode(int playMode)
playMode
- can be one of the following: Animation.NORMAL, Animation.REVERSED, Animation.LOOP, Animation.LOOP_REVERSED,
Animation.LOOP_PINGPONG, Animation.LOOP_RANDOMpublic boolean isAnimationFinished(float stateTime)
stateTime
-
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |