21 #include "hx3d/graphics/animation.hpp" 41 _currentTime += delta;
42 if (_currentTime >= _delay) {
43 _currentTime -= _delay;
46 unsigned int framesQty = _frames.size();
47 float limit = _delay / framesQty;
48 unsigned int currentFrame = (
unsigned int)(_currentTime / limit);
49 setTexture(_atlas->getRegion(_frames[currentFrame]));
void initialize(Ptr< TextureAtlas > atlas, std::vector< std::string > frames, float speed)
Initialize an animation with an atlas, frames and a speed.
void setTexture(const Ptr< Texture > &texture)
Set the sprite texture.
void update(float delta)
Update the animation.
Animation()
Create an uninitialized animation.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.