Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Classes | Public Member Functions | List of all members
gf::Animation Class Reference

An animation. More...

#include <gf/Animation.h>

Public Member Functions

 Animation ()
 Default constructor. More...
 
void addFrame (const Texture &texture, const RectF &bounds, float duration)
 Add a frame to the animation. More...
 
const TexturegetCurrentTexture () const
 Get the current texture. More...
 
RectF getCurrentBounds () const
 Get the current texture rectangle. More...
 
bool update (float dt)
 Update the state of the animation. More...
 

Detailed Description

An animation.

An animation is a collection of frames that are displayed consecutively during a predefined amount of time.

To display an animation, you need a gf::AnimatedSprite.

See also
gf::AnimatedSprite

Constructor & Destructor Documentation

gf::Animation::Animation ( )

Default constructor.

Member Function Documentation

void gf::Animation::addFrame ( const Texture texture,
const RectF bounds,
float  duration 
)

Add a frame to the animation.

The frame of an animation is defined by the texture of the frame, the texture rectangle (in texture coordinates) and an amount of time.

Parameters
textureThe texture where the sprite is
boundsThe texture rectangle where the sprite is
durationThe amount of time to display the frame
RectF gf::Animation::getCurrentBounds ( ) const

Get the current texture rectangle.

Returns
The current texture rectangle
const Texture* gf::Animation::getCurrentTexture ( ) const

Get the current texture.

Returns
The current texture or nullptr if the animation is empty
bool gf::Animation::update ( float  dt)

Update the state of the animation.

Parameters
dtThe time (in seconds) since the last update
Returns
True if the current frame has changed