Gamedev Framework (gf)  0.2.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

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.

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.

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

Get the current texture.

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

Update the state of the animation.

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