Package nl.saxion.gameapp.animation
Class Timeline
Timeline allows you to compose multiple Animatable objects (Tweens, SpriteAnimations, or other Timelines)
into a single sequence or parallel set of animations.
By default, animations are added sequentially: each animation starts after the previous one finishes. You can also add animations with a positive or negative delay to adjust timing manually.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(Animatable<?> anim) Add an Animatable sequentially: it starts after the previous animations finish.add(Animatable<?> anim, float delay) Add an Animatable with a specific delay.static Timelinecreate()floatReturns the total duration of the timeline (last animation's end time)booleanReturns true if all animations have finished.voidreset()Reset without reversing.voidreset(boolean reverse) Reset all animations.update(float deltaTime) Update the timeline by deltaTime.
-
Constructor Details
-
Timeline
public Timeline()
-
-
Method Details
-
create
-
add
Add an Animatable sequentially: it starts after the previous animations finish. -
add
Add an Animatable with a specific delay.- Parameters:
anim- the Animatable to adddelay- delay in seconds relative to the timeline start (can be negative)
-
update
Update the timeline by deltaTime. Calls update on all Animatables whose startTime has been reached.- Specified by:
updatein classAnimatable<Void>- Parameters:
deltaTime- the time in seconds since the last update
-
isFinished
public boolean isFinished()Returns true if all animations have finished.- Specified by:
isFinishedin classAnimatable<Void>- Returns:
trueif the animation or interpolation has completed,falseotherwise
-
reset
public void reset(boolean reverse) Reset all animations.- Specified by:
resetin classAnimatable<Void>- Parameters:
reverse- if true, animations are reset in reverse (and sequence order is reversed)
-
reset
public void reset()Reset without reversing.- Overrides:
resetin classAnimatable<Void>
-
getTotalDuration
public float getTotalDuration()Returns the total duration of the timeline (last animation's end time)
-