29 #ifndef THOR_FRAMEANIMATION_HPP
30 #define THOR_FRAMEANIMATION_HPP
33 #include <Aurora/Tools/ForEach.hpp>
35 #include <SFML/Graphics/Rect.hpp>
49 Frame(
float duration,
const sf::IntRect& subrect)
57 Frame(
float duration,
const sf::IntRect& subrect, sf::Vector2f origin)
65 mutable float duration;
94 void addFrame(
float relativeDuration,
const sf::IntRect& subrect);
100 void addFrame(
float relativeDuration,
const sf::IntRect& subrect, sf::Vector2f origin);
107 template <
class Animated>
108 void operator() (Animated& animated,
float progress)
const;
114 void ensureNormalized()
const;
120 std::vector<detail::Frame> mFrames;
121 mutable bool mNormalized;
129 template <
class Animated>
132 assert(!mFrames.empty());
133 assert(progress >= 0.f && progress <= 1.f);
136 AURORA_FOREACH(
const detail::Frame& frame, mFrames)
138 progress -= frame.duration;
142 target.setTextureRect(frame.subrect);
143 if (frame.applyOrigin)
144 target.setOrigin(frame.origin);
153 #endif // THOR_FRAMEANIMATION_HPP
Changes a sprite's subrect over time.
Definition: FrameAnimation.hpp:82
Definition: Animator.hpp:42
Configuration header of the library.
void operator()(Animated &animated, float progress) const
Animates the object.
Definition: FrameAnimation.hpp:130