Class TweenEngine

java.lang.Object
rocks.friedrich.engine_omega.tweening.TweenEngine
All Implemented Interfaces:
FrameUpdateListener

public class TweenEngine extends Object implements FrameUpdateListener
The TweenEngine is the central manager for Tweens. It tracks all current Tween instances and applies their TweenEquation with every GameLoop update.
  • Constructor Details

    • TweenEngine

      public TweenEngine()
      Instantiates a new TweenEngine.
  • Method Details

    • begin

      public Tween begin(Tweenable target, TweenType type, int duration)
      Begins a new Tween. If a Tween is already registered for the Tweenable with the given TweenType, it is restarted with the given duration.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
      duration - the duration of the Tween in milliseconds.
      Returns:
      the Tween instance
    • getTween

      public Tween getTween(Tweenable target, TweenType type)
      Attempts to get a previously registered Tween or registers a new one.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
      Returns:
      the Tween instance
    • getTweens

      public Map<Tweenable,Map<TweenType,Tween>> getTweens()
      Gets the map of registered Tweens.
      Returns:
      the map of registered Tweens.
    • reset

      public Tween reset(Tweenable target, TweenType type)
      Looks for a registered Tween instance with the given target and type. Attempts to stop the Tween and reset the Tweenable values to the start values.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
      Returns:
      the Tween instance
    • resume

      public Tween resume(Tweenable target, TweenType type)
      Looks for a registered Tween instance with the given target and type. Attempts to resume the Tween if it was stopped.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
      Returns:
      the Tween instance
    • start

      public void start()
      Start.
    • remove

      public void remove(Tweenable target, TweenType type)
      Looks for a registered Tween instance with the given target and type. Attempts to remove the Tween from the TweenEngine.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
    • stop

      public Tween stop(Tweenable target, TweenType type)
      Looks for a registered Tween instance with the given target and type. Attempts to stop the Tween.
      Parameters:
      target - the Tweenable target object
      type - the TweenType determining which values of the target object will be modified.
      Returns:
      the Tween instance
    • terminate

      public void terminate()
      Terminate.
    • onFrameUpdate

      public void onFrameUpdate(double deltaSeconds)
      Updates all registered Tweens by applying the TweenEquation.
      Specified by:
      onFrameUpdate in interface FrameUpdateListener
      Parameters:
      deltaSeconds - Die Zeit in Sekunden, die seit der letzten Aktualisierung vergangen ist.