节点解释: 节点是场景图的基本元素。场景图的基本元素必须是节点对象或者是节点对象的子类。
其中主要可以看到Layer、MenuItem、Scene、Sprite、TMXTiledMap(解析and渲染TMX地图)、ParticleSystem(粒子系统基类)等等
Node是这些类的根类
节点的基本操作
- 创建节点
Node* childNode = Node::Create();
- 增加新的子节点
node->addChild(childNode,z深度,tag);
- 查找子节点
Node* node=node->getChildByTag(tag)
- node->removeChildTag(tag,true)删除子节点,并停止所有该节点上的一切动作
- node->removeChild(childNode)通过Node指针删除节点
- node->removeAllChildrenWithCleanup(true)删除所有子节点,并停止这些子节点上的一切动作
- node->removeFromParentAndCleanup(true) 从父Node中删除节点,并停止所有该节点上的一切动作
Node的重要属性
- anchorPoint锚点
锚点指定了贴图上和所在节点原点(也就是设置位置的点)
锚点的默认值是(0.5,0.5),表示的并不是一个像素点,而是一个乘数因子。(0.5,0.5)表示锚点位于贴图长度乘以0.5和宽度乘以0.5的地方,即贴图的中心。
改变锚点的值虽然可能看起来节点的图像位置发生了改变,但其实并不会改变节点的位置,其实变化的只是贴图相对于你设置的位置的相对位置,相当于你在移动节点里面的贴图,而非节点本身。
position=(5,5),anchorPoin=(0.5,0.5)
position=(5,5),anchorPoin=(0,0)

position=(5,5),anchorPoin=(0.66,0.5)

cocos2d-x 3.0 Node与Node层级结构,布布扣,bubuko.com
cocos2d-x 3.0 Node与Node层级结构
原文:http://www.cnblogs.com/zsboy/p/3926323.html