Package nl.colorize.multimedialib.stage
Class Animation
java.lang.Object
nl.colorize.multimedialib.stage.Animation
2D sprite animation that shows a number of images in sequence. Every frame
in the animation is shown for a certain amount of time, indicated in seconds.
After all images have been shown, the animation will either loop or keep
showing the last image.
Note that this class *describes* the animation, it does not contain any state that relates to *showing* the animation. This allows for using the same animation data to display the animation multiple times simultaneously, but it does mean the animation's playback state needs to be managed by the user of this class.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Returns a new animation that contains all frames of this animation followed by all frames of the specified other animation.copy()
float
getFrameAtIndex
(int index) getFrameAtTime
(float time) int
float
getFrameTime
(int index) boolean
isLoop()
mirror()
Returns a new animation with the same frames as this one, but appends the reversed version of the animation.repeat
(int times) Returns a new animation with the same frames as this one, but repeated by the specified number of times.reverse()
Returns a new animation with the same frames as this one, but with all frames and corresponding frame times in reverse compared to the original.void
setFrameTime
(float frameTime) Changes the frame time for all frames within this animation.void
setFrameTime
(int index, float frameTime) Changes the frame time for the frame located at the specified index.void
setFrameTimes
(List<Float> frameTimes) Changes the frame time for all frames within this animation.
-
Constructor Details
-
Animation
public Animation(boolean loop) -
Animation
-
Animation
-
-
Method Details
-
addFrame
-
getFrameCount
public int getFrameCount() -
getFrameImages
-
getFrameAtIndex
-
getFrameAtTime
-
getDuration
public float getDuration() -
setFrameTime
public void setFrameTime(int index, float frameTime) Changes the frame time for the frame located at the specified index. -
setFrameTimes
Changes the frame time for all frames within this animation. The number of elements in the list needs to match the number of frames within this animation. -
setFrameTime
public void setFrameTime(float frameTime) Changes the frame time for all frames within this animation. -
getFrameTime
public float getFrameTime(int index) -
isLoop
public boolean isLoop() -
copy
-
reverse
Returns a new animation with the same frames as this one, but with all frames and corresponding frame times in reverse compared to the original. -
append
Returns a new animation that contains all frames of this animation followed by all frames of the specified other animation. -
repeat
Returns a new animation with the same frames as this one, but repeated by the specified number of times.- Throws:
IllegalArgumentException
- if the new animation does not repeat at least twice (since repeating once would be identical to the original animation.
-
mirror
Returns a new animation with the same frames as this one, but appends the reversed version of the animation. For example, if the original animation consists of frames1-2-3
, the result would be1-2-3-3-2-1
.
-