![]() |
Changes a sprite's subrect over time. More...
Public Member Functions | |
FrameAnimation () | |
Default constructor. | |
void | addFrame (float relativeDuration, const sf::IntRect &subrect) |
Adds a frame to the animation, changes only the sub-rect. | |
void | addFrame (float relativeDuration, const sf::IntRect &subrect, sf::Vector2f origin) |
Adds a frame to the animation, changes sub-rect and sprite origin. | |
template<class Animated > | |
void | operator() (Animated &animated, float progress) const |
Animates the object. |
Changes a sprite's subrect over time.
This class stores multiple frames that represent the sub-rectangle of a texture. The resulting animation consists of a sequence of frames that are drawn one after another.
void thor::FrameAnimation::addFrame | ( | float | relativeDuration, |
const sf::IntRect & | subrect | ||
) |
Adds a frame to the animation, changes only the sub-rect.
relativeDuration | Duration of the frame relative to the other durations. |
subrect | Rectangle of the sf::Texture that is used for the new frame. |
void thor::FrameAnimation::addFrame | ( | float | relativeDuration, |
const sf::IntRect & | subrect, | ||
sf::Vector2f | origin | ||
) |
Adds a frame to the animation, changes sub-rect and sprite origin.
relativeDuration | Duration of the frame relative to the other durations. |
subrect | Rectangle of the sf::Texture that is used for the new frame. |
origin | Position of the coordinate system origin. Is useful when frames have rectangles of different sizes. |
void thor::FrameAnimation::operator() | ( | Animated & | animated, |
float | progress | ||
) | const |
Animates the object.
animated | Object to animate. |
progress | Value in [0,1] determining the progress of the animation. |
Animated | Class with member functions void setTextureRect(sf::IntRect) and void setOrigin(sf::Vector2f), for example sf::Sprite. |