Cornell Cocos
Cornell Extensions to Cocos2d
CUPolygonNode.h
1 //
2 // CCPolygonNode.h
3 // Cornell Extensions to Cocos2D
4 //
5 // This module provides a scene graph node that supports solid 2D polygons. These
6 // polygons may also be textured by a sprite. This class is preferable to Sprite
7 // except in the cases where you use Cocos2d's animation events.
8 //
9 // Author: Walker White
10 // Version: 2/21/15
11 //
12 #ifndef __CC_POLYGON_SPRITE_H__
13 #define __CC_POLYGON_SPRITE_H__
14 
15 #include <string>
16 #include "CUTexturedNode.h"
17 
18 
19 NS_CC_BEGIN
20 
21 #pragma mark -
22 #pragma mark PolygonNode
23 
60 class CC_DLL PolygonNode : public TexturedNode {
61 
62 #pragma mark Internal Helpers
63 private:
65  CC_DISALLOW_COPY_AND_ASSIGN(PolygonNode);
66 
67 protected:
74  virtual void generateRenderData() override;
75 
76 
77 public:
78 #pragma mark Static Constructors
79 
87  static PolygonNode* create();
88 
103  static PolygonNode* create(float* vertices, int size, int offset=0);
104 
115  static PolygonNode* create(const Poly2& poly);
116 
128  static PolygonNode* create(const Rect& rect);
129 
141  static PolygonNode* createWithFile(const std::string& filename);
142 
156  static PolygonNode* createWithFile(const std::string& filename, float* vertices, int size, int offset=0);
157 
167  static PolygonNode* createWithFile(const std::string& filename, const Poly2& poly);
168 
182  static PolygonNode* createWithFile(const std::string& filename, const Rect& rect);
183 
195  static PolygonNode* createWithTexture(Texture2D *texture);
196 
211  static PolygonNode* createWithTexture(Texture2D *texture, float* vertices, int size, int offset=0);
212 
223  static PolygonNode* createWithTexture(Texture2D *texture, const Poly2& poly);
224 
239  static PolygonNode* createWithTexture(Texture2D *texture, const Rect& rect);
240 
241 
242 #pragma mark Attribute Accessors
243 
250  virtual std::string getDescription() const override;
251 
252 
253 #pragma mark Rendering Methods
254 
266  virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
267 
268 
269 CC_CONSTRUCTOR_ACCESS:
270 #pragma mark Hidden Constructors
271 
280  PolygonNode(void);
281 
289  virtual ~PolygonNode(void) { }
290 
291 };
292 
293 NS_CC_END
294 
295 #endif /* defined(__CC_POLYGON_SPRITE_H__) */
Definition: CUTexturedNode.h:71
virtual void generateRenderData()
Definition: CUTexturedNode.h:146
Definition: CUPolygonNode.h:60
virtual ~PolygonNode(void)
Definition: CUPolygonNode.h:289
Definition: CUPoly2.h:53