![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
An animation. More...
#include <gf/Animation.h>
Public Member Functions | |
Animation () | |
Default constructor. More... | |
void | addFrame (const Texture &texture, const RectF &bounds, Time duration) |
Add a frame to the animation. More... | |
void | addTileset (const Texture &texture, Vector2i layout, Time duration, int frameCount, int frameOffset=0) |
Add a entire tileset to the animation. More... | |
void | setLoop (bool enabled) |
Enable or disable the animation loop. More... | |
const Texture & | getCurrentTexture () const |
Get the current texture. More... | |
RectF | getCurrentBounds () const |
Get the current texture rectangle. More... | |
bool | update (Time time) |
Update the state of the animation. More... | |
void | reset () |
Reset the animation. More... | |
bool | isFinished () const |
Tell if the animation is finished. More... | |
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.
gf::Animation::Animation | ( | ) |
Default constructor.
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.
texture | The texture where the sprite is |
bounds | The texture rectangle where the sprite is |
duration | The amount of time to display the frame |
void gf::Animation::addTileset | ( | const Texture & | texture, |
Vector2i | layout, | ||
Time | duration, | ||
int | frameCount, | ||
int | frameOffset = 0 |
||
) |
Add a entire tileset to the animation.
Take all frames of the entire tilset. Each frame is defined the texture rectangle (in texture coordinates) and an amount of time.
texture | The texture where the sprite is |
layout | Layout of frames |
duration | The amount of time to display the frame |
frameCount | Number of frames included in tileset |
frameOffset | The frame to start with |
RectF gf::Animation::getCurrentBounds | ( | ) | const |
Get the current texture rectangle.
std::runtime_error | If the animation is empty |
const Texture & gf::Animation::getCurrentTexture | ( | ) | const |
Get the current texture.
std::runtime_error | If the animation is empty |
bool gf::Animation::isFinished | ( | ) | const |
Tell if the animation is finished.
void gf::Animation::reset | ( | ) |
Reset the animation.
void gf::Animation::setLoop | ( | bool | enabled | ) |
Enable or disable the animation loop.
enabled | True to enable the loop otherwise false |
bool gf::Animation::update | ( | Time | time | ) |
Update the state of the animation.
time | The time since the last update |