GAF Library
Generic Animation Format
 All Classes Functions Pages
GAFSprite.h
1 #pragma once
2 
3 #ifndef __GAF_SPRITE__
4 #define __GAF_SPRITE__
5 
6 typedef struct _gafBlendFuncSeparate
7 {
8  // source blend function
9  GLenum src;
10  // destination blend function
11  GLenum dst;
12  // source alpha channel blend function
13  GLenum srcAlpha;
14  // destination alpha channel blend function
15  GLenum dstAlpha;
16 
18 
22 
23 class GAFSprite : public cocos2d::Sprite
24 {
25 protected:
26  cocos2d::AffineTransform m_externalTransform;
27  cocos2d::AffineTransform m_childTransform;
28  void invalidateTransformCache();
29 private:
30  gafBlendFuncSeparate m_blendFuncSeparate;
31  bool m_useSeparateBlendFunc;
32  bool m_isLocator;
33  GLint m_blendEquation;
34  float m_atlasScale;
35 
36  cocos2d::QuadCommand m_quadCommand;
37  cocos2d::V3F_C4B_T2F_Quad m_quad;
38 public:
39  GAFSprite();
40  void setExternaTransform(const cocos2d::AffineTransform& transform);
41  void setChildTransform(const cocos2d::AffineTransform& transform);
42 
43  unsigned int objectIdRef;
44 
45  virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, bool transformUpdated) override;
46  virtual void setUniformsForFragmentShader();
47 
48  inline const cocos2d::AffineTransform &childTransform() const
49  {
50  return m_childTransform;
51  }
52  const cocos2d::AffineTransform& getExternalTransform() const
53  {
54  return m_externalTransform;
55  }
56  inline void setLocator(bool locator)
57  {
58  m_isLocator = locator;
59  }
60  void setAtlasScale(float scale);
61 
62  virtual const cocos2d::Mat4& getNodeToParentTransform() const override;
63  cocos2d::AffineTransform getNodeToParentAffineTransform() const;
64 
65  void setTexture(cocos2d::Texture2D *texture);
66  bool initWithTexture(cocos2d::Texture2D *pTexture, const cocos2d::Rect& rect, bool rotated);
67 
68  virtual bool initWithSpriteFrame(cocos2d::SpriteFrame *spriteFrame);
69 };
70 
71 
72 #endif // __GAF_SPRITE__
Definition: GAFSprite.h:23
Definition: GAFSprite.h:6