주요 내용으로 건너뛰기

MoveAnimator

touchgfx/mixins/MoveAnimator.hpp

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

voidcancelMoveAnimation()
Cancel move animation and leave the Drawable in its current position.
voidclearMoveAnimationEndedAction()
Clears the move animation ended action previously set by setMoveAnimationEndedAction.
virtual uint16_tgetMoveAnimationDelay() const
Gets the current animation delay.
virtual voidhandleTickEvent()
The tick handler that handles the actual animation steps.
boolisMoveAnimationRunning() const
Gets whether or not the move animation is running.
MoveAnimator()
virtual voidsetMoveAnimationDelay(uint16_t delay)
Sets a delay on animations done by the MoveAnimator.
voidsetMoveAnimationEndedAction(GenericCallback< const MoveAnimator< T > & > & callback)
Associates an action to be performed when the animation ends.
voidstartMoveAnimation(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

voidnextMoveAnimationStep()
Execute next step in move animation and stop the timer if the animation has finished.

Protected Attributes

uint16_tmoveAnimationCounter
Counter that is equal to the current step in the animation.
uint16_tmoveAnimationDelay
The delay applied before animation start. Expressed in ticks.
uint16_tmoveAnimationDuration
The complete duration of the actual animation. Expressed in ticks.
GenericCallback< const MoveAnimator< T > & > *moveAnimationEndedCallback
Animation ended Callback.
int16_tmoveAnimationEndX
The X value at the end of the animation.
int16_tmoveAnimationEndY
The Y value at the end of the animation.
boolmoveAnimationRunning
True if the animation is running.
int16_tmoveAnimationStartX
The X value at the beginning of the animation.
int16_tmoveAnimationStartY
The Y value at the beginning of the animation.
EasingEquationmoveAnimationXEquation
EasingEquation expressing the development of the X value during the animation.
EasingEquationmoveAnimationYEquation
EasingEquation expressing the development of the Y value during the animation.

Public Functions Documentation

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.

See also:

getMoveAnimationDelay

virtual uint16_t getMoveAnimationDelay()const

Gets the current animation delay.

Returns:

The current animation delay.

See also:

handleTickEvent

virtual void handleTickEvent()

The tick handler that handles the actual animation steps.

isMoveAnimationRunning

Gets whether or not the move animation is running.

Returns:

true if the move animation is running.

MoveAnimator

setMoveAnimationDelay

virtual void setMoveAnimationDelay(uint16_tdelay)

Sets a delay on animations done by the MoveAnimator.

Parameters:
delayThe delay in ticks.
See also:

setMoveAnimationEndedAction

Associates an action to be performed when the animation ends.

Parameters:
callbackThe callback to be executed. The callback will be given a reference to the MoveAnimator.
See also:

startMoveAnimation

void startMoveAnimation(int16_tendX ,
int16_tendY ,
uint16_tduration ,
EasingEquationxProgressionEquation =&EasingEquations::linearEaseNone,
EasingEquationyProgressionEquation =&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.

Parameters:
endXThe X position at animation end.
endYThe Y position at animation end.
durationThe 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

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.