List of all members | Public Member Functions
thor::AnimationMap< Animated, Id > Class Template Reference

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...
 

Detailed Description

template<class Animated, typename Id>
class thor::AnimationMap< Animated, Id >

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, ...).

Template Parameters
IdIdentifier to distinguish animations. This type acts as key in the map and must support operator<.
AnimatedClass that is affected by animations.
Warning
Instances of this class must live as long as any Animator instance references them.

Member Function Documentation

template<class Animated, typename Id>
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.

Parameters
idValue that identifies the animation (must not be registered yet).
animationAnimation 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:
  • animated is the object being animated.
  • progress is a number in [0,1] determining the animation state.
durationDuration of the animation (> 0).

The documentation for this class was generated from the following file: