Used to create animations programatically.
This class can be used to create an animation programatically. The animation can be played and notify listeners when it has completed.
Animations are composed of zero or more animations in a list. Each animation contains information on its own execution over time, such as the duration, and current state.
To create a new animation, classes should extend CYIAnimation::Listener, implement OnAnimate, and set this new class as a listener to a CYIAnimation instance. For instance:
#include <animation/YiAnimation.h>

Classes | |
| class | Listener |
| Base class used to listen to one or more CYIAnimations as they update over time. More... | |
Public Types | |
| enum | REPEAT_MODE { REPEAT_RESTART = 0, REPEAT_REVERSE } |
| enum | STATUS { STATUS_NOT_STARTED = 0, STATUS_RUNNING, STATUS_PAUSED, STATUS_ENDED } |
| enum | DIRECTION { DIRECTION_FORWARD = 0, DIRECTION_REVERSE } |
Static Public Attributes | |
| static const uint64_t | ANIMATION_TIME_UNDEFINED |
| static const uint64_t | ANIMATION_REPEAT_COUNT_INFINITE |
| enum CYIAnimation::STATUS |
| CYIAnimation::CYIAnimation | ( | ) |
|
virtual |
| void CYIAnimation::AddListener | ( | CYIAnimation::Listener * | pListener | ) |
Adds a listener for the callbacks : OnAnimate(), OnAnimationBegin() and OnAnimationEnd().
| void CYIAnimation::ChangeDirection | ( | ) |
Reverse the current direction the animation is playing.
| CYIAnimation::DIRECTION CYIAnimation::GetDirection | ( | ) | const |
Returns the current animation direction.
| uint64_t CYIAnimation::GetDuration | ( | ) | const |
Returns the current animation duration (in milliseconds).
| uint64_t CYIAnimation::GetLastDeltaTime | ( | ) | const |
Returns the last saved delta time (in milliseconds).
| CYIAnimation* CYIAnimation::GetNext | ( | ) | const |
Returns the next animation in the list.
| CYIAnimation* CYIAnimation::GetPrevious | ( | ) | const |
Returns the previous animation in the list.
| CYIAnimation::STATUS CYIAnimation::GetStatus | ( | ) | const |
Returns the status of the animation.
| CYITimeInterpolator* CYIAnimation::GetTimeInterpolator | ( | ) | const |
Returns the current animation interpolation function.
| void* CYIAnimation::GetUserData | ( | ) | const |
Returns the user data set previously. Useful for the listeners.
| void CYIAnimation::InsertInList | ( | CYIAnimation ** | ppFirstAnimation | ) |
Inserts this animation at the beginning of the chained list whose first element pointer is provided.
| void CYIAnimation::Pause | ( | ) |
Pauses the current animation. The animation can be restarted by calling Start().
| void CYIAnimation::RemoveFromList | ( | CYIAnimation ** | ppFirstAnimation | ) |
Removes this animation from the chained list whose first element pointer is provided The animation must already be part of that list. If it is not, or is part of another list, the consequences are unpredictable.
| void CYIAnimation::RemoveListener | ( | CYIAnimation::Listener * | pListener | ) |
Removes the specified listener in the list.
| void CYIAnimation::Reset | ( | ) |
Resets the animation status and start time. The animation won't automatically restart until Start() or SetStartTime() is called
| void CYIAnimation::ScaleDuration | ( | uint64_t | uNewSimpleDur | ) |
Assigns new duration and scales the animation accordingly. Re-assigns the animation duration to the new duration. The current animation position remains unchanged, relatively to the duration (if the current position was at 30% of the previous duration, it will still be at 30% of the new duration.)
No effect if the current repeatCount is ANIMATION_REPEAT_COUNT_INFINITE No effect if the current animation status is CYIAnimation::STATUS_ENDED
| void CYIAnimation::SetDirection | ( | CYIAnimation::DIRECTION | direction | ) |
Changes the animation to the specified direction.
| void CYIAnimation::SetDuration | ( | uint64_t | uDur | ) |
Sets the animation's duration. Setting to ANIMATION_TIME_UNDEFINED causes the animation to run forever but but not advance in data position Must be called before animation starts, has no effect otherwise.
| void CYIAnimation::SetNext | ( | CYIAnimation * | pAnimation | ) |
Set the next animation in the chained list.
| void CYIAnimation::SetPrevious | ( | CYIAnimation * | pAnimation | ) |
Set the previous animation in the chained list.
| void CYIAnimation::SetRepeatCount | ( | uint64_t | uRepeatCount | ) |
Sets the number of times the animation should play.
Default is 1.
When called with 0, the repeatCount is set to 1 instead.
Set to ANIMATION_REPEAT_COUNT_INFINITE for an indefinitely repeating animation. The animation's total active time is (repeatCount * duration).
It has no effect if the animation is running or paused.
| void CYIAnimation::SetRepeatMode | ( | CYIAnimation::REPEAT_MODE | eRepeatMode | ) |
Sets the behaviour of the animation when it repeats. Has no effect if the animation is running or paused.
| void CYIAnimation::SetStartTime | ( | uint64_t | uStartTime | ) |
Sets the start time for the animation.
If there was already a valid start time (Start() or SetStartTime() previously called), this function has no effect. Call Reset() first if you want to specify a new start time.
| void CYIAnimation::SetTimeInterpolator | ( | CYITimeInterpolator * | pTimeInterpolator | ) |
Specify the time interpolator function The Default value is CYIInterpolateLinear.
| void CYIAnimation::SetUserData | ( | void * | pPrivData | ) |
Set the user data. User data will be passed through the listeners' callback functions.
| void CYIAnimation::Start | ( | ) |
Starts or restarts the animation immediately. If the animation is paused, it is resumed. If the animation is ended or already running, the function has no effect (call Reset() first) If a previous start time had been provided (but animation had not started yet), that start time is discarded.
| void CYIAnimation::Terminate | ( | ) |
Terminates the animation by advancing to its end time, thus triggering a call to OnAnimationEnd() and leaving it in CYIAnimation::STATUS_ENDED state.
If the animation repeat count is ANIMATION_REPEAT_COUNT_INFINITE, OnAnimationEnd() is not called but the status becomes CYIAnimation::STATUS_ENDED.
If the animation is paused when this function is called, it is restarted, then advanced to its end as described above.
|
static |
|
static |