Since this class just controls the logic of animations and has no image data assigned to it, you should use a more specialized class to blit animations, such as the Sprite class.
Public Member Functions | |
int | GetCurrentAnimation () |
Gets current animation being executed. | |
int | GetCurrentFrame () |
Gets current frame of animation. | |
bool | IsRunning (void) |
Tells if an animation is running. | |
void | SetAnimationMap (AnimationMap *animations) |
Assigns an animation map to this animation. | |
void | SetCurrentFrame (unsigned int frame) |
Sets frame of animation. | |
void | StartAnimation (unsigned int animation_id, bool repeating=true) |
Starts selected animation. | |
void | StopAnimation () |
Stops current animation. |
int e2d::graphics::Animation::GetCurrentAnimation | ( | ) |
int e2d::graphics::Animation::GetCurrentFrame | ( | ) |
Call this method at any moment to know what is the current frame of this animation.
bool e2d::graphics::Animation::IsRunning | ( | void | ) |
void e2d::graphics::Animation::SetAnimationMap | ( | AnimationMap * | animations | ) |
Assigns an animation map to an object of this class so it may be able to control its animations.
animations | map of animations for this class to iterate over. |
void e2d::graphics::Animation::SetCurrentFrame | ( | unsigned int | frame | ) |
You may, at any moment, set the frame you want to be recovered by Animation::GetCurrentFrame. Note that this method also stops any animation running at the moment.
frame | Index of the image representing the frame. |
void e2d::graphics::Animation::StartAnimation | ( | unsigned int | animation_id, | |
bool | repeating = true | |||
) |
Starts an animation whose id is defined as a key of the animation map assigned to this object. Right after a call to this method, the current frame is set to the first frame of the selected animation, and after the amount of time defined for that frame has elapsed, the current frame is set to the second frame of the animation, and so on until the end of the animation sequence.
If the parameter "repeating" is set to true, the current frame will return to the first frame of animation after the last frame's duration has elapsed, thus making this animation repeat forever until Animation::StopAnimation is called. Otherwise, the animation sequence shall run only once, and after it ends the current frame will stay set to the last frame of the sequence.
animation_id | Id defined for this animation | |
repeating | true if you want the animation to loop, false if you want it to run only once. |
void e2d::graphics::Animation::StopAnimation | ( | ) |
Stops the current animation from running. The current frame will stay set to the last frame before this method was called.