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

前端之家收集整理的这篇文章主要介绍了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;
};

猜你在找的Cocos2d-x相关文章