Class Tween
public class Tween
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 -
Method Summary
Modifier and TypeMethodDescriptionaddListener(TweenListener listener) Registers aTweenListenerthat gets notified about the Tween's lifecycle events.ease(TweenEquation easeEquation) Sets a custom easing function for this Tween.ease(TweenFunction easingFunction) Sets a predefined easing function for this Tween.intGets the duration of the Tween.Gets the tween equation that modifies the start values each tick.getLoop()Gets the configured loop mode for this Tween.longGets the start tick of the Tween.float[]Gets the start values.Gets theTweenabletarget object.float[]Gets the target values.getType()Gets the tween type determining which values of theTweenableobject will be modified.booleanChecks if the Tween has stopped.booleanChecks whether the Tween is currently running in its reversed direction.booleanChecks if the Tween is currently running.Sets the loop mode for this Tween.removeListener(TweenListener listener) Removes a previously registeredTweenListener.reset()Resets the Tween values to the start values.resume()Resumes the stopped Tween.voidsetDuration(int duration) Sets the Tween duration.start()Starts the Tween by setting its start time to the current game time in ticks.stop()Stops the Tween.target(float... targetValues) Sets the target values absolutely.targetRelative(float... targetValues) Sets the target values relatively to the start values.
-
Constructor Details
-
Tween
-
-
Method Details
-
start
Starts the Tween by setting its start time to the current game time in ticks.- Returns:
- the Tween instance
-
isRunning
public boolean isRunning()Checks if the Tween is currently running.- Returns:
- true if the Tween is running, false otherwise.
-
ease
Sets a custom easing function for this Tween.- Parameters:
easeEquation- theTweenEquationapplied to the tween values.- Returns:
- the Tween instance.
-
ease
Sets a predefined easing function for this Tween.- Parameters:
easingFunction- theTweenFunctionapplied to the tween values.- Returns:
- the Tween instance.
-
getDuration
public int getDuration()Gets the duration of the Tween.- Returns:
- the duration of the Tween in ticks
-
getEquation
Gets the tween equation that modifies the start values each tick.- Returns:
- the TweenEquation
-
getStartTime
public long getStartTime()Gets the start tick of the Tween.- Returns:
- the start time in ticks
-
getStartValues
public float[] getStartValues()Gets the start values.- Returns:
- the start values
-
getTarget
-
getTargetValues
public float[] getTargetValues()Gets the target values.- Returns:
- the target values
-
getType
Gets the tween type determining which values of theTweenableobject will be modified.- Returns:
- the
TweenTypeof this Tween
-
hasStopped
public boolean hasStopped()Checks if the Tween has stopped.- Returns:
- true, if successful
-
reset
-
resume
-
setDuration
public void setDuration(int duration) Sets the Tween duration.- Parameters:
duration- the new duration in ticks
-
stop
-
getLoop
Gets the configured loop mode for this Tween.- Returns:
- the
TweenLoopmode.
-
loop
-
isReversed
public boolean isReversed()Checks whether the Tween is currently running in its reversed direction. This is only relevant forTweenLoop.PINGPONGtweens.- Returns:
trueif the Tween currently interpolates from its target values back to its start values.
-
addListener
Registers aTweenListenerthat gets notified about the Tween's lifecycle events.- Parameters:
listener- the listener to add.- Returns:
- the Tween instance.
-
removeListener
Removes a previously registeredTweenListener.- Parameters:
listener- the listener to remove.- Returns:
- the Tween instance.
-
target
Sets the target values absolutely.- Parameters:
targetValues- the absolute target values- Returns:
- the Tween instance
-
targetRelative
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
-