UGDK  0.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sprite.h
Go to the documentation of this file.
1 #ifndef HORUSEYE_FRAMEWORK_SPRITE_H_
2 #define HORUSEYE_FRAMEWORK_SPRITE_H_
3 
4 #include <ugdk/math/vector2D.h>
5 #include <ugdk/graphic.h>
8 
9 namespace ugdk {
10 namespace graphic {
11 
12 class Sprite : public Drawable {
13  public:
14  Sprite(const Spritesheet *spritesheet, action::AnimationSet *set = NULL);
15  explicit Sprite(const std::string& spritesheet_tag, action::AnimationSet *set = NULL);
16  explicit Sprite(const std::string& spritesheet_tag, const std::string& animation_set_tag);
17  explicit Sprite(const Spritesheet *spritesheet, const std::string& animation_set_tag);
18  virtual ~Sprite();
19 
20  void Update(double dt);
21  void Draw() const;
22  const Vector2D& size() const;
23 
25 
26  void SelectAnimation(const std::string& animation_name) {
27  animation_manager_->Select(animation_name);
28  }
30 
31  void SelectAnimation(int animation_index) {
32  animation_manager_->Select(animation_index);
33  }
34 
36 
39  void SetAnimationSpeedupFactor(double factor) { animation_manager_->set_speedup_factor(factor); }
40 
42 
45  void SetAnimationSlowdownFactor(double factor) { animation_manager_->set_slowdown_factor(factor); }
46 
48 
51  double GetAnimationFPS() const { return animation_manager_->fps(); }
52 
54 
58  animation_manager_->AddObserver(observer);
59  }
60 
61  void AddTickFunctionToAnimation(std::tr1::function<void (void)> tick) {
62  animation_manager_->AddTickFunction(tick);
63  }
64 
66 
68  int GetAnimationFrameNumber() const { return animation_manager_->n_frames(); }
69 
71 
73  void SetDefaultFrame(int frame) {
74  animation_manager_->set_default_frame(frame);
75  }
76 
77 
78  private:
79  const Spritesheet *spritesheet_;
80  action::AnimationManager *animation_manager_;
81 
83 
85 };
86 
87 } // namespace graphic
88 } // namespace ugdk
89 
90 #endif //HORUSEYE_FRAMEWORK_SPRITE_H_