hx3d  1
2D/3D Simple Game Framework
animation.hpp
1 /*
2  Animated sprite.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_ANIMATION
22 #define HX3D_GRAPHICS_ANIMATION
23 
24 #include "hx3d/graphics/sprite.hpp"
25 #include "hx3d/graphics/texture_atlas.hpp"
26 
27 namespace hx3d {
28 namespace graphics {
29 
33 class Animation: public Sprite {
34 public:
35 
41  Animation();
42 
50  Animation(Ptr<TextureAtlas> atlas, std::vector<std::string> frames, float speed);
51 
59  void initialize(Ptr<TextureAtlas> atlas, std::vector<std::string> frames, float speed);
60 
66  void update(float delta);
67 
68 private:
69  Ptr<TextureAtlas> _atlas;
70  std::vector<std::string> _frames;
71 
72  float _currentTime;
73  float _delay;
74 };
75 
76 } /* graphics */
77 } /* hx3d */
78 
79 #endif /* HX3D_GRAPHICS_ANIMATION */
void initialize(Ptr< TextureAtlas > atlas, std::vector< std::string > frames, float speed)
Initialize an animation with an atlas, frames and a speed.
Definition: animation.cpp:31
hx3d framework namespace
Definition: audio.hpp:26
void update(float delta)
Update the animation.
Definition: animation.cpp:40
Animation()
Create an uninitialized animation.
Definition: animation.cpp:26
Animated texture-atlas based sprite.
Definition: animation.hpp:33
2D texture manipulation.
Definition: sprite.hpp:62
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34