java.lang.Object
de.gurkenlabs.litiengine.tweening.Tween

public class Tween
extends java.lang.Object
A Tween is an interpolation between start values and target values over a given time period. It modifies the start values by applying an easing function (TweenEquation) each tick.
  • Constructor Summary

    Constructors 
    ConstructorDescription
    Tween​(Tweenable target, TweenType type, int duration)
    Instantiates a new tween.
  • Method Summary

    Modifier and TypeMethodDescription
    Tweenbegin()
    Begins the Tween by setting its start time to the current game time in ticks.
    Tweenease​(TweenEquation easeEquation)
    Sets a custom easing function for this Tween.
    Tweenease​(TweenFunction easingFunction)
    Sets a predefined easing function for this Tween.
    longgetDuration()
    Gets the duration of the Tween.
    TweenEquationgetEquation()
    Gets the tween equation that modifies the start values each tick.
    longgetStartTime()
    Gets the start time of the Tween.
    float[]getStartValues()
    Gets the start values.
    TweenablegetTarget()
    Gets the Tweenable target object.
    float[]getTargetValues()
    Gets the target values.
    TweenTypegetType()
    Gets the tween type determining which values of the Tweenable object will be modified.
    booleanhasStopped()
    Checks if the Tween has stopped.
    Tweenreset()
    Resets the Tween values to the start values.
    Tweenresume()
    Resumes the stopped Tween.
    voidsetDuration​(int duration)
    Sets the Tween duration.
    Tweenstop()
    Stops the Tween.
    Tweentarget​(float... targetValues)
    Sets the target values absolutely.
    TweentargetRelative​(float... targetValues)
    Sets the target values relatively to the start values.

    Methods inherited from class java.lang.Object

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

    • Tween

      public Tween​(Tweenable target, TweenType type, int duration)
      Instantiates a new tween.
      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.
  • Method Details

    • begin

      public Tween begin()
      Begins the Tween by setting its start time to the current game time in ticks.
      Returns:
      the Tween instance
    • ease

      public Tween ease​(TweenEquation easeEquation)
      Sets a custom easing function for this Tween.
      Parameters:
      easeEquation - the TweenEquation applied to the tween values.
      Returns:
      the Tween instance.
    • ease

      public Tween ease​(TweenFunction easingFunction)
      Sets a predefined easing function for this Tween.
      Parameters:
      easingFunction - the TweenFunction applied to the tween values.
      Returns:
      the Tween instance.
    • getDuration

      public long getDuration()
      Gets the duration of the Tween.
      Returns:
      the duration of the Tween in milliseconds
    • getEquation

      public TweenEquation getEquation()
      Gets the tween equation that modifies the start values each tick.
      Returns:
      the TweenEquation
    • getStartTime

      public long getStartTime()
      Gets the start time of the Tween.
      Returns:
      the start time in milliseconds
    • getStartValues

      public float[] getStartValues()
      Gets the start values.
      Returns:
      the start values
    • getTarget

      public Tweenable getTarget()
      Gets the Tweenable target object.
      Returns:
      the target
    • getTargetValues

      public float[] getTargetValues()
      Gets the target values.
      Returns:
      the target values
    • getType

      public TweenType getType()
      Gets the tween type determining which values of the Tweenable object will be modified.
      Returns:
      the TweenType of this Tween
    • hasStopped

      public boolean hasStopped()
      Checks if the Tween has stopped.
      Returns:
      true, if successful
    • reset

      public Tween reset()
      Resets the Tween values to the start values.
      Returns:
      the Tween instance
    • resume

      public Tween resume()
      Resumes the stopped Tween.
      Returns:
      the Tween instance
    • setDuration

      public void setDuration​(int duration)
      Sets the Tween duration.
      Parameters:
      duration - the new duration in milliseconds
    • stop

      public Tween stop()
      Stops the Tween.
      Returns:
      the Tween instance
    • target

      public Tween target​(float... targetValues)
      Sets the target values absolutely.
      Parameters:
      targetValues - the absolute target values
      Returns:
      the Tween instance
    • targetRelative

      public Tween targetRelative​(float... targetValues)
      Sets the target values relatively to the start values.
      Parameters:
      targetValues - the relative target values with respect to the start values
      Returns:
      the Tween instance