cocos2d-x游戏开发(九)重要的基类CCNode

欢迎转载:http://blog.csdn.net/fylz1125/article/details/8522523


这个CCNode是个很重要的基类,没有理由不把它搞一搞。

首先看下类结构图:


它几乎是所有类的基类,官方注释如下:


CCNode是主要元素。任何一个能被绘制或者包含能被绘制的东西都是一个CCNode。

最常用的CCNode有:CCScene,CCLayer,CCSprite,CCMenu.

一个CCNode的主要特性包括:

1.他们能够容纳别的CCNode节点,别如能addChild, getChildByTag, removeChild 。

2.他们能定期的调度回调函数,比如能schedule,unschedule等。

3.他们能执行动作,比如runAciton,stopAction等。

一些节点能给自己或他们的子几点提供一些额外额功能。


继承一个CCNode节点通常意味着如下几条:

1.重写init()函数来初始化资源和回调

2.创建回调函数来处理时间片

3.重写draw来绘制节点

另外,一个CCNode是一个看不见对象,他没有纹理。每个节点都有一个Camera,默认指向节点的中心点。

看下这个类

  1. class CC_DLL CCNode : public CCObject  
  2. {  
  3. protected:  
  4.     // rotation angle  
  5.     float m_fRotationX, m_fRotationY;  
  6.       
  7.     // scaling factors 缩放因子  
  8.     float m_fScaleX, m_fScaleY;  
  9.       
  10.     // openGL real Z vertex  
  11.     float m_fVertexZ;  
  12.       
  13.     // position of the node  
  14.     CCPoint m_obPosition;  
  15.       
  16.     // skew angles  
  17.     float m_fSkewX, m_fSkewY;  
  18.       
  19.     // anchor point in points 锚点(points形式)  
  20.     CCPoint m_obAnchorPointInPoints;  
  21.     // anchor point normalized (NOT in points) 锚点(比例形式)  
  22.     CCPoint m_obAnchorPoint;  
  23.       
  24.     // untransformed size of the node  
  25.     CCSize m_obContentSize;  
  26.       
  27.     // transform  
  28.     CCAffineTransform m_sTransform, m_sInverse;  
  29.       
  30.     // a Camera  
  31.     CCCamera *m_pCamera;  
  32.       
  33.     // a Grid  
  34.     CCGridBase *m_pGrid;  
  35.       
  36.     // z-order value  
  37.     int m_nZOrder;  
  38.       
  39.     // array of children  
  40.     CCArray *m_pChildren;//关键数组,存子节点  
  41.       
  42.     // weak ref to parent  
  43.     CCNode *m_pParent; // 父节点  
  44.       
  45.     // a tag. any number you want to assign to the node  
  46.     int m_nTag; //tag标记  
  47.       
  48.     // user data field  
  49.     void *m_pUserData;  
  50.     CCObject *m_pUserObject;  
  51.       
  52.     // Shader  
  53.     CCGLProgram *m_pShaderProgram;// 着色器  
  54.       
  55.     // Server side state  
  56.     ccGLServerState m_eGLServerState;  
  57.       
  58.     // used to preserve sequence while sorting children with the same zOrder  
  59.     unsigned int m_uOrderOfArrival;  
  60.       
  61.     // scheduler used to schedule timers and updates  
  62.     CCScheduler *m_pScheduler; //调度器,调度定时器执行一些函数  
  63.       
  64.     // ActionManager used to handle all the actions  
  65.     CCActionManager *m_pActionManager; //动作管理器,处理所有动作  
  66.       
  67.     // Is running  
  68.     bool m_bRunning; //状态标志  
  69.       
  70.     bool m_bTransformDirty;  
  71.     bool m_bInverseDirty;  
  72.       
  73.     // is visible  
  74.     bool m_bVisible; // 是否可见  
  75.       
  76.     // If true, the Anchor Point will be (0,0) when you position the CCNode.  
  77.     // Used by CCLayer and CCScene  
  78.     bool m_bIgnoreAnchorPointForPosition;  
  79.   
  80.     bool m_bReorderChildDirty;  
  81.       
  82.     // Properties for script  
  83.       
  84.     // script handler  
  85.     int m_nScriptHandler;  
  86.     int m_nUpdateScriptHandler;  
  87.   
  88.     // script type, lua or javascript  
  89.     ccScriptType m_eScriptType;  
  90.   
  91. public:  
  92.     // getter & setter  
  93.       
  94.     /** The z order of the node relative to it's "brothers": children of the same parent */  
  95.     virtual int getZOrder(); // 取得z坐标,相对于同一父节点  
  96.     virtual void setZOrder(int nZOrder);  
  97.   
  98.     /** The real openGL Z vertex. 
  99.      Differences between openGL Z vertex and cocos2d Z order: 
  100.      - OpenGL Z modifies the Z vertex, and not the Z order in the relation between parent-children 
  101.      - OpenGL Z might require to set 2D projection 
  102.      - cocos2d Z order works OK if all the nodes uses the same openGL Z vertex. eg: vertexZ = 0 
  103.      @warning: Use it at your own risk since it might break the cocos2d parent-children z order 
  104.      @since v0.8 
  105.      */  
  106.     virtual float getVertexZ();  
  107.     virtual void setVertexZ(float fVertexZ);  
  108.   
  109.     /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the X scale factor. */  
  110.     virtual float getScaleX();  
  111.     virtual void setScaleX(float fScaleX);  
  112.   
  113.     /** The scale factor of the node. 1.0 is the default scale factor. It only modifies the Y scale factor. */  
  114.     virtual float getScaleY();  
  115.     virtual void setScaleY(float fScaleY);  
  116.   
  117.     /** Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner. */  
  118.     virtual CCPoint getPosition();  
  119.     virtual void setPosition(const CCPoint &position);  
  120.       
  121.     /** The X skew angle of the node in degrees. 
  122.      This angle describes the shear distortion in the X direction. 
  123.      Thus, it is the angle between the Y axis and the left edge of the shape 
  124.      The default skewX angle is 0. Positive values distort the node in a CW direction. 
  125.      */  
  126.     virtual float getSkewX();  
  127.     virtual void setSkewX(float fSkewX);  
  128.       
  129.     /** The Y skew angle of the node in degrees. 
  130.      This angle describes the shear distortion in the Y direction. 
  131.      Thus, it is the angle between the X axis and the bottom edge of the shape 
  132.      The default skewY angle is 0. Positive values distort the node in a CCW direction. 
  133.      */  
  134.     virtual float getSkewY();  
  135.     virtual void setSkewY(float fSkewY);  
  136.       
  137.     virtual CCArray* getChildren();  
  138.       
  139.     /** A CCCamera object that lets you move the node using a gluLookAt 
  140.      */  
  141.     virtual CCCamera* getCamera();  
  142.       
  143.     /** A CCGrid object that is used when applying effects */  
  144.     virtual CCGridBase* getGrid();  
  145.     virtual void setGrid(CCGridBase *pGrid);  
  146.       
  147.     /** A tag used to identify the node easily */  
  148.     virtual int getTag();  
  149.     virtual void setTag(int nTag);  
  150.       
  151.     /** A custom user data pointer */  
  152.     virtual void* getUserData();  
  153.     virtual void setUserData(void *pUserData);  
  154.       
  155.     /** Similar to userData, but instead of holding a void* it holds an id */  
  156.     virtual CCObject* getUserObject();  
  157.     virtual void setUserObject(CCObject *pUserObject); //retain  
  158.       
  159.     /** Shader Program 
  160.      @since v2.0 
  161.      */  
  162.     virtual CCGLProgram* getShaderProgram();  
  163.     virtual void setShaderProgram(CCGLProgram *pShaderProgram);  
  164.       
  165.     /** used internally for zOrder sorting, don't change this manually */  
  166.     virtual unsigned int getOrderOfArrival();  
  167.     virtual void setOrderOfArrival(unsigned int uOrderOfArrival);  
  168.       
  169.     /** GL server side state 
  170.      @since v2.0 
  171.      */  
  172.     virtual ccGLServerState getGLServerState();  
  173.     virtual void setGLServerState(ccGLServerState glServerState);  
  174.       
  175.     /** CCActionManager used by all the actions. 
  176.      IMPORTANT: If you set a new CCActionManager, then previously created actions are going to be removed. 
  177.      @since v2.0 
  178.      */  
  179.     virtual CCActionManager* getActionManager();  
  180.     virtual void setActionManager(CCActionManager *pActionManager);  
  181.       
  182.     /** CCScheduler used to schedule all "updates" and timers. 
  183.      IMPORTANT: If you set a new CCScheduler, then previously created timers/update are going to be removed. 
  184.      @since v2.0 
  185.      */  
  186.     virtual CCScheduler* getScheduler();  
  187.     virtual void setScheduler(CCScheduler *pScheduler);  
  188.       
  189.     /** A weak reference to the parent */  
  190.     virtual CCNode* getParent();  
  191.     virtual void setParent(CCNode *pParent);  
  192.       
  193.     /** anchorPoint is the point around which all transformations and positioning manipulations take place. 
  194.      It's like a pin in the node where it is "attached" to its parent. 
  195.      The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner. 
  196.      But you can use values higher than (1,1) and lower than (0,0) too. 
  197.      The default anchorPoint is (0.5,0.5), so it starts in the center of the node. 
  198.      @since v0.8 
  199.      */  
  200.     virtual CCPoint getAnchorPoint();  
  201.     virtual void setAnchorPoint(const CCPoint &anchorPoint);  
  202.       
  203.     /** The anchorPoint in absolute pixels. 
  204.      Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead 
  205.      */  
  206.     virtual CCPoint getAnchorPointInPoints();  
  207.       
  208.     /** The untransformed size of the node. 
  209.      The contentSize remains the same no matter the node is scaled or rotated. 
  210.      All nodes has a size. Layer and Scene has the same size of the screen. 
  211.      @since v0.8 
  212.      */  
  213.     virtual CCSize getContentSize();  
  214.     virtual void setContentSize(const CCSize &contentSize);  
  215.   
  216.     virtual bool isVisible();  
  217.     virtual void setVisible(bool visible);  
  218.       
  219.     /** Get the scale factor of the node. 
  220.      @warning: Assert when m_fScaleX != m_fScaleY. 
  221.      */  
  222.     virtual float getScale();  
  223.     /** The scale factor of the node. 1.0 is the default scale factor. It modifies the X and Y scale at the same time. */  
  224.     virtual void setScale(float scale);  
  225.       
  226.     /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. */  
  227.     virtual float getRotation();  
  228.     virtual void setRotation(float fRotation);  
  229.       
  230.     /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the X rotation performing a horizontal rotational skew . */  
  231.     virtual float getRotationX();  
  232.     virtual void setRotationX(float fRotaionX);  
  233.     /** The rotation (angle) of the node in degrees. 0 is the default rotation angle. Positive values rotate node CW. It only modifies the Y rotation performing a vertical rotational skew . */  
  234.     virtual float getRotationY();  
  235.     virtual void setRotationY(float fRotationY);  
  236.   
  237.     /** whether or not the node is running */  
  238.     virtual bool isRunning();  
  239.   
  240.     // If true, the Anchor Point will be (0,0) when you position the CCNode.  
  241.     // Used by CCLayer and CCScene  
  242.     virtual bool isIgnoreAnchorPointForPosition();  
  243.     virtual void ignoreAnchorPointForPosition(bool isIgnoreAnchorPointForPosition);  
  244.   
  245.     /** Get children count */  
  246.     unsigned int getChildrenCount(void);  
  247.       
  248.     void _setZOrder(int z);  
  249.   
  250.     /** Get script handler for onEnter/onExit event. */  
  251.     inline int getScriptHandler() { return m_nScriptHandler; };  
  252.       
  253.     /** get/set Position for Lua (pass number faster than CCPoint object) 
  254.       
  255.      lua code: 
  256.      local pos  = node:getPositionLua() -- return CCPoint object from C++ 
  257.      local x, y = node:getPosition()    -- return x, y values from C++ 
  258.      local x    = node:getPositionX() 
  259.      local y    = node:getPositionY() 
  260.      node:setPosition(x, y)             -- pass x, y values to C++ 
  261.      node:setPositionX(x) 
  262.      node:setPositionY(y) 
  263.      */  
  264.     const CCPoint& getPositionLua(void);  
  265.     void getPosition(float* x, float* y);  
  266.     float getPositionX(void);  
  267.     float getPositionY(void);  
  268.     void setPositionX(float x);  
  269.     void setPositionY(float y);  
  270.     void setPosition(float x, float y);  
  271.   
  272. public:  
  273.     CCNode(void);  
  274.   
  275.     virtual ~CCNode(void);  
  276.   
  277.     const char* description(void);  
  278.   
  279.     /** allocates and initializes a node. 
  280.      The node will be created as "autorelease". 
  281.      */  
  282.     static CCNode * create(void); // 自动释放对象构造器  
  283.   
  284.     //scene management  
  285.   
  286.     /** callback that is called every time the CCNode enters the 'stage'. 
  287.      If the CCNode enters the 'stage' with a transition, this callback is called when the transition starts. 
  288.      During onEnter you can't a "sister/brother" node. 
  289.      */  
  290.     virtual void onEnter(); //回调。如果节点进入时又过渡,那么在过渡开始时调度  
  291.   
  292.     /** callback that is called when the CCNode enters in the 'stage'. 
  293.      If the CCNode enters the 'stage' with a transition, this callback is called when the transition finishes. 
  294.      @since v0.8 
  295.      */  
  296.     virtual void onEnterTransitionDidFinish();//回调,当过渡结束时调用  
  297.   
  298.     /** callback that is called every time the CCNode leaves the 'stage'. 
  299.      If the CCNode leaves the 'stage' with a transition, this callback is called when the transition finishes. 
  300.      During onExit you can't access a sibling node. 
  301.      */  
  302.     virtual void onExit();//回调,节点离开时,如果有过渡,则在过渡结束时调用  
  303.   
  304.     /** callback that is called every time the CCNode leaves the 'stage'. 
  305.      If the CCNode leaves the 'stage' with a transition, this callback is called when the transition starts. 
  306.      */  
  307.     virtual void onExitTransitionDidStart();// 回调,离开时,在过渡开始时调用  
  308.   
  309.     /** Register onEnter/onExit handler script function 
  310.       
  311.      Script handler auto unregister after onEnter(). 
  312.      */  
  313.     virtual void registerScriptHandler(int nHandler);  
  314.     virtual void unregisterScriptHandler(void);  
  315.   
  316.     // composition: ADD  
  317.   
  318.     /** Adds a child to the container with z-order as 0. 
  319.      If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. 
  320.      @since v0.7.1 
  321.      */  
  322.     virtual void addChild(CCNode * child);//添加一个子节点,默认z坐标为0.如果一个子节点被添加到一个正在运行的节点,那么这个子节点的onEnter和onEnterTransitionDidFinish会被立即调用  
  323.   
  324.     /** Adds a child to the container with a z-order 
  325.      If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. 
  326.      @since v0.7.1 
  327.      */  
  328.     virtual void addChild(CCNode * child, int zOrder);// 添加一个子节点,设置z坐标  
  329.   
  330.     /** Adds a child to the container with z order and tag 
  331.      If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately. 
  332.      @since v0.7.1 
  333.      */  
  334.     virtual void addChild(CCNode * child, int zOrder, int tag);// 添加子节点,设置z坐标和tag标记  
  335.   
  336.     // composition: REMOVE  
  337.   
  338.     /** Remove itself from its parent node forcing a cleanup. 
  339.      If the node orphan, then nothing happens. 
  340.      @since v2.1 
  341.      */  
  342.     virtual void removeFromParent();//从父节点删除自己,如果没有父节点则什么都不干  
  343.   
  344.     /** Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks. 
  345.      If the node orphan, then nothing happens. 
  346.      @since v0.99.3 
  347.      */  
  348.     virtual void removeFromParentAndCleanup(bool cleanup);// 从父节点删除自己,如果cleanup标记为true,则删除其所有动作和回调函数  
  349.   
  350.     /** Removes a child from the container forcing a cleanup 
  351.      @since v2.1 
  352.      */  
  353.     virtual void removeChild(CCNode* child);// 删除一个子节点,强制cleanup为true  
  354.   
  355.     /** Removes a child from the container. It will also cleanup all running actions depending on the cleanup parameter. 
  356.      @since v0.7.1 
  357.      */  
  358.     virtual void removeChild(CCNode* child, bool cleanup);  
  359.   
  360.     /** Removes a child from the container by tag value forcing a cleanup. 
  361.      @since v2.1 
  362.      */  
  363.     virtual void removeChildByTag(int tag);  
  364.   
  365.     /** Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter 
  366.      @since v0.7.1 
  367.      */  
  368.     virtual void removeChildByTag(int tag, bool cleanup);  
  369.   
  370.     /** Removes all children from the container forcing a cleanup. 
  371.      @since v2.1 
  372.      */  
  373.     virtual void removeAllChildren();// 删除所有子节点及其动作和回调,即cleanup强置true  
  374.   
  375.     /** Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. 
  376.      @since v0.7.1 
  377.      */  
  378.     virtual void removeAllChildrenWithCleanup(bool cleanup);  
  379.   
  380.     // composition: GET  
  381.     /** Gets a child from the container given its tag 
  382.      @return returns a CCNode object 
  383.      @since v0.7.1 
  384.      */  
  385.     CCNode * getChildByTag(int tag);  
  386.   
  387.     /** Reorders a child according to a new z value. 
  388.      * The child MUST be already added. 
  389.      */  
  390.     virtual void reorderChild(CCNode * child, int zOrder);  
  391.   
  392.     /** performance improvement, Sort the children array once before drawing, instead of every time when a child is added or reordered 
  393.      don't call this manually unless a child added needs to be removed in the same frame */  
  394.     virtual void sortAllChildren();  
  395.   
  396.     /** Stops all running actions and schedulers 
  397.      @since v0.8 
  398.      */  
  399.     virtual void cleanup(void); // 停止所有动作和任务调度  
  400.   
  401.     // draw  
  402.   
  403.     /** Override this method to draw your own node. 
  404.      The following GL states will be enabled by default: 
  405.      - glEnableClientState(GL_VERTEX_ARRAY); 
  406.      - glEnableClientState(GL_COLOR_ARRAY); 
  407.      - glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
  408.      - glEnable(GL_TEXTURE_2D); 
  409.  
  410.      AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE 
  411.  
  412.      But if you enable any other GL state, you should disable it after drawing your node. 
  413.      */  
  414.     virtual void draw(void);//画自己  
  415.   
  416.     /** recursive method that visit its children and draw them */  
  417.     virtual void visit(void);//递归访问子节点并绘制它们  
  418.   
  419.     // transformations  
  420.     // MARMALADE ADDED THIS... SO IT IS NO LONGER SPECIFIC TO CCSprite  
  421.     /** updates the quad according the the rotation, position, scale values. */  
  422.     virtual void updateTransform(void);  
  423.   
  424.     /** performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes. */  
  425.     void transform(void);  
  426.   
  427.     /** performs OpenGL view-matrix transformation of it's ancestors. 
  428.      Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO) 
  429.      it's necessary to transform the ancestors again. 
  430.      @since v0.7.2 
  431.      */  
  432.     void transformAncestors(void);  
  433.   
  434.     /** returns a "local" axis aligned bounding box of the node. 
  435.      The returned box is relative only to its parent. 
  436.  
  437.      @since v0.8.2 
  438.      */  
  439.     CCRect boundingBox(void);//返回节点的边框矩形区域,相对于其父节点  
  440.   
  441.     // actions  
  442.   
  443.     /** Executes an action, and returns the action that is executed. 
  444.      The node becomes the action's target. 
  445.      @warning Starting from v0.8 actions don't retain their target anymore. 
  446.      @since v0.7.1 
  447.      @return An Action pointer 
  448.      */  
  449.   
  450.     CCAction* runAction(CCAction* action);// 执行一个动作。执行动作的节点将变成动作的target  
  451.   
  452.     /** Removes all actions from the running action list */  
  453.     void stopAllActions(void);  
  454.   
  455.     /** Removes an action from the running action list */  
  456.     void stopAction(CCAction* action);  
  457.   
  458.     /** Removes an action from the running action list given its tag 
  459.      @since v0.7.1 
  460.      */  
  461.     void stopActionByTag(int tag);  
  462.   
  463.     /** Gets an action from the running action list given its tag 
  464.      @since v0.7.1 
  465.      @return the Action the with the given tag 
  466.      */  
  467.     CCAction* getActionByTag(int tag);  
  468.   
  469.     /** Returns the numbers of actions that are running plus the ones that are schedule to run (actions in actionsToAdd and actions arrays). 
  470.      * Composable actions are counted as 1 action. Example: 
  471.      *    If you are running 1 Sequence of 7 actions, it will return 1. 
  472.      *    If you are running 7 Sequences of 2 actions, it will return 7. 
  473.      */  
  474.     unsigned int numberOfRunningActions(void);  
  475.   
  476.   
  477.     // timers  
  478.   
  479.     /** check whether a selector is scheduled. */  
  480.     bool isScheduled(SEL_SCHEDULE selector);//检测一个选择器是否被调用  
  481.   
  482.     /** schedules the "update" method. It will use the order number 0. This method will be called every frame. 
  483.      Scheduled methods with a lower order value will be called before the ones that have a higher order value. 
  484.      Only one "update" method could be scheduled per node. 
  485.  
  486.      @since v0.99.3 
  487.      */  
  488.     void scheduleUpdate(void);//采用0优先级调度update函数,这个函数每一帧都会被执行,优先级数字越小,权重越高,也就越优先调用。每个节点只能有一个update被调度。  
  489.   
  490.     /** schedules the "update" selector with a custom priority. This selector will be called every frame. 
  491.      Scheduled selectors with a lower priority will be called before the ones that have a higher value. 
  492.      Only one "update" selector could be scheduled per node (You can't have 2 'update' selectors). 
  493.  
  494.      @since v0.99.3 
  495.      */  
  496.     void scheduleUpdateWithPriority(int priority);// 用一个优先级调度update函数,每一帧都调用  
  497.   
  498.     /* unschedules the "update" method. 
  499.  
  500.      @since v0.99.3 
  501.      */  
  502.     void unscheduleUpdate(void);//停止调度update函数  
  503.   
  504.     /** schedules a selector. 
  505.      The scheduled selector will be ticked every frame 
  506.      */  
  507.     void schedule(SEL_SCHEDULE selector);//选择器selector每一帧都被调一次  
  508.   
  509.     /** schedules a custom selector with an interval time in seconds. 
  510.      If time is 0 it will be ticked every frame. 
  511.      If time is 0, it is recommended to use 'scheduleUpdate' instead. 
  512.      If the selector is already scheduled, then the interval parameter 
  513.      will be updated without scheduling it again. 
  514.      */  
  515.     void schedule(SEL_SCHEDULE selector, float interval);//自定义时间间隔调度选择器selector,比如每秒一次  
  516.   
  517.     /** 
  518.      repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever 
  519.      delay is the amount of time the action will wait before execution 
  520.      */  
  521.     void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay);  
  522.       
  523.     /** 
  524.      Schedules a selector that runs only once, with a delay of 0 or larger 
  525.     */  
  526.     void scheduleOnce(SEL_SCHEDULE selector, float delay);//以一个延迟时间调度回调selector,仅调用一次  
  527.   
  528.     /** unschedules a custom selector.*/  
  529.     void unschedule(SEL_SCHEDULE selector);//停止调度自定义的选择器  
  530.   
  531.     /** unschedule all scheduled selectors: custom selectors, and the 'update' selector. 
  532.      Actions are not affected by this method. 
  533.      @since v0.99.3 
  534.      */  
  535.     void unscheduleAllSelectors(void);// 停止调用所有选择器,包括自定义的和内置的update  
  536.   
  537.     /** resumes all scheduled selectors and actions. 
  538.      Called internally by onEnter 
  539.      */  
  540.     void resumeSchedulerAndActions(void);  
  541.     /** pauses all scheduled selectors and actions. 
  542.      Called internally by onExit 
  543.      */  
  544.     void pauseSchedulerAndActions(void);  
  545.       
  546.     /* Update will be called automatically every frame if "scheduleUpdate" is called, and the node is "live" 
  547.      */  
  548.     virtual void update(float fDelta);//内置的选择器,如果调用了scheduleUpdate,那么这个选择器每一帧都会被调用  
  549.   
  550.       
  551.     // transformation methods  
  552.   
  553.     /** Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates. 
  554.      The matrix is in Pixels. 
  555.      @since v0.7.1 
  556.      */  
  557.     virtual CCAffineTransform nodeToParentTransform(void);  
  558.   
  559.     /** Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates. 
  560.      The matrix is in Pixels. 
  561.      @since v0.7.1 
  562.      */  
  563.     virtual CCAffineTransform parentToNodeTransform(void);  
  564.   
  565.     /** Returns the world affine transform matrix. The matrix is in Pixels. 
  566.      @since v0.7.1 
  567.      */  
  568.     virtual CCAffineTransform nodeToWorldTransform(void);  
  569.   
  570.     /** Returns the inverse world affine transform matrix. The matrix is in Pixels. 
  571.      @since v0.7.1 
  572.      */  
  573.     virtual CCAffineTransform worldToNodeTransform(void);  
  574.   
  575.     /** Converts a Point to node (local) space coordinates. The result is in Points. 
  576.      @since v0.7.1 
  577.      */  
  578.     CCPoint convertToNodeSpace(const CCPoint& worldPoint);//将世界坐标系的点转换为节点的本地坐标系的点  
  579.     /** Converts a Point to world space coordinates. The result is in Points. 
  580.      @since v0.7.1 
  581.      */  
  582.     CCPoint convertToWorldSpace(const CCPoint& nodePoint);//将节点的本地坐标系的点转换为世界坐标系的点  
  583.     /** Converts a Point to node (local) space coordinates. The result is in Points. 
  584.      treating the returned/received node point as anchor relative. 
  585.      @since v0.7.1 
  586.      */  
  587.     CCPoint convertToNodeSpaceAR(const CCPoint& worldPoint);//将世界坐标系的点转换为基于锚点的节点本地坐标系的点  
  588.     /** Converts a local Point to world space coordinates.The result is in Points. 
  589.      treating the returned/received node point as anchor relative. 
  590.      @since v0.7.1 
  591.      */  
  592.     CCPoint convertToWorldSpaceAR(const CCPoint& nodePoint);// 将基于锚点的节点的本地坐标系的点转换为世界坐标系的点  
  593.   
  594.     /** convenience methods which take a CCTouch instead of CCPoint 
  595.      @since v0.7.1 
  596.      */  
  597.     CCPoint convertTouchToNodeSpace(CCTouch * touch);//将一个屏幕坐标系的touch转换为节点的本地坐标系的点  
  598.   
  599.     /** converts a CCTouch (world coordinates) into a local coordinate. This method is AR (Anchor Relative). 
  600.      @since v0.7.1 
  601.      */  
  602.     CCPoint convertTouchToNodeSpaceAR(CCTouch * touch);  
  603.           
  604.     /** Schedules for script. */  
  605.     void scheduleUpdateWithPriorityLua(int nHandler, int priority);  

其中有有些较重要的成员变量和函数,做了注释,后面陆续写写。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值