CCLayer相关资料

来源:互联网 发布:淘宝图片跳转链接代码 编辑:程序博客网 时间:2024/06/04 20:13

cocos2d-x给CCLayer的子类提供了2个宏,这两个宏用来生成CCLayer的node方法

#define LAYER_NODE_FUNC(layer) 这个宏生成的node方法是不带参数的,需要子类有一个没有参数的init()方法

#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) 这个宏生成的node方法带参数,需要子类有一个带相同参数的init方法

class BackgroundLayer:public CCLayer{public:    LAYER_NODE_FUNC(BackgroundLayer);    LAYER_NODE_FUNC_PARAM(BackgroundLayer, CCString*, id);    virtual bool init();    virtual bool init(CCString* id);};

使用:

backgroundLayer = BackgroundLayer::node();this->addChild(backgroundLayer);    backgroundLayer = BackgroundLayer::node(m_scnID);this->addChild(backgroundLayer);





原创粉丝点击