Class Animatable<T>

java.lang.Object
nl.saxion.gameapp.animation.Animatable<T>
Direct Known Subclasses:
Interpolator, SpriteAnimation, Timeline, Tween

public abstract class Animatable<T> extends Object
Represents any object that can be animated or interpolated over time.

This is a common base class for both Interpolator and SpriteAnimation, allowing them to be updated, reset, and queried for completion in a uniform way. It is especially useful for composing timelines, sequences, or parallel animations.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract boolean
    Checks whether the animation or interpolation has finished.
    void
    Resets the animation or interpolation to its initial state without reversing.
    abstract void
    reset(boolean reverse)
    Resets the animation or interpolation to its initial state.
    abstract T
    update(float deltaTime)
    Updates the animation or interpolation by the specified amount of time.

    Methods inherited from class java.lang.Object

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

    • Animatable

      public Animatable()
  • Method Details

    • update

      public abstract T update(float deltaTime)
      Updates the animation or interpolation by the specified amount of time.

      This method should be called every frame (e.g., inside your game loop) with the time elapsed since the last update.

      Parameters:
      deltaTime - the time in seconds since the last update
    • isFinished

      public abstract boolean isFinished()
      Checks whether the animation or interpolation has finished.

      For looping animations, this may always return false.

      Returns:
      true if the animation or interpolation has completed, false otherwise
    • reset

      public abstract void reset(boolean reverse)
      Resets the animation or interpolation to its initial state.

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

      Parameters:
      reverse - whether to reset in reverse mode (if supported)
    • reset

      public void reset()
      Resets the animation or interpolation to its initial state without reversing.

      Equivalent to calling reset(boolean) with reverse set to false.