文章引用自http://blog.csdn.net/qiurisuixiang/article/details/8763260
1 CCNode是cocos2d-x中一个非常重要的类。CCNode是场景、层、菜单、精灵等的父类。而我们在使用cocos2d-x时。接触最多的就是场景、层、菜单、精灵等。所以有必要先弄懂CCNode类
2 CCObject类是cocos2d-x中全部对象的基类,CCObject封装了对象的引用计数和自己主动释放功能,以下是类图
3 由于场景、层、精灵、菜菜单是CCNode的子类,所以在使用它们时,有些方法来自CCNode。以下解释了CCNode中经常使用的方法
-
- bool init();
-
-
- CCNode * create(void);
-
-
- const char* description(void);
-
-
- void setZOrder(int zOrder);
- void _setZOrder(int z);
-
- int getZOrder();
-
-
- void setVertexZ(float vertexZ);
-
- float getVertexZ();
-
-
- void setScaleX(float fScaleX);
-
- float getScaleX();
-
-
- void setScaleY(float fScaleY);
-
- float getScaleY();
-
-
- void setScale(float scale);
-
- float getScale();
-
-
- void setPosition(const CCPoint &position);
-
- const CCPoint& getPosition();
-
-
- void setPosition(float x, float y);
-
- void getPosition(float* x, float* y);
-
-
- void setPositionX(float x);
-
- float getPositionX(void);
-
- void setPositionY(float y);
-
- float getPositionY(void);
-
-
- void setSkewX(float fSkewX);
-
- float getSkewX();
-
-
- void setSkewY(float fSkewY);
-
- float getSkewY();
-
-
- void setAnchorPoint(const CCPoint& anchorPoint);
-
- const CCPoint& getAnchorPoint();
-
-
- void setContentSize(const CCSize& contentSize);
-
- const CCSize& getContentSize();
-
-
- void setVisible(bool visible);
-
- bool isVisible();
-
-
- void setRotation(float fRotation);
-
- float getRotation();
-
-
-
- void addChild(CCNode * child);
-
- void addChild(CCNode * child, int zOrder);
-
- void addChild(CCNode* child, int zOrder, int tag);
-
-
- CCNode * getChildByTag(int tag);
-
- CCArray* getChildren();
-
- unsigned int getChildrenCount(void);
-
-
- void setParent(CCNode* parent);
-
- CCNode* getParent();
-
-
- void removeFromParent();
-
- void removeFromParentAndCleanup(bool cleanup);
-
- void removeChild(CCNode* child);
-
- void removeChild(CCNode* child, bool cleanup);
-
- void removeChildByTag(int tag);
-
- void removeChildByTag(int tag, bool cleanup);
-
- void removeAllChildren();
-
- void removeAllChildrenWithCleanup(bool cleanup);
-
-
- void reorderChild(CCNode * child, int zOrder);
-
-
- void sortAllChildren();
-
-
- int getTag();
-
- void setTag(int nTag);
-
-
- CCCamera* getCamera();
-
-
- bool isRunning();
-
-
- void onEnter();
-
- void onEnterTransitionDidFinish();
-
- void onExit();
-
-
- void cleanup(void);
-
-
- void draw(void);
-
-
- void visit(void);
-
-
- CCRect boundingBox(void);
-
-
- void setActionManager(CCActionManager* actionManager);
-
- CCActionManager* getActionManager();
-
-
- CCAction* runAction(CCAction* action);
-
- stopAction(CCAction* action);
-
-
-
- void stopAllActions(void);
-
-
- CCAction* getActionByTag(int tag);
-
-
- unsigned int numberOfRunningActions(void);
-
-
- void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay);
-
- void schedule(SEL_SCHEDULE selector, float interval);
-
-
- void unschedule(SEL_SCHEDULE selector);
-
- void unscheduleAllSelectors(void);
-
-
- void pauseSchedulerAndActions(void);
-
- void resumeSchedulerAndActions(void);
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5093037.html,如需转载请自行联系原作者