29 #ifndef THOR_ANIMATOR_HPP
30 #define THOR_ANIMATOR_HPP
34 #include <SFML/System/Time.hpp>
51 template <
class Animated,
typename Id>
96 void addAnimation(
const Id&
id,
const AnimationFunction& animation, sf::Time duration);
125 void animate(Animated& animated)
const;
131 typedef std::pair<AnimationFunction, sf::Time> ScaledAnimation;
132 typedef std::map<Id, ScaledAnimation> AnimationMap;
133 typedef typename AnimationMap::iterator AnimationMapIterator;
139 void playAnimation(AnimationMapIterator animation,
bool loop);
141 template <
typename T>
142 void adopt(T& source);
148 AnimationMap mAnimationMap;
149 AnimationMapIterator mPlayingAnimation;
158 #include <Thor/Animations/Detail/Animator.inl>
159 #endif // THOR_ANIMATOR_HPP
void addAnimation(const Id &id, const AnimationFunction &animation, sf::Time duration)
Registers an animation with a given name.
Definition: Animator.hpp:42
void playAnimation(const Id &id, bool loop=false)
Plays the animation with the given name.
Class that stores the progress of an object's animation.
Definition: Animator.hpp:52
Configuration header of the library.
std::function< void(Animated &, float)> AnimationFunction
Functor to animate the objects.
Definition: Animator.hpp:61
bool isPlayingAnimation() const
Checks whether an animation is currently playing.
void animate(Animated &animated) const
Applies the stored animations to an object.
void update(sf::Time dt)
Updates the animator's progress. You should call this method each frame.
Animator()
Default constructor.
Animator & operator=(const Animator &origin)
Copy assignment operator.
Id getPlayingAnimation() const
Returns the ID of the currently playing animation.
void stopAnimation()
Interrupts the animation that is currently active.