Class that stores the progress of an object's animation. More...
Public Types | |
| typedef std::function< void(Animated &, float)> | AnimationFunction |
| Functor to animate the objects. More... | |
Public Member Functions | |
| Animator () | |
| Default constructor. | |
| Animator (const Animator &origin) | |
| Copy constructor. | |
| Animator & | operator= (const Animator &origin) |
| Copy assignment operator. | |
| Animator (Animator &&source) | |
| Move constructor. | |
| Animator & | operator= (Animator &&source) |
| Move assignment operator. | |
| ~Animator () | |
| Destructor. | |
| void | addAnimation (const Id &id, const AnimationFunction &animation, sf::Time duration) |
| Registers an animation with a given name. More... | |
| void | playAnimation (const Id &id, bool loop=false) |
| Plays the animation with the given name. More... | |
| void | stopAnimation () |
| Interrupts the animation that is currently active. More... | |
| bool | isPlayingAnimation () const |
| Checks whether an animation is currently playing. More... | |
| Id | getPlayingAnimation () const |
| Returns the ID of the currently playing animation. More... | |
| void | update (sf::Time dt) |
| Updates the animator's progress. You should call this method each frame. More... | |
| void | animate (Animated &animated) const |
| Applies the stored animations to an object. More... | |
Class that stores the progress of an object's animation.
The Animator class takes care of multiple animations which are registered by a ID. The animations can be played at any time. Animator updates their progress and applies it to animated objects.
| typedef std::function<void(Animated&, float)> thor::Animator< Animated, Id >::AnimationFunction |
Functor to animate the objects.
Signature: void (Animated& animated, float progress)
| void thor::Animator< Animated, Id >::addAnimation | ( | const Id & | id, |
| const AnimationFunction & | animation, | ||
| sf::Time | duration | ||
| ) |
Registers an animation with a given name.
| id | Value that identifies the animation (must not be registered yet). |
| animation | Animation to add to the animator. The animation is copied; if you want to insert a reference instead, use the function refAnimation(). |
| duration | Duration of the animation. |
| void thor::Animator< Animated, Id >::animate | ( | Animated & | animated | ) | const |
Applies the stored animations to an object.
| animated | Object which is animated by the current animation. If no animation is active, the object is left unchanged. |
| Id thor::Animator< Animated, Id >::getPlayingAnimation | ( | ) | const |
Returns the ID of the currently playing animation.
| bool thor::Animator< Animated, Id >::isPlayingAnimation | ( | ) | const |
Checks whether an animation is currently playing.
| void thor::Animator< Animated, Id >::playAnimation | ( | const Id & | id, |
| bool | loop = false |
||
| ) |
Plays the animation with the given name.
| id | Value that identifies the animation (must already be registered). |
| loop | True if the animation is played repeatedly. |
| void thor::Animator< Animated, Id >::stopAnimation | ( | ) |
Interrupts the animation that is currently active.
The animated object remains in the state of the stopped animation. After this call, isPlayingAnimation() returns false.
| void thor::Animator< Animated, Id >::update | ( | sf::Time | dt | ) |
Updates the animator's progress. You should call this method each frame.
| dt | Frame time. |