Properties
active Boolean
The local active state of this node.
节点本地活动状态。
activeInHierarchy Boolean
Indicates whether this node is active in the scene.
表明该节点是否在场景中活跃。
name String
Name of node
节点名称。
parent Node
The parent of the node.
节点的父亲。
uuid String
The uuid for editor, will be stripped before building project.
编辑器uuid,在建立工程之前将被去除。
skewX Number
Skew x
X轴倾斜度。
skewY Number
Skew y
Y轴倾斜度。
zIndex Number
Z order in depth which stands for the drawing order.
绘图命令深度Z轴顺序。
rotation Number
Rotation of node
节点旋转角度。
rotationX Number
Rotation on x axis
X轴旋转角度。
scaleX Number
Scale on x axis
X轴放大比例。
scaleY Number
Scale on y axis
Y轴放大比例。
x Number
x axis position of node.
节点X轴位置。
y Number
y axis position of node.
节点Y轴位置。
children Node[]
All children nodes
所有孩子节点。
childrenCount Number
All children nodes.
孩子节点个数。
anchorX Number
Anchor point's position on x axis.
X轴锚点位置。
anchorY Number
Anchor point's position on y axis.
Y轴锚点位置。
width Number
Width of node.
节点宽度。
height Number
Height of node.
节点高度。
ignoreAnchor Boolean
Indicate whether ignore the anchor point property for positioning.
指示节点是否忽略定位的锚点属性。
tag Number
Tag of node.
节点标识。
opacity Number
Opacity of node, default value is 255.
节点不透明度,默认为255。
cascadeOpacity Boolean
Indicate whether node's opacity value affect its child nodes, default value is false.
显示节点的不透明度值是否影响其孩子节点,默认值是不影响。
color Color
Color of node, default value is white: (255, 255, 255).
节点颜色,默认为白色。
position Vec2
position of node.
节点位置。
scale Number
Scale of node
节点放大比例。
Methods
on ( type, callback, [target ] ) Function
Register an callback of a specific event type on Node. Use this method to register touch or mouse event permit propagation based on scene graph, you can propagate the event to the parents or swallow it by calling stopPropagation on the event. It's the recommended way to register touch/mouse event for Node, please do not use cc.eventManager directly for Node.
为节点注册一个特定事件类型的回调。使用此方法注册允许在基于场景中传播的触摸或鼠标事件,可以传播事件给父节点或通过调用stopPropagation()吞噬事件。为节点注册触摸/鼠标事件,推荐使用这种方式。请不要直接使用cc.eventManager节点
runAction ( action ) cc.Action
Executes an action, and returns the action that is executed.
执行一个动作,并返回所执行的动作。
The node becomes the action's target. Refer to cc.Action's getTarget() Calling runAction while the node is not active won't have any effect。
节点成为行动的目标。指cc.Action.getTarget()获得的目标,,调用runAction的非活跃节点不会受任何影响。(翻译不怎么准确)
stopAllActions ( )
Stops and removes all actions from the running action list .
将运行动作列表中的所有运动停止并删除。
stopAction ( action )
Stops and removes an action from the running action list.
将运行动作列表中的`action`运动停止并删除。
stopActionByTag ( tag )
Removes an action from the running action list by its tag.
将运行动作列表中的标识为`tag`的运动删除。
getActionByTag ( tag ) cc.Action
Returns an action from the running action list by its tag.
返回运行动作列表中的标识为`tag`的运动。
getNumberOfRunningActions ( ) Number
Composable actions are counted as 1 action. Example:
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.
组合动作算作一个动作。例:
如果您正在运行包含7个运动的1个组合运动,它将返回1。 如果您正在运行包含2个运动的7个组合运动,它将返回7。
attr ( attrs )
Properties configuration function
All properties in attrs will be set to the node,
when the setter of the node is available,
the property will be set via setter function.
属性配置功能函数.
所有属性在attrs将被设置为节点, 当节点的setter是可用的, 属性将通过setter函数。
setGlobalZOrder ( globalZOrder )
Defines the order in which the nodes are renderer.
Nodes that have a Global Z Order lower, are renderer first.
定义节点的渲染器顺序。
节点有一个较低的全局Z轴顺序,渲染器优先。
In case two or more nodes have the same Global Z Order, the order is not guaranteed.
如果两个或两个以上的节点有相同的全局Z轴顺序,顺序是没有保证的。
The only exception if the Nodes have a Global Z Order == 0. In that case, the Scene Graph order is used.
节点的全局Z轴顺序==0是唯一的例外情况。在这种情况下,使用场景图的顺序渲染。
By default, all nodes have a Global Z Order = 0. That means that by default, the Scene Graph order is used to render the nodes.
默认情况下,所有节点全局Z==0。这意味着在默认情况下,是按照场景图的顺序来渲染节点。
Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
当你需要渲染的节点不同于场景图的顺序,全局Z是非常有用的。
Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their ancestors.
限制:如果某个节点的祖先是SpriteBatchNode,全局Z不能使用。
And if ClippingNode is one of the ancestors, then "global Z order" will be relative to the ClippingNode.
如果ClippingNode是祖先,那么“全局Z”将会相对于ClippingNode.
getGlobalZOrder ( ) Number
Return the Node's Global Z Order.
返回节点的全局Z。
getScale ( ) Number
Returns the scale factor of the node. Assertion will fail when _scaleX != _scaleY.
返回节点的放大比例因子。_scaleX != _scaleY,断言失败。
setScale ( scale, [scaleY =scale] )
Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time.
设置节点的放大比例因子。默认是1.0。这个函数可以在同一时间修改X和Y。
getPosition ( ) Vec2
Returns a copy of the position (x,y) of the node in cocos2d coordinates. (0,0) is the left-bottom corner.
返回cocos2d坐标系中,节点位置的拷贝。(0,0)为左下角。
setPosition ( newPosOrxValue, [yValue ] )
Changes the position (x,y) of the node in cocos2d coordinates.
在cocos2d坐标中改变位置。
The original point (0,0) is at the left-bottom corner of screen.
原点(0,0)是屏幕左下角。
Usually we use cc.p(x,y) to compose CCPoint object.
通常我们使用cc.p(x,y)组成CCPoint对象。
and Passing two numbers (x,y) is more efficient than passing CCPoint object.
传递两个数字(x,y)比CCPoint对象更高效。
getAnchorPoint ( ) Vec2
Returns a copy of the anchor point.
返回一个锚点的拷贝。
Anchor point is the point around which all transformations and positioning manipulations take place.
锚点是所有转换和定位的关键点.
It's like a pin in the node where it is "attached" to its parent.
它像是一个节点上的引脚,依附在它的父节点上。
The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
锚点的规范化像是一个百分比。(0,0)是左下角,(1,1)是右上角。
But you can use values higher than (1,1) and lower than (0,0) too.
但是你可以使用高于(1,1)和低于(0,0)的值。
The default anchor point is (0.5,0.5), so it starts at the center of the node.
默认锚点是(0.5,0.5),即节点的中心。
setAnchorPoint ( point, [y ] )
Sets the anchor point in percent.
设置锚点的百分比.
getAnchorPointInPoints ( ) Vec2
Returns a copy of the anchor point in absolute pixels.
返回一个绝对像素的锚点的拷贝。
you can only read it. If you wish to modify it, use setAnchorPoint
你只能读它。如果你想修改它,用setanchorpoint.
getContentSize ( [ignoreSizeProvider =false] ) Size
Returns a copy the untransformed size of the node.
The contentSize remains the same no matter the node is scaled or rotated.
返回一个节点的正常大小.
无论节点是缩放还是旋转,contentSize都保持不变.
All nodes has a size. Layer and Scene has the same size of the screen by default.
所有节点都有一个大小。层和场景默认为屏幕的大小。
setContentSize ( size, [height ] )
Sets the untransformed size of the node.
设置节点的未转化的大小。
getBoundingBox ( ) Rect
Returns a "local" axis aligned bounding box of the node.
返回节点的“本地”轴对齐的边界框。
The returned box is relative only to its parent.
返回的包围盒是相对其父的。
cleanup ( )
Stops all running actions and schedulers.
停止所有正在运动的动作和选择器。
getChildByTag ( tag ) Node
Returns a child from the container given its tag.
从容器中返回一个给定标记的孩子节点。
getChildByName ( name ) Node
Returns a child from the container given its name
从容器中返回一个给定名字的孩子节点。
addChild ( child, [localZOrder ], [tag ] )
If the child is added to a 'running' node, then 'onEnter' and 'onEnterTransitionDidFinish' will be called immediately.
如果孩子被添加到'运行'节点,然后'onenter'和' onentertransitiondidfinish'会被立刻调用。
localZOrder: Z order for drawing priority. Please refer to setZOrder(int)
Z轴顺序绘制优先级。请参阅setzorder(int)
tag: An integer or a name to identify the node easily. Please refer to setTag(int) and setName(string)
标签:一个整数或一个名称,以方便识别节点。请参阅setTag(int)和setName(string).
removeFromParent ( [cleanup =true] )
Remove itself from its parent node. If cleanup is true, then also remove all actions and callbacks.
从它的父节点中删除它。如果cleanup==true,也会删除所有的行动和回调。
If the cleanup parameter is not passed, it will force a cleanup.
如果cleanup参数未通过,将强制清理。
If the node orphan, then nothing happens.
如果节点独立,则什么也没有发生。
removeChild ( child, [cleanup =true] )
If the cleanup parameter is not passed, it will force a cleanup.
如果清除参数未通过,将强制清理。
"remove" logic MUST only be on this method.
'remove'逻辑只能是这个方法.
If a class wants to extend the 'removeChild' behavior it only needs to override this method
如果一个类需要延长的removechild行为只需要重写这个方法.
removeChildByTag ( tag, [cleanup =true] )
Removes a child from the container by tag value. It will also cleanup all running actions depending on the cleanup parameter. If the cleanup parameter is not passed, it will force a cleanup.
从容器中移除一个标记为`tag`的孩子。它也将清理所有运行的行动,这取决于清理参数。如果清除参数未通过,将强制清理。
removeAllChildren ( [cleanup =true] )
Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
If the cleanup parameter is not passed, it will force a cleanup.
从容器中移除所有的孩子。它也将清理所有运行的行动,这取决于清理参数。如果清除参数未通过,将强制清理
Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
返回父节点的空间坐标到节点(本地)空间坐标的矩阵.
The matrix is in Pixels. The returned transform is readonly and cannot be changed.
矩阵是以像素为单位。返回的变换是只读的,不能被改变。
Returns the world affine transform matrix. The matrix is in Pixels.
返回世界仿射变换矩阵。矩阵是以像素为单位。
Returns the inverse world affine transform matrix. The matrix is in Pixels.
返回逆世界的仿射变换矩阵。矩阵是以像素为单位。
convertToNodeSpace ( worldPoint ) Vec2
Converts a Point to node (local) space coordinates. The result is in Points.
转换点到节点(本地)空间坐标。结果是Vec2。
convertToWorldSpace ( nodePoint ) Vec2
Converts a Point to world space coordinates. The result is in Points.
转换点到世界空间坐标。结果是Vec2。
convertToNodeSpaceAR ( worldPoint ) Vec2
Converts a Point to node (local) space coordinates. The result is in Points.
转换点到节点(本地)空间坐标。结果是Vec2。
treating the returned/received node point as anchor relative.
相对于锚点处理返回/接收的节点。
convertToWorldSpaceAR ( nodePoint ) Vec2
Converts a local Point to world space coordinates.The result is in Points.
转换点到节点世界空间坐标。结果是Vec2。
treating the returned/received node point as anchor relative.
相对于锚点处理返回/接收的节点
convertTouchToNodeSpace ( touch ) Vec2
convenience methods which take a cc.Touch instead of cc.Vec2
cc.Touch转化为cc.Touch的简便方法.
convertTouchToNodeSpaceAR ( touch ) Vec2
converts a cc.Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
将一个坐标转换为一个局部坐标。此方法相对于锚点。
Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
The matrix is in Pixels.
返回将节点(本地)空间坐标转换为父亲空间坐标的矩阵。
矩阵是以像素为单位。
getBoundingBoxToWorld ( ) Rect
Returns a "world" axis aligned bounding box of the node.
返回一个'世界'轴对齐的边界框的节点。
getDisplayedOpacity ( ) Number
Returns the displayed opacity of Node, the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled.
返回节点的显示不透明度。显示不透明度和不透明度的区别是,当级联不透明启用时,显示不透明度的基于不透明度和父节点的不透明度来计算的。
_updateDisplayedOpacity( parentOpacity )
Update displayed opacity
更新显示不透明度。
getDisplayedColor ( ) Color
Returns the displayed color of Node, the difference between displayed color and color is that displayed color is calculated based on color and parent node's color when cascade color enabled.
返回节点的显示颜色,显示颜色和颜色之间的区别是,当级联颜色启用时,显示颜色是基于颜色和父节点的颜色来计算的。
setOpacityModifyRGB ( opacityValue )
Set whether color should be changed with the opacity value, useless in ccsg.Node, but this function is override in some class to have such behavior.
设置是否颜色应与不透明度值改变而改变,在ccsg.Node中无用。但是在某些类中会重载这个函数来实现这个行为。
isOpacityModifyRGB ( ) Boolean
Get whether color should be changed with the opacity value
获取颜色是否应与不透明度值改变.
getSiblingIndex ( ) Number
Get the sibling index.
获得同级索引。
setSiblingIndex ( index )
Set the sibling index of this node.
设置此节点的同级索引。
isChildOf ( parent ) Boolean
Is this node a child of the given node?
节点是否是给定节点的子节点
Returns true if this node is a child, deep child or identical to the given node.
setPositionX ( x )
Sets the x axis position of the node in cocos2d coordinates.
在cocos2d坐标系中,设置节点X轴位置。
getPositionX ( ) Number
Returns the x axis position of the node in cocos2d coordinates.
获得节点在cocos2d坐标系中X轴位置。
getPositionY ( ) Number
Returns the y axis position of the node in cocos2d coordinates.
获得节点在cocos2d坐标系中Y轴位置。
setPositionY ( y )
Sets the y axis position of the node in cocos2d coordinates.
在cocos2d坐标系中,设置节点Y轴位置。
getLocalZOrder ( ) Number
Returns the local Z order of this node.
返回节点的本地Z轴顺序。
setLocalZOrder ( localZOrder )
LocalZOrder is the 'key' used to sort the node relative to its siblings.
LocalZOrder用于相对于它的兄弟姐妹进行排序.
The Node's parent will sort all its children based ont the LocalZOrder value.
节点的父亲将基于LocalZOrder对所有的孩子进行排序。
If two nodes have the same LocalZOrder, then the node that was added first to the children's array will be in front of the other node in the array.
如果两个节点具有相同的localzorder,那么加入第一个孩子节点队列的节点将在其他节点队列的前面。
Also, the Scene Graph is traversed using the "In-Order" tree traversal algorithm ( http://en.wikipedia.org/wiki/Tree_traversal#In-order ) 并且,场景图是用“In-Order”树遍历算法遍历的。
Tree traversal
And Nodes that have LocalZOder values smaller than 0 are the "left" subtree
localzoder值小于0的节点是“左”子树.
While Nodes with LocalZOder greater than 0 are the "right" subtree.
localzoder值大于0的节点是“右”子树.
isIgnoreAnchorPointForPosition ( ) Boolean
Returns whether the anchor point will be ignored when you position this node.
返回这个节点位置时,是否会忽略这个锚点.
When anchor point ignored, position will be calculated based on the origin point (0, 0) in parent's coordinates.
当锚点被忽略时,在父坐标系中的原点(0、0)计算位置。
ignoreAnchorPointForPosition ( newValue )
Sets whether the anchor point will be ignored when you position this node.
设置此节点位置时,是否会忽略锚点。
This is an internal method, only used by CCLayer and CCScene. Don't call it outside framework.
这是一个内部的方法,只有cclayer和ccscene使用。不要在外部框架调用它。
The default value is false, while in CCLayer and CCScene are true.
默认值是false,而在cclayer和ccscene是true.
isCascadeOpacityEnabled ( ) Boolean
Returns whether node's opacity value affect its child nodes.
返回节点的不透明度值是否影响其子节点.
setCascadeOpacityEnabled ( cascadeOpacityEnabled )
Enable or disable cascade opacity, if cascade enabled, child nodes' opacity will be the multiplication of parent opacity and its own opacity.
启用或禁用级联不透明度,如果级联启用,子节点的不透明度将乘以父亲不透明和它自己的不透明度。
isCascadeColorEnabled ( ) Boolean
Returns whether node's color value affect its child nodes.
返回节点的颜色值是否影响其子节点。
setCascadeColorEnabled ( cascadeColorEnabled )
Enable or disable cascade color, if cascade enabled, child nodes' opacity will be the cascade value of parent color and its own color.
启用或禁用级联颜色,如果级联启用,子节点的不透明度将是父亲颜色和它自己的颜色的级联值。
destroy ( ) Boolean
Destroy this Object, and release all its own references to other objects.
销毁这个对象,释放所有的其他对象对其的引用。
After destroy, this CCObject is not usable any more. You can use cc.isValid(obj) (or obj.isValid if obj is non-nil) to check whether the object is destroyed before accessing it.
破坏后,这个CCObject不再可用。在访问之前,您可以使用cc.isValid(obj)(或obj.isValid如果obj非nil值)检查对象是否被摧毁。
realDestroyInEditor ( )
In fact, Object's "destroy" will not trigger the destruct operation in Firebal Editor. The destruct operation will be executed by Undo system later.
实际上,对象的“摧毁”不会在Firebal编辑器引发销毁操作。销毁操作将在还原系统后执行。
Events
略。