Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了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结构学习(十六)CCLayerColor、CCProgressTimer、CCProgressTo、CCSet全部内容,希望文章能够帮你解决Cocos2d-x结构学习(十六)CCLayerColor、CCProgressTimer、CCProgressTo、CCSet所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。