Class Timeline

java.lang.Object
nl.saxion.gameapp.animation.Animatable<Void>
nl.saxion.gameapp.animation.Timeline

public class Timeline extends Animatable<Void>
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 Details

    • Timeline

      public Timeline()
  • Method Details

    • create

      public static Timeline create()
    • add

      public Timeline add(Animatable<?> anim)
      Add an Animatable sequentially: it starts after the previous animations finish.
    • add

      public Timeline add(Animatable<?> anim, float delay)
      Add an Animatable with a specific delay.
      Parameters:
      anim - the Animatable to add
      delay - delay in seconds relative to the timeline start (can be negative)
    • update

      public Void update(float deltaTime)
      Update the timeline by deltaTime. Calls update on all Animatables whose startTime has been reached.
      Specified by:
      update in class Animatable<Void>
      Parameters:
      deltaTime - the time in seconds since the last update
    • isFinished

      public boolean isFinished()
      Returns true if all animations have finished.
      Specified by:
      isFinished in class Animatable<Void>
      Returns:
      true if the animation or interpolation has completed, false otherwise
    • reset

      public void reset(boolean reverse)
      Reset all animations.
      Specified by:
      reset in class Animatable<Void>
      Parameters:
      reverse - if true, animations are reset in reverse (and sequence order is reversed)
    • reset

      public void reset()
      Reset without reversing.
      Overrides:
      reset in class Animatable<Void>
    • getTotalDuration

      public float getTotalDuration()
      Returns the total duration of the timeline (last animation's end time)