UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
spriteanimationframe.h
Go to the documentation of this file.
1 #ifndef UGDK_ACTION_SPRITEANIMATIONFRAME_H_
2 #define UGDK_ACTION_SPRITEANIMATIONFRAME_H_
3 
4 #include <ugdk/math/geometry.h>
6 
7 #include <string>
8 
9 #define DEFAULT_PERIOD 0.1
10 
11 namespace ugdk {
12 namespace action {
13 
14 /*
15  * Represents the visual behavior information of a sprite in a single game frame.
16  */
18  /*
19  * frame_: the index of the spritesheet frame that should be rendered.
20  * geometry_: a pointer to the Geometry object describing the visual modifiers that
21  * should be applied to the rendered sprite.
22  */
23  public:
25  : atlas_frame_name_(atlas_frame_name)
26  , mirror_(0)
27  , period_(DEFAULT_PERIOD)
28  {}
29 
30  const std::string& atlas_frame_name() const { return atlas_frame_name_; }
31  const math::Geometry& geometry() const { return geometry_; }
32  const structure::VisualEffect& effect() const { return effect_; }
33  ugdk::Mirror mirror() const { return mirror_; }
34  double fps() const { return 1.0/period_; }
35  double period() const { return period_; }
36 
37  void set_atlas_frame_name(const std::string& name) { atlas_frame_name_ = name; }
38  math::Geometry& geometry() { return geometry_; }
39  structure::VisualEffect& effect() { return effect_; }
40  void set_mirror(const ugdk::Mirror& _mirror) { mirror_ = _mirror; }
41  void set_fps(double _fps) { period_ = 1.0/_fps; }
42  void set_period(double _period) { period_ = _period; }
43 
44  static const SpriteAnimationFrame& DEFAULT() {
45  static SpriteAnimationFrame default_frame("default");
46  return default_frame;
47  }
48 
49  private:
50  std::string atlas_frame_name_;
51  math::Geometry geometry_;
53  ugdk::Mirror mirror_;
54  double period_;
55 };
56 
57 } // namespace action
58 } // namespace ugdk
59 
60 #endif // UGDK_GRAPHIC_SPRITEANIMATIONFRAME_H_
61 
62 
static const SpriteAnimationFrame & DEFAULT()
Definition: spriteanimationframe.h:44
SpriteAnimationFrame(const std::string &atlas_frame_name)
Definition: spriteanimationframe.h:24
Definition: animation.h:11
Definition: visualeffect.h:9
#define DEFAULT_PERIOD
Definition: spriteanimationframe.h:9
void set_period(double _period)
Definition: spriteanimationframe.h:42
double fps() const
Definition: spriteanimationframe.h:34
uint8 Mirror
Definition: types.h:21
const std::string & atlas_frame_name() const
Definition: spriteanimationframe.h:30
void set_fps(double _fps)
Definition: spriteanimationframe.h:41
Definition: geometry.h:15
ugdk::Mirror mirror() const
Definition: spriteanimationframe.h:33
const math::Geometry & geometry() const
Definition: spriteanimationframe.h:31
double period() const
Definition: spriteanimationframe.h:35
Definition: spriteanimationframe.h:17
structure::VisualEffect & effect()
Definition: spriteanimationframe.h:39
void set_atlas_frame_name(const std::string &name)
Definition: spriteanimationframe.h:37
math::Geometry & geometry()
Definition: spriteanimationframe.h:38
const structure::VisualEffect & effect() const
Definition: spriteanimationframe.h:32
void set_mirror(const ugdk::Mirror &_mirror)
Definition: spriteanimationframe.h:40