Cocos2d-x结构学习十六CCLayerColor、CCProgressTimer、CCProgressTo、CCSet

1、cclayerColor:继承自cclayerRGBA和CCBlendProtocol,可能继承自CCGLBufferednode,这些属性方法和前面的都差不多,浏览一下就知晓

class CC_DLL cclayerColor : public cclayerRGBA,public CCBlendProtocol
#ifdef EMSCRIPTEN,public CCGLBufferednode
#endif
{
protected:
    ccVertex2F m_pSquareVertices[4];
    ccColor4F  m_pSquareColors[4];

public:
    cclayerColor();
    virtual ~cclayerColor();

    virtual void draw();
    virtual void setContentSize(const CCSize & var);
    
    static cclayerColor* create();
    static cclayerColor * create(const ccColor4B& color,GLfloat width,GLfloat height);
    static cclayerColor * create(const ccColor4B& color);

    virtual bool init();
    virtual bool initWithColor(const ccColor4B& color,GLfloat height);
    virtual bool initWithColor(const ccColor4B& color);

    void changeWidth(GLfloat w);
    void changeHeight(GLfloat h);
    void changeWidthAndHeight(GLfloat w,GLfloat h);

    CC_PROPERTY(ccBlendFunc,m_tBlendFunc,BlendFunc)
    virtual void setColor(const ccColor3B &color);
    virtual void setopacity(glubyte opacity);
protected:
    virtual void updateColor();
};
2、CCProgresstimer:时间进度类,继承自CCNodeRGBA,可能继承自CCGLBufferednode
class CC_DLL CCProgresstimer : public CCNodeRGBA
#ifdef EMSCRIPTEN,public CCGLBufferednode
#endif
{
public:
    CCProgresstimer();
    ~CCProgresstimer(void);

    inline CCProgresstimerType getType(void) { return m_eType; }   //获得类型

    inline float getPercentage(void) {return m_fPercentage; }     //获得百分比

    inline CCSprite* getSprite(void) { return m_pSprite; }

    bool initWithSprite(CCSprite* sp);

    void setPercentage(float fPercentage);    //几个设置函数
    void setSprite(CCSprite *pSprite);
    void setType(CCProgresstimerType type);

    void setReverseProgress(bool reverse);

    virtual void draw(void);
    void setAnchorPoint(CCPoint anchorPoint);

    virtual void setColor(const ccColor3B& color);
    virtual const ccColor3B& getColor() const;
    virtual glubyte getopacity() const;
    virtual void setopacity(glubyte opacity);
    
    inline bool isReverseDirection() { return m_bReverseDirection; };
    inline void setReverseDirection(bool value) { m_bReverseDirection = value; };

public:
    static CCProgresstimer* create(CCSprite* sp);
protected:
    ccTex2F textureCoordFromAlphaPoint(CCPoint alpha);
    ccVertex2F vertexFromAlphaPoint(CCPoint alpha);
    void updateProgress(void);
    void updateBar(void);
    void updateradial(void);
    void updateColor(void);
    CCPoint boundaryTexCoord(char index);

protected:
    CCProgresstimerType m_eType;
    float m_fPercentage;
    CCSprite *m_pSprite;
    int m_nVertexDataCount;
    ccV2F_C4B_T2F *m_pVertexData;

    CC_PROPERTY(CCPoint,m_tMidpoint,Midpoint);
    CC_SYNTHESIZE(CCPoint,m_tBarChangeRate,BarChangeRate);

    bool m_bReverseDirection;
};
3、CCProgressto:继承自CCActionInterval
class CC_DLL CCProgressto : public CCActionInterval
{
public:
    bool initWithDuration(float duration,float fPercent);

    virtual CCObject* copyWithZone(CCZone *pZone);
    virtual void startWithTarget(CCNode *pTarget);
    virtual void update(float time);

public:
    static CCProgressto* create(float duration,float fPercent);
protected:
    float m_fTo;
    float m_fFrom;
};
4、CCSet:集合类,继承自CCObject
class CC_DLL CCSet : public CCObject
{
public:
    CCSet(void);
    CCSet(const CCSet &rSetobject);
    virtual ~CCSet(void);

    static CCSet * create();
    CCSet* copy();
    CCSet* mutablecopy();
   
    int count();                //返回集合里有多少个元素
 
    void addobject(CCObject *pObject);              //添加和移除
    void removeObject(CCObject *pObject);
    void removeAllObjects();
  
    bool containsObject(CCObject *pObject);
    CCSetIterator begin();
    CCSetIterator end();
    CCObject* anyObject();
    virtual void acceptVisitor(CCDataVisitor &visitor);
private:
    std::set<CCObject *> *m_pSet;
};

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...