Oxygine  1
2g game engine
Sprite.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "core/Texture.h"
4 #include "math/Rect.h"
5 #include "res/ResAnim.h"
6 #include "Actor.h"
7 #include "AnimationFrame.h"
8 #include "VisualStyle.h"
9 #include "TweenAnim.h"
10 
11 namespace oxygine
12 {
13  DECLARE_SMART(Sprite, spSprite);
14  class Sprite : public VStyleActor
15  {
16  INHERITED(VStyleActor);
17  public:
18  DECLARE_COPYCLONE_NEW(Sprite);
19 
20  Sprite();
21  ~Sprite();
22 
23  const AnimationFrame& getAnimFrame() const {return _frame;}
24  RectF getDestRect() const override;
25  const Diffuse& getDiffuse() const {return _frame.getDiffuse();}
26  bool getManageResAnim() const {return (_flags & flag_manageResAnim) != 0;}
27  const RectF& getSrcRect() const {return _frame.getSrcRect();}
28  const ResAnim* getResAnim() const {return _frame.getResAnim();}
29  int getColumn() const {return _frame.getColumn();}
30  int getRow() const {return _frame.getRow();}
31  const Vector2& getLocalScale() const { return _localScale; }
32 
34  void setManageResAnim(bool manage);
36  void setAnimFrame(const AnimationFrame& f);
38  void setAnimFrame(const ResAnim* resanim, int col = 0, int row = 0);
39  virtual void setResAnim(const ResAnim* resanim, int col = 0, int row = 0);
40  void setRow(int row);
41  void setColumn(int column);
42  void setColumnRow(int column, int row);
43  void setLocalScale(const Vector2& s);
44 
45  bool isOn(const Vector2& localPosition, float localScale) override;
46 
47  bool isFlippedX() const {return (_flags & flag_flipX) != 0;}
48  bool isFlippedY() const {return (_flags & flag_flipY) != 0;}
49  void setFlippedX(bool flippedX);
50  void setFlippedY(bool flippedY);
51  void setFlipped(bool flippedX, bool flippedY);
52 
53  void serialize(serializedata* data) override;
54  void deserialize(const deserializedata* data) override;
55 
57  std::string dump(const dumpOptions&) const override;
58 
59  void doRender(const RenderState&) override;
60  protected:
61  enum
62  {
63  flag_manageResAnim = flag_last << 1,
64  flag_flipX = flag_last << 2,
65  flag_flipY = flag_last << 3
66  };
67  virtual void changeAnimFrame(const AnimationFrame& f);
68  virtual void animFrameChanged(const AnimationFrame& f);
69  void sizeChanged(const Vector2& size) override;
70 
71  Vector2 _localScale;
72  AnimationFrame _frame;
73  };
74 }
75 
76 EDITOR_INCLUDE(Sprite);
Definition: Serialize.h:28
Definition: Sprite.h:14
Definition: RenderState.h:27
Definition: AnimationFrame.h:28
Definition: Serialize.h:21
–oxgl-end–!
Definition: Actor.h:14
bool isOn(const Vector2 &localPosition, float localScale) override
Definition: VisualStyle.h:29
void setAnimFrame(const AnimationFrame &f)
Definition: ResAnim.h:13
Definition: TweenAnim.h:13
std::string dump(const dumpOptions &) const override
Definition: AnimationFrame.h:9
void setManageResAnim(bool manage)