Class that stores multiple animations. More...
Public Member Functions | |
AnimationMap () | |
Default constructor. | |
void | addAnimation (Id id, std::function< void(Animated &, float)> animation, sf::Time duration) |
Registers an animation with a given identifier. More... | |
Class that stores multiple animations.
The only purpose of this class is to define and store different animations. Each animation is identified by an ID (string, enum, ...).
Id | Identifier to distinguish animations. This type acts as key in the map and must support operator< . |
Animated | Class that is affected by animations. |
void thor::AnimationMap< Animated, Id >::addAnimation | ( | Id | id, |
std::function< void(Animated &, float)> | animation, | ||
sf::Time | duration | ||
) |
Registers an animation with a given identifier.
It is explicitly allowed to add animations while this AnimationMap is in use by Animator instances. Their playback will not be affected by doing so. Furthermore, the same animation can be added multiple times (with different durations), as long as a distinct ID is used.
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(). The signature is void(Animated& animated, float progress) , where:
|
duration | Duration of the animation (> 0). |