Class Tween


public class Tween extends Animatable<Void>
Tween allows you to animate properties of an object over time with GSAP-like chaining.
  • Method Summary

    Modifier and Type
    Method
    Description
    delay(float seconds)
    Set a delay before starting.
    duration(float duration)
    Set the duration of this Tween (for all steps).
    ease(com.badlogic.gdx.math.Interpolation interpolation)
    Set the easing interpolation for this Tween.
    float
     
    float
    Returns the total duration including all steps and the start delay.
    boolean
    Checks whether the animation or interpolation has finished.
    static Tween
    on(Object target)
    Start tweening a specific object.
    onComplete(Runnable callback)
    Callback when this tween finishes.
    void
    reset(boolean reverse)
    Resets the animation or interpolation to its initial state.
    to(String property, float endValue)
    Add a property to tween to a target value.
    toX(float x)
    Shortcut for X property (example for position).
    toY(float y)
    Shortcut for Y property.
    update(float deltaTime)
    Update the tween.

    Methods inherited from class nl.saxion.gameapp.animation.Animatable

    reset

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • on

      public static Tween on(Object target)
      Start tweening a specific object.
    • to

      public Tween to(String property, float endValue)
      Add a property to tween to a target value.
    • toX

      public Tween toX(float x)
      Shortcut for X property (example for position).
    • toY

      public Tween toY(float y)
      Shortcut for Y property.
    • duration

      public Tween duration(float duration)
      Set the duration of this Tween (for all steps).
    • ease

      public Tween ease(com.badlogic.gdx.math.Interpolation interpolation)
      Set the easing interpolation for this Tween.
    • delay

      public Tween delay(float seconds)
      Set a delay before starting.
    • onComplete

      public Tween onComplete(Runnable callback)
      Callback when this tween finishes.
    • getStartOffset

      public float getStartOffset()
    • getTotalDuration

      public float getTotalDuration()
      Returns the total duration including all steps and the start delay.
    • update

      public Void update(float deltaTime)
      Update the tween. Call every frame with delta time.
      Specified by:
      update in class Animatable<Void>
      Parameters:
      deltaTime - the time in seconds since the last update
      Returns:
    • isFinished

      public boolean isFinished()
      Description copied from class: Animatable
      Checks whether the animation or interpolation has finished.

      For looping animations, this may always return false.

      Specified by:
      isFinished in class Animatable<Void>
      Returns:
      true if the animation or interpolation has completed, false otherwise
    • reset

      public void reset(boolean reverse)
      Description copied from class: Animatable
      Resets the animation or interpolation to its initial state.

      Subclasses may implement the reverse flag to play the animation backward if desired.

      Specified by:
      reset in class Animatable<Void>
      Parameters:
      reverse - whether to reset in reverse mode (if supported)