Game Develop C++ Platform: Sprite.h Source File

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Sprite.h
Go to the documentation of this file.
1
6 #ifndef SPRITE_H
7 #define SPRITE_H
8 #include <string>
9 #include <boost/shared_ptr.hpp>
10 #include <SFML/Graphics.hpp>
11 #include "GDCpp/Point.h"
12 #include "GDCpp/Polygon.h"
13 class SFMLTextureWrapper;
14 #undef LoadImage //prevent windows.h to be polluting everything
15
25 class GD_API Sprite
26 {
27 public:
28 Sprite();
29 virtual ~Sprite();
30
34 inline const sf::Sprite & GetSFMLSprite() const { return sfmlSprite; }
35
39 inline sf::Sprite & GetSFMLSprite() { return sfmlSprite; }
40
44 void LoadImage(boost::shared_ptr<SFMLTextureWrapper> image);
45
49 boost::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() { return sfmlImage; };
50
54 const boost::shared_ptr<SFMLTextureWrapper> GetSFMLTexture() const { return sfmlImage; };
55
59 inline void SetImageName(const std::string & image_) { image = image_; }
60
64 inline const std::string & GetImageName() const { return image; }
65
69 inline std::string & GetImageName() { return image; }
70
77 std::vector<Polygon2d> GetCollisionMask() const;
78
83 void SetCustomCollisionMask(const std::vector<Polygon2d> & collisionMask) {customCollisionMask = collisionMask;};
84
88 inline bool IsCollisionMaskAutomatic() const { return automaticCollisionMask; }
89
93 inline void SetCollisionMaskAutomatic(bool enabled) { automaticCollisionMask = enabled; };
94
98 inline std::vector < Point > & GetAllNonDefaultPoints() { return points; }
99
103 inline const std::vector < Point > & GetAllNonDefaultPoints() const { return points; }
104
108 void AddPoint( const Point & point );
109
113 void DelPoint( const std::string & name );
114
118 const Point & GetPoint( const std::string & name) const;
119
123 Point & GetPoint(const std::string & name);
124
128 bool HasPoint( const std::string & name ) const;
129
133 inline const Point & GetOrigine() const { return origine; }
134
138 inline Point & GetOrigine() { return origine; }
139
146 inline const Point & GetCentre() const { return centre; }
147
154 inline Point & GetCentre() { automaticCentre = false; return centre; }
155
159 inline bool IsCentreAutomatic() const { return automaticCentre; }
160
164 bool SetCentreAutomatic(bool enabled);
165
170 void MakeSpriteOwnsItsImage();
171
172 private:
173
174 sf::Sprite sfmlSprite;
175 boost::shared_ptr<SFMLTextureWrapper> sfmlImage;
176 bool hasItsOwnImage;
177 std::string image;
178
179 bool automaticCollisionMask;
180 std::vector<Polygon2d> customCollisionMask;
181
182 std::vector < Point > points;
183 Point origine;
184 Point centre;
185 bool automaticCentre;
186
187 static Point badPoint;
188 };
189
190 #endif // SPRITE_H
191