加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 20:43:00 所属栏目:百科 来源:网络整理
导读:1、CCLayerColor:继承自CCLayerRGBA和CCBlendProtocol,可能继承自CCGLBufferedNode,这些属性和方法和前面的都差不多,浏览一下就知晓 class CC_DLL CCLayerColor : public CCLayerRGBA,public CCBlendProtocol#ifdef EMSCRIPTEN,public CCGLBufferedNode#

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;
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读