public class Animation
extends java.lang.Object
| Constructor and Description |
|---|
Animation() |
Animation(AnimationMode mode) |
| Modifier and Type | Method and Description |
|---|---|
Animation |
finish()
Finish the animation immediately.
This will stop the animation if it is running. |
Animation |
finish(AnimationDirection direction)
Finish the animation immediately in the given direction.
This will stop the animation if it is running. |
Animation |
frame(java.util.function.Consumer<AnimationFrameBuilder> frameBuilder)
Add a new frame to the animation.
Fields that are not set will be copied from the previous frame. The start value will be copied from the end value of the previous frame. Copying values from the previous frame only works if a previous frame exists. |
Animation |
frame(EasingFunction easingFunction,
EasingMode easingMode,
float[] startValue,
float[] endValue,
java.lang.Integer duration,
EasingBehavior easingBehavior)
Add a new frame to the animation.
Fields that are set to null will be copied from the previous frame. |
Animation |
frame(EasingFunction easingFunction,
EasingMode easingMode,
float startValue,
float endValue,
java.lang.Integer duration,
EasingBehavior easingBehavior)
Add a new frame to the animation.
Fields that are set to null will be copied from the previous frame. |
int |
getCurrentFrame() |
AnimationDirection |
getDirection() |
float[] |
getEnd(int frame)
Get the end value of the given frame.
|
int |
getFrameCount() |
float[] |
getStart(int frame)
Get the start value of the given frame.
|
float |
getValue() |
float |
getValue(int index)
Get the current value of the animation at the given index.
|
float[] |
getValues() |
boolean |
isFinished() |
boolean |
isRunning() |
Animation |
reset()
Reset the animation to the start.
This will stop the animation if it is running. |
Animation |
reverse()
Reverse the current animation direction.
|
Animation |
runInDirection(AnimationDirection direction)
Run the animation in the given direction.
If the current direction is the same as the given direction, this method will do nothing. If the animation is not running, this method will start the animation into the given direction. If already running, the direction will be reversed. |
Animation |
setDirection(AnimationDirection direction)
Set the direction of the animation.
|
Animation |
setFrameByFrame(boolean frameByFrame)
Set if the animation should be played frame by frame or not.
If true, manually calling the start() method is required to continue the animation. |
Animation |
setMode(AnimationMode mode)
Set the mode of the animation.
This will reset the animation. |
Animation |
start()
Start the animation.
If the animation is already running, this method will do nothing. |
Animation |
start(AnimationDirection direction)
Start the animation in the given direction.
If the given direction is already set, this method will do nothing. |
Animation |
stop()
Stop the animation.
If the animation is already stopped, this method will do nothing. After stopping the animation, the current value will be saved and returned by getValues(). |
public Animation()
public Animation(AnimationMode mode)
public Animation frame(java.util.function.Consumer<AnimationFrameBuilder> frameBuilder)
frame(EasingFunction, EasingMode, float, float, Integer, EasingBehavior) or frame(EasingFunction, EasingMode, float[], float[], Integer, EasingBehavior) to add the first frame and ensure all values are set.frameBuilder - The builder for the framepublic Animation frame(@Nullable EasingFunction easingFunction, @Nullable EasingMode easingMode, float startValue, float endValue, @Nullable java.lang.Integer duration, @Nullable EasingBehavior easingBehavior)
null will be copied from the previous frame.easingFunction - The easing function for the frameeasingMode - The easing mode for the framestartValue - The start value for the frameendValue - The end value for the frameduration - The duration for the frameeasingBehavior - The reverse behavior for the framepublic Animation frame(@Nullable EasingFunction easingFunction, @Nullable EasingMode easingMode, @Nullable float[] startValue, @Nullable float[] endValue, @Nullable java.lang.Integer duration, @Nullable EasingBehavior easingBehavior)
null will be copied from the previous frame.easingFunction - The easing function for the frameeasingMode - The easing mode for the framestartValue - The start value for the frameendValue - The end value for the frameduration - The duration for the frameeasingBehavior - The reverse behavior for the framepublic Animation setMode(AnimationMode mode)
mode - The mode of the animationpublic Animation setFrameByFrame(boolean frameByFrame)
true, manually calling the start() method is required to continue the animation.frameByFrame - If the animation should be played frame by framepublic boolean isRunning()
public boolean isFinished()
public AnimationDirection getDirection()
public Animation setDirection(AnimationDirection direction)
direction - The direction of the animationpublic int getCurrentFrame()
public int getFrameCount()
public float[] getStart(int frame)
frame - The frame to get the start value frompublic float[] getEnd(int frame)
frame - The frame to get the end value frompublic Animation reverse()
public Animation runInDirection(AnimationDirection direction)
direction - The direction to run the animation inpublic Animation start(AnimationDirection direction)
direction - The direction to start the animation inpublic Animation start()
public Animation stop()
getValues().public Animation reset()
public Animation finish()
public Animation finish(AnimationDirection direction)
direction - The direction to finish the animation inpublic float getValue()
getValue(int),
getValues()public float getValue(int index)
index - The index of the value to getgetValues()public float[] getValues()