List of all members | Public Member Functions
thor::FrameAnimation Class Reference

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. More...
 
void addFrame (float relativeDuration, const sf::IntRect &subrect, sf::Vector2f origin)
 Adds a frame to the animation, changes sub-rect and sprite origin. More...
 
template<class Animated >
void operator() (Animated &animated, float progress) const
 Animates the object. More...
 

Detailed Description

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.

Member Function Documentation

void thor::FrameAnimation::addFrame ( float  relativeDuration,
const sf::IntRect &  subrect 
)

Adds a frame to the animation, changes only the sub-rect.

Parameters
relativeDurationDuration of the frame relative to the other durations.
subrectRectangle 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.

Parameters
relativeDurationDuration of the frame relative to the other durations.
subrectRectangle of the sf::Texture that is used for the new frame.
originPosition of the coordinate system origin. Is useful when frames have rectangles of different sizes.
template<class Animated >
void thor::FrameAnimation::operator() ( Animated &  animated,
float  progress 
) const

Animates the object.

Parameters
animatedObject to animate.
progressValue in [0,1] determining the progress of the animation.
Template Parameters
AnimatedClass with member functions void setTextureRect(sf::IntRect) and void setOrigin(sf::Vector2f), for example sf::Sprite.

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