CCNode类

     // 初始化节点对象
    virtual bool init();
     // 分配内存并初始化节点对象
    static CCNode * create(void);
    // 节点描述
    const char* description(void);   
     // 设置z-order,只影响节点绘制顺序,与OpenGL的z值无关
    virtual void setZOrder(int zOrder);
    // 获取节点的z-order值
    virtual int getZOrder();
    // 设置节点OpenGL的z值
    virtual void setVertexZ(float vertexZ);
     // 获取节点的OpenGL的坐标z值
    virtual float getVertexZ();
     // 设置x放缩系数
    virtual void setScaleX(float fScaleX);
     // 获取节点的放缩系数
    virtual float getScaleX();
     // 设置y值放缩系数
    virtual void setScaleY(float fScaleY);
     // 设置y放缩系数
    virtual float getScaleY();
     // 设置节点放缩比例,同时影响x,y值
    virtual void setScale(float scale);
	// 获取节点放缩比例,同时影响x,y值
    virtual float getScale();
     // 设置节点放缩比例,同时影响x,y值
    virtual void setScale(float fScaleX,float fScaleY);

     // 设置节点的位置,在OpenGL坐标系中
    virtual void setPosition(const CCPoint &position);
    virtual void setPosition(float x, float y);
     // 获取节点在OpenGL坐标系下节点坐标值
    virtual const CCPoint& getPosition();
    virtual void getPosition(float* x, float* y);
     // 设置单个坐标x,y值
    virtual void  setPositionX(float x);
    virtual float getPositionX(void);
    virtual void  setPositionY(float y);
    virtual float getPositionY(void);

     // 设置x的扭曲角度,获取x的扭曲角度
    virtual void setSkewX(float fSkewX);
    virtual float getSkewX();
     // 设置x的扭曲角度,获取x的扭曲角度
    virtual void setSkewY(float fSkewY);
    virtual float getSkewY();
    // 设置锚点位置,获取锚点位置
    virtual void setAnchorPoint(const CCPoint& anchorPoint);
    virtual const CCPoint& getAnchorPoint();
     // 在绝对像素下,获取锚点位置,
    virtual const CCPoint& getAnchorPointInPoints();
     // 设置节点的大小,获取节点大小(都是未变化前的大小)
    virtual void setContentSize(const CCSize& contentSize);
    virtual const CCSize& getContentSize() const;

     // 设置节点可见性,询问节点可见性
    virtual void setVisible(bool visible);
    virtual bool isVisible();
     // 设置节点旋转的角度,获取节点的旋转角度
    virtual void setRotation(float fRotation);
    virtual float getRotation();

     // 设置及获取旋转角度单个值x,y
    virtual void setRotationX(float fRotaionX);
    virtual float getRotationX();
    virtual void setRotationY(float fRotationY);
    virtual float getRotationY();

     // 设置、获取节点的到达顺序,只有在z-order相同的情况下,才比较他,而且拥有较大值uOrderOfArrival得戒掉后被绘制
    virtual void setOrderOfArrival(unsigned int uOrderOfArrival);
    virtual unsigned int getOrderOfArrival();
    
     // 设置、获取OpenGL环境的服务状态
    virtual void setGLServerState(ccGLServerState glServerState);
    virtual ccGLServerState getGLServerState();
    
     // 设置、获取忽略锚点与否
    virtual void ignoreAnchorPointForPosition(bool ignore);
    virtual bool isIgnoreAnchorPointForPosition();

     // 向该节点添加子节点
    virtual void addChild(CCNode * child);
     // 向该节点添加子节点,并指定z-order值
    virtual void addChild(CCNode * child, int zOrder);
   	// 添加子节点,指定zorder值,并打上标记tag
    virtual void addChild(CCNode* child, int zOrder, int tag);
     // 根据tag标记获取节点对象
    CCNode * getChildByTag(int tag);
     // 获取所有的子节点对象
    virtual CCArray* getChildren();
     // 获取子节点数目
    unsigned int getChildrenCount(void) const;
     // 设置、获取父节点
    virtual void setParent(CCNode* parent);
    virtual CCNode* getParent();
    
     // 从父节点移除该节点和与节点绑定的动作
    virtual void removeFromParent();
    virtual void removeFromParentAndCleanup(bool cleanup);
     // 移除该节点指定的子节点和子节点对应的动作序列
    virtual void removeChild(CCNode* child);
    virtual void removeChild(CCNode* child, bool cleanup);
     // 通过tag值移除指定的额子节点和对应的动作序列
    virtual void removeChildByTag(int tag);
    virtual void removeChildByTag(int tag, bool cleanup);
    // 移除所有的子节点并清空动作序列
    virtual void removeAllChildren();
    virtual void removeAllChildrenWithCleanup(bool cleanup);
    
     // 重新定义节点的zorder值
    virtual void reorderChild(CCNode * child, int zOrder);
     // 在绘制节点前对所有的子节点进行排序
    virtual void sortAllChildren();

     // 返回、设置一个grid对象,用于演示各种效果时
    virtual CCGridBase* getGrid();
    virtual void setGrid(CCGridBase *pGrid);

    // 获取、设置节点标记
    virtual int getTag() const;
    virtual void setTag(int nTag);
    
     // 获取、设置用户数据指针
    virtual void* getUserData();
    virtual void setUserData(void *pUserData);
    
     // 返回、设置一个赋值的CCObject对象
    virtual CCObject* getUserObject();
    virtual void setUserObject(CCObject *pUserObject);

     // 返回、设置该节点的shader
    virtual CCGLProgram* getShaderProgram();
    virtual void setShaderProgram(CCGLProgram *pShaderProgram);

     // 获取该节点的摄像机,CCCamera object that lets you move the node using a gluLookAt
    virtual CCCamera* getCamera();

     // 查询该节点是否接受回调函数,如onEnter(), onExit(), update()
    virtual bool isRunning();

     // 注册脚本函数的handler,以便在onEnter() & onExit()调用
    virtual void registerScriptHandler(int handler);
     // 销毁注册的脚本函数
    virtual void unregisterScriptHandler(void);
     // 获取脚本入口的handler
    inline int getScriptHandler() { return m_nScriptHandler; };

     // 用来供lua脚本调用
    void scheduleUpdateWithPriorityLua(int nHandler, int priority);

     // 当节点进入舞台后每帧都会调用,在该节点执行各种变化时,重写该方法时要调用父节点的该方法
    virtual void onEnter();
     // 当节点执行完各种动作变化后,执行该回调函数
    virtual void onEnterTransitionDidFinish();
     // 节点离开舞台后,执行该函数
    virtual void onExit();

     // 在节点退出舞台时,这里的变化动作执行之前
    virtual void onExitTransitionDidStart();
     // 停止所有动作和调度函数
    virtual void cleanup(void);

     // 重写该方法来绘制你自己的节点对象
    virtual void draw(void);

     // 访问该节点的子节点并递归绘制他们
    virtual void visit(void);

     // 返回该节点的绑定盒子,该盒子相对于父节点的
    CCRect boundingBox(void);

     // 设置、获取该节点的动作管理器用于所有的动作序列
    virtual void setActionManager(CCActionManager* actionManager);
    virtual CCActionManager* getActionManager();

     // 执行该节点绑定的动作序列,并返回该动作序列
    CCAction* runAction(CCAction* action);

     // 停止所有的节点对象,并移除所有的动作序列
    void stopAllActions(void);

     // 停止某个动作序列并移除之
    void stopAction(CCAction* action);

     // 根据给定的tag移除动作序列
    void stopActionByTag(int tag);

     // 根据给定的tag获取指定的动作序列
    CCAction* getActionByTag(int tag);

     // 返回该节点运行的动作序列的数目,
    // If you are running 1 Sequence of 7 actions, it will return 1.If you are running 7 Sequences of 2 actions, it will return 7.
    unsigned int numberOfRunningActions(void);

     // 设置、获取该节点的调度对象用来调度所有的"updates" and timers
    virtual void setScheduler(CCScheduler* scheduler);
    virtual CCScheduler* getScheduler();

     // 查询一个调度对象是否正在被调度
    bool isScheduled(SEL_SCHEDULE selector);

     // 定时调度update方法,每帧都会调用,拥有较小order值的会先于较大的调用
    void scheduleUpdate(void);

     // 定时刷新调度update方法,根据优先级调度
    void scheduleUpdateWithPriority(int priority);

     // 停止调度update方法
    void unscheduleUpdate(void);

     // 调度一个自定义的函数,函数-间隔时间-次数-等待时间
    void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay);
    void schedule(SEL_SCHEDULE selector, float interval);
    // 延迟时间调度
    void scheduleOnce(SEL_SCHEDULE selector, float delay);
    // 每帧调度
    void schedule(SEL_SCHEDULE selector);
    // 停止自定义的调度
    void unschedule(SEL_SCHEDULE selector);
    // 关闭所有的调度函数
    void unscheduleAllSelectors(void);

     // 重新开启所有的调度函数和动作序列onEnter
    void resumeSchedulerAndActions(void);

     // 暂停调度和所有的动作序列onExit
    void pauseSchedulerAndActions(void);

     // 每帧调度该函数,如果节点存在的话
    virtual void update(float delta);

     // 执行OpenGL的视图矩阵变换
    void transform(void);

     // 视图变换,包括父母的
    void transformAncestors(void);

     // 调用子节点的变换
    virtual void updateTransform(void);

     // 返回矩阵,从子节点坐标系到父节点坐标系转换的矩阵
    virtual CCAffineTransform nodeToParentTransform(void);

     // 从父节点坐标系转换到子节点坐标系的转换矩阵
    virtual CCAffineTransform parentToNodeTransform(void);

     // 到世界矩阵的变换矩阵
    virtual CCAffineTransform nodeToWorldTransform(void);

     // 返回到世界矩阵的变换矩阵的逆矩阵
    virtual CCAffineTransform worldToNodeTransform(void);

     // 转换到本地坐标系
    CCPoint convertToNodeSpace(const CCPoint& worldPoint);

     // 转换到世界坐标系
    CCPoint convertToWorldSpace(const CCPoint& nodePoint);

     // 转换点到本地坐标系中,返回值与锚点相关的
    CCPoint convertToNodeSpaceAR(const CCPoint& worldPoint);

     // 转换本地坐标系的节点的位置到世界坐标系中,与锚点相关的
    CCPoint convertToWorldSpaceAR(const CCPoint& nodePoint);

     // 讲触摸对象转换为本地坐标系
    CCPoint convertTouchToNodeSpace(CCTouch * touch);

     // 转换触摸对象到本地坐标系中,与锚点相关的
    CCPoint convertTouchToNodeSpaceAR(CCTouch * touch);
    
     // 设置附加的矩阵变化,常用来摸底父子节点的关系,获取精灵a的变化,并应用于精灵b上,精灵b位置依赖于a的父节点
    void setAdditionalTransform(const CCAffineTransform& additionalTransform);

     // 通过名字获取分量
    CCComponent* getComponent(const char *pName) const;

     // 添加一个分量
    virtual bool addComponent(CCComponent *pComponent);

     // 移除一个分量
    virtual bool removeComponent(const char *pName);

     // 移除所有的分量
    virtual void removeAllComponents();

// 属性:
    float m_fRotationX;                 ///< rotation angle on x-axis
    float m_fRotationY;                 ///< rotation angle on y-axis
    
    float m_fScaleX;                    ///< scaling factor on x-axis
    float m_fScaleY;                    ///< scaling factor on y-axis
    
    float m_fVertexZ;                   ///< OpenGL real Z vertex
    
    CCPoint m_obPosition;               ///< position of the node
    
    float m_fSkewX;                     ///< skew angle on x-axis
    float m_fSkewY;                     ///< skew angle on y-axis
    
    CCPoint m_obAnchorPointInPoints;    ///< anchor point in points
    CCPoint m_obAnchorPoint;            ///< anchor point normalized (NOT in points)
    
    CCSize m_obContentSize;             ///< untransformed size of the node
    
    CCAffineTransform m_sAdditionalTransform; ///< transform
    CCAffineTransform m_sTransform;     ///< transform
    CCAffineTransform m_sInverse;       ///< transform
    
    CCCamera *m_pCamera;                ///< a camera
    
    CCGridBase *m_pGrid;                ///< a grid
    
    int m_nZOrder;                      ///< z-order value that affects the draw order
    
    CCArray *m_pChildren;               ///< array of children nodes
    CCNode *m_pParent;                  ///< weak reference to parent node
    
    int m_nTag;                         ///< a tag. Can be any number you assigned just to identify this node
    
    void *m_pUserData;                  ///< A user assingned void pointer, Can be point to any cpp object
    CCObject *m_pUserObject;            ///< A user assigned CCObject
    
    CCGLProgram *m_pShaderProgram;      ///< OpenGL shader
    
    ccGLServerState m_eGLServerState;   ///< OpenGL servier side state
    
    unsigned int m_uOrderOfArrival;     ///< used to preserve sequence while sorting children with the same zOrder
    
    CCScheduler *m_pScheduler;          ///< scheduler used to schedule timers and updates
    
    CCActionManager *m_pActionManager;  ///< a pointer to ActionManager singleton, which is used to handle all the actions
    
    bool m_bRunning;                    ///< is running
    
    bool m_bTransformDirty;             ///< transform dirty flag
    bool m_bInverseDirty;               ///< transform dirty flag
    bool m_bAdditionalTransformDirty;   ///< The flag to check whether the additional transform is dirty
    bool m_bVisible;                    ///< is this node visible
    
    bool m_bIgnoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the CCNode, false otherwise.
                                          ///< Used by CCLayer and CCScene.
    
    bool m_bReorderChildDirty;          ///< children order dirty flag
    
    int m_nScriptHandler;               ///< script handler for onEnter() & onExit(), used in Javascript binding and Lua binding.
    int m_nUpdateScriptHandler;         ///< script handler for update() callback per frame, which is invoked from lua & javascript.
    ccScriptType m_eScriptType;         ///< type of script binding, lua or javascript
    
    CCComponentContainer *m_pComponentContainer;        ///< Dictionary of components

};

class CC_DLL CCNodeRGBA : public CCNode, public CCRGBAProtocol
{
public:

    CCNodeRGBA();
    virtual ~CCNodeRGBA();
    virtual bool init();

     // 分配内存并初始化节点对象
    static CCNodeRGBA * create(void);
    // 透明度相关
    virtual GLubyte getOpacity();
    virtual GLubyte getDisplayedOpacity();
    virtual void setOpacity(GLubyte opacity);
    virtual void updateDisplayedOpacity(GLubyte parentOpacity);
    virtual bool isCascadeOpacityEnabled();
    virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
    // 颜色相关的
    virtual const ccColor3B& getColor(void);
    virtual const ccColor3B& getDisplayedColor();
    virtual void setColor(const ccColor3B& color);
    virtual void updateDisplayedColor(const ccColor3B& parentColor);
    virtual bool isCascadeColorEnabled();
    virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
    
    virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);};
    virtual bool isOpacityModifyRGB() { return false; };
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值