MoveAnimator
A MoveAnimator makes the template class T able to animate a movement from its current position to a specified end position. The speed of the movement in both the X and Y direction can be controlled by supplying EasingEquations. The MoveAnimator performs a callback when the animation has finished.
This mixin can be used on any Drawable.
Inherits from: T
Public Functions
void | cancelMoveAnimation() |
Cancel move animation and leave the Drawable in its current position. | |
void | clearMoveAnimationEndedAction() |
Clears the move animation ended action previously set by setMoveAnimationEndedAction. | |
virtual uint16_t | getMoveAnimationDelay() const |
Gets the current animation delay. | |
virtual void | handleTickEvent() |
The tick handler that handles the actual animation steps. | |
bool | isMoveAnimationRunning() const |
Gets whether or not the move animation is running. | |
MoveAnimator() | |
virtual void | setMoveAnimationDelay(uint16_t delay) |
Sets a delay on animations done by the MoveAnimator. | |
void | setMoveAnimationEndedAction(GenericCallback< const MoveAnimator< T > & > & callback) |
Associates an action to be performed when the animation ends. | |
void | startMoveAnimation(int16_t endX, int16_t endY, uint16_t duration, EasingEquation xProgressionEquation =&EasingEquations::linearEaseNone, EasingEquation yProgressionEquation =&EasingEquations::linearEaseNone) |
Starts the move animation from the current position to the specified end position. | |
Protected Functions
void | nextMoveAnimationStep() |
Execute next step in move animation and stop the timer if the animation has finished. | |
Protected Attributes
uint16_t | moveAnimationCounter |
Counter that is equal to the current step in the animation. | |
uint16_t | moveAnimationDelay |
The delay applied before animation start. Expressed in ticks. | |
uint16_t | moveAnimationDuration |
The complete duration of the actual animation. Expressed in ticks. | |
GenericCallback< const MoveAnimator< T > & > * | moveAnimationEndedCallback |
Animation ended Callback. | |
int16_t | moveAnimationEndX |
The X value at the end of the animation. | |
int16_t | moveAnimationEndY |
The Y value at the end of the animation. | |
bool | moveAnimationRunning |
True if the animation is running. | |
int16_t | moveAnimationStartX |
The X value at the beginning of the animation. | |
int16_t | moveAnimationStartY |
The Y value at the beginning of the animation. | |
EasingEquation | moveAnimationXEquation |
EasingEquation expressing the development of the X value during the animation. | |
EasingEquation | moveAnimationYEquation |
EasingEquation expressing the development of the Y value during the animation. | |
Public Functions Documentation
cancelMoveAnimation
void cancelMoveAnimation | ( | ) |
Cancel move animation and leave the Drawable in its current position.
If the animation is not running, nothing is done.
clearMoveAnimationEndedAction
Clears the move animation ended action previously set by setMoveAnimationEndedAction.
The effect is that any action set using setMoveAnimationEndedAction() will not be executed.
getMoveAnimationDelay
virtual uint16_t getMoveAnimationDelay | ( | ) | const |
Gets the current animation delay.
The current animation delay.
handleTickEvent
virtual void handleTickEvent | ( | ) |
The tick handler that handles the actual animation steps.
isMoveAnimationRunning
bool isMoveAnimationRunning | ( | ) | const |
Gets whether or not the move animation is running.
true if the move animation is running.
MoveAnimator
setMoveAnimationDelay
virtual void setMoveAnimationDelay | ( | uint16_t | delay | ) | |
setMoveAnimationEndedAction
void setMoveAnimationEndedAction | ( | GenericCallback< const MoveAnimator< T > & > & | callback | ) | |
Associates an action to be performed when the animation ends.
callback | The callback to be executed. The callback will be given a reference to the MoveAnimator. |
startMoveAnimation
void startMoveAnimation | ( | int16_t | endX , | ||
int16_t | endY , | ||||
uint16_t | duration , | ||||
EasingEquation | xProgressionEquation =&EasingEquations::linearEaseNone, | ||||
EasingEquation | yProgressionEquation =&EasingEquations::linearEaseNone | ||||
) |
Starts the move animation from the current position to the specified end position.
The development of the position (X, Y) during the animation is described by the supplied EasingEquations. If no easing equation is given, the movement is performed linear.
endX | The X position at animation end. |
endY | The Y position at animation end. |
duration | The duration of the animation measured in ticks. |
xProgressionEquation | (Optional) The equation that describes the development of the X position during the animation. Default is EasingEquations::linearEaseNone. |
yProgressionEquation | (Optional) The equation that describes the development of the Y position during the animation. Default is EasingEquations::linearEaseNone. |
Protected Functions Documentation
nextMoveAnimationStep
void nextMoveAnimationStep | ( | ) |
Execute next step in move animation and stop the timer if the animation has finished.
Protected Attributes Documentation
moveAnimationCounter
uint16_t moveAnimationCounter
Counter that is equal to the current step in the animation.
moveAnimationDelay
uint16_t moveAnimationDelay
The delay applied before animation start. Expressed in ticks.
moveAnimationDuration
uint16_t moveAnimationDuration
The complete duration of the actual animation. Expressed in ticks.
moveAnimationEndedCallback
GenericCallback< const MoveAnimator< T > & > * moveAnimationEndedCallback
Animation ended Callback.
moveAnimationEndX
int16_t moveAnimationEndX
The X value at the end of the animation.
moveAnimationEndY
int16_t moveAnimationEndY
The Y value at the end of the animation.
moveAnimationRunning
bool moveAnimationRunning
True if the animation is running.
moveAnimationStartX
int16_t moveAnimationStartX
The X value at the beginning of the animation.
moveAnimationStartY
int16_t moveAnimationStartY
The Y value at the beginning of the animation.
moveAnimationXEquation
EasingEquation moveAnimationXEquation
EasingEquation expressing the development of the X value during the animation.
moveAnimationYEquation
EasingEquation moveAnimationYEquation
EasingEquation expressing the development of the Y value during the animation.