Scene 类型
继承于 Node
模块: cc
cc.Scene 是 cc.Node 的子类,仅作为一个抽象的概念。
cc.Scene 和 cc.Node 有点不同,用户不应直接修改 cc.Scene。
索引
属性(properties)
autoReleaseAssetsBoolean指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。groupIndexInteger节点的分组索引。groupString节点的分组。positionVec2节点在父节点坐标系中的位置(x, y)。xNumber节点 X 轴坐标。yNumber节点 Y 轴坐标。rotationNumber该节点旋转角度。rotationXNumber该节点 X 轴旋转角度。rotationYNumber该节点 Y 轴旋转角度。scaleNumber节点相对父节点的缩放。scaleXNumber节点 X 轴缩放。scaleYNumber节点 Y 轴缩放。skewXNumber该节点 X 轴倾斜角度。skewYNumber该节点 Y 轴倾斜角度。opacityNumber节点透明度,默认值为 255。colorColor节点颜色。anchorXNumber节点 X 轴锚点位置。anchorYNumber节点 Y 轴锚点位置。widthNumber节点宽度。heightNumber节点高度。zIndexNumberzIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。cascadeOpacityBoolean节点的不透明度值是否影响其子节点,默认值为 true。_levelNumber_componentsComponent[]_prefabPrefabInfoThe PrefabInfo object_persistNodeBooleanIf true, the node is an persist node which won't be destroyed during scene transition....nameString该节点名称。uuidString主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。childrenNode[]节点的所有子节点。childrenCountNumber节点的子节点数量。activeBoolean当前节点的自身激活状态。activeInHierarchyBoolean表示此节点是否在场景中激活。__eventTargetsEventTarget[]Register all related EventTargets,...parentNode该节点的父节点。_nameString_objFlagsNumberisValidBoolean表示该对象是否可用(被 destroy 后将不可用)。
方法
constructoron在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。once注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。off删除之前与同类型,回调,目标或 useCapture 注册的回调。targetOff移除目标上的所有注册事件。hasEventListener检查事件目标对象是否有为特定类型的事件注册的回调。emit通过事件名发送自定义事件dispatchEvent分发事件到事件流中。pauseSystemEvents暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。resumeSystemEvents恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。_getCapturingTargetsGet all the targets listening to the supplied type of event in the target's capturing phase...._getBubblingTargetsGet all the targets listening to the supplied type of event in the target's bubbling phase....runAction执行并返回该执行的动作。pauseAllActions暂停本节点上所有正在运行的动作。resumeAllActions恢复运行本节点上所有暂停的动作。stopAllActions停止并且移除所有正在运行的动作列表。stopAction停止并移除指定的动作。stopActionByTag停止并且移除指定标签的动作。getActionByTag通过标签获取指定动作。getNumberOfRunningActions获取运行着的动作加上正在调度运行的动作的总数。getPosition获取节点在父节点坐标系中的位置(x, y)。setPosition设置节点在父节点坐标系中的位置。getScale获取节点的缩放。setScale设置节点的缩放比例,默认值为 1.0。setRotation设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。getRotation获取该节点以局部坐标系 Z 轴为轴进行旋转的角度。getContentSize获取节点自身大小,不受该节点是否被缩放或者旋转的影响。setContentSize设置节点原始大小,不受该节点是否被缩放或者旋转的影响。getAnchorPoint获取节点锚点,用百分比表示。setAnchorPoint设置锚点的百分比。lookAt通过观察目标来设置 rotation,一般用于 Camera Node 上getLocalMatrix返回局部空间坐标系的矩阵,基于父节点坐标系。getWorldMatrix返回世界空间坐标系的矩阵。convertToNodeSpace将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。convertToWorldSpace将一个相对于节点左下角的坐标位置转换到世界空间坐标系。convertToNodeSpaceAR将一个点转换到节点 (局部) 空间坐标系,这个坐标系以锚点为原点。convertToWorldSpaceAR将节点坐标系下的一个点转换到世界空间坐标系。getNodeToParentTransform返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。getNodeToParentTransformAR返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。getNodeToWorldTransform返回节点到世界坐标系的仿射变换矩阵。getNodeToWorldTransformAR返回节点到世界坐标仿射变换矩阵。getParentToNodeTransform返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。getWorldToNodeTransformconvertTouchToNodeSpace将触摸点转换成本地坐标系中位置。convertTouchToNodeSpaceAR转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。getBoundingBox返回父节坐标系下的轴向对齐的包围盒。getBoundingBoxToWorld返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。addChild添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。cleanup停止所有正在播放的动作和计时器。sortAllChildren根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。getDisplayedOpacity显示透明度是基于自身透明度和父节点透明度计算的。getDisplayedColor显示颜色是基于自身颜色和父节点颜色计算的。isCascadeOpacityEnabled返回节点的不透明度值是否影响其子节点。setCascadeOpacityEnabled启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。setOpacityModifyRGB透明度影响颜色配置已经被废弃...isOpacityModifyRGB获取更改透明度时是否修改RGB值。getParent获取该节点的父节点。setParent设置该节点的父节点。attr属性配置函数。getChildByUuid通过 uuid 获取节点的子节点。getChildByName通过名称获取节点的子节点。insertChild插入子节点到指定位置getSiblingIndex获取同级索引。setSiblingIndex设置节点同级索引。walk遍历该节点的子树里的所有节点并按规则执行回调函数。removeFromParent从父节点中删除该节点。removeChild移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。removeAllChildren移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。isChildOf是否是指定节点的子节点?getComponent获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。getComponents返回节点上指定类型的所有组件。getComponentInChildren递归查找所有子节点中第一个匹配指定类型的组件。getComponentsInChildren递归查找自身或所有子节点中指定类型的组件addComponent向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。_addComponentAtThis api should only used by undo systemremoveComponent删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。_getDependComponentdestroyAllChildren销毁所有子节点,并释放所有它们对其它对象的引用。destroy销毁该对象,并释放所有它对其它对象的引用。_destructClear all references in the instance...._onPreDestroyCalled before the object being destroyed._serializeThe customized serialization for this object. (Editor Only)_deserializeInit this object from the custom serialized data.
事件
position-changed位置变动监听事件, 通过 this.node.on(cc.Node.EventType.POSITION_CHANGED, callback, this); 进行监听。size-changed尺寸变动监听事件,通过 this.node.on(cc.Node.EventType.SIZE_CHANGED, callback, this); 进行监听。anchor-changed锚点变动监听事件,通过 this.node.on(cc.Node.EventType.ANCHOR_CHANGED, callback, this); 进行监听。child-added增加子节点监听事件,通过 this.node.on(cc.Node.EventType.CHILD_ADDED, callback, this); 进行监听。child-removed删除子节点监听事件,通过 this.node.on(cc.Node.EventType.CHILD_REMOVED, callback, this); 进行监听。child-reorder子节点顺序变动监听事件,通过 this.node.on(cc.Node.EventType.CHILD_REORDER, callback, this); 进行监听。group-changed节点分组变动监听事件,通过 this.node.on(cc.Node.EventType.GROUP_CHANGED, callback, this); 进行监听。active-in-hierarchy-changed注意:此节点激活时,此事件仅从最顶部的节点发出。
Details
属性(properties)
autoReleaseAssets
指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/CCScene.js:47 |
groupIndex
节点的分组索引。
节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
| meta | description |
|---|---|
| 类型 | Integer |
| 定义于 | cocos2d/core/CCNode.js:584 |
group
节点的分组。
节点的分组将关系到节点的碰撞组件可以与哪些碰撞组件相碰撞。
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/CCNode.js:600 |
position
节点在父节点坐标系中的位置(x, y)。
| meta | description |
|---|---|
| 类型 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:625 |
示例
cc.log("Node Position: " + node.position);
x
节点 X 轴坐标。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:633 |
示例
node.x = 100;
cc.log("Node Position X: " + node.x);
y
节点 Y 轴坐标。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:676 |
示例
node.y = 100;
cc.log("Node Position Y: " + node.y);
rotation
该节点旋转角度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:742 |
示例
node.rotation = 90;
cc.log("Node Rotation: " + node.rotation);
rotationX
该节点 X 轴旋转角度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:770 |
示例
node.rotationX = 45;
cc.log("Node Rotation X: " + node.rotationX);
rotationY
该节点 Y 轴旋转角度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:803 |
示例
node.rotationY = 45;
cc.log("Node Rotation Y: " + node.rotationY);
scale
节点相对父节点的缩放。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:836 |
示例
node.scale = 1;
scaleX
节点 X 轴缩放。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:845 |
示例
node.scaleX = 0.5;
cc.log("Node Scale X: " + node.scaleX);
scaleY
节点 Y 轴缩放。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:871 |
示例
node.scaleY = 0.5;
cc.log("Node Scale Y: " + node.scaleY);
skewX
该节点 X 轴倾斜角度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:897 |
示例
node.skewX = 0;
cc.log("Node SkewX: " + node.skewX);
skewY
该节点 Y 轴倾斜角度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:917 |
示例
node.skewY = 0;
cc.log("Node SkewY: " + node.skewY);
opacity
节点透明度,默认值为 255。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:937 |
示例
node.opacity = 255;
color
节点颜色。默认为白色,数值为:(255,255,255)。
| meta | description |
|---|---|
| 类型 | Color |
| 定义于 | cocos2d/core/CCNode.js:959 |
示例
node.color = new cc.Color(255, 255, 255);
anchorX
节点 X 轴锚点位置。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:989 |
示例
node.anchorX = 0;
anchorY
节点 Y 轴锚点位置。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:1012 |
示例
node.anchorY = 0;
width
节点宽度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:1035 |
示例
node.width = 100;
height
节点高度。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:1065 |
示例
node.height = 100;
zIndex
zIndex 是用来对节点进行排序的关键属性,它决定一个节点在兄弟节点之间的位置。
zIndex 的取值应该介于 cc.macro.MIN_ZINDEX 和 cc.macro.MAX_ZINDEX 之间 父节点主要根据节点的 zIndex 和添加次序来排序,拥有更高 zIndex 的节点将被排在后面,如果两个节点的 zIndex 一致,先添加的节点会稳定排在另一个节点之前。
节点在 children 中的顺序决定了其渲染顺序。父节点永远在所有子节点之前被渲染
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/CCNode.js:1095 |
示例
node.zIndex = 1;
cc.log("Node zIndex: " + node.zIndex);
cascadeOpacity
透明度级联功能从 v2.0 开始已移除 节点的不透明度值是否影响其子节点,默认值为 true。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/CCNode.js:3189 |
| 废弃(Deprecated) | since v2.0 |
_level
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/utils/base-node.js:151 |
_components
| meta | description |
|---|---|
| 类型 | Component[] |
| 定义于 | cocos2d/core/utils/base-node.js:159 |
_prefab
The PrefabInfo object
| meta | description |
|---|---|
| 类型 | PrefabInfo |
| 定义于 | cocos2d/core/utils/base-node.js:168 |
_persistNode
If true, the node is an persist node which won't be destroyed during scene transition. If false, the node will be destroyed automatically when loading a new scene. Default is false.
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/utils/base-node.js:176 |
name
该节点名称。
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/utils/base-node.js:200 |
示例
node.name = "New Node";
cc.log("Node Name: " + node.name);
uuid
主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/utils/base-node.js:222 |
示例
cc.log("Node Uuid: " + node.uuid);
children
节点的所有子节点。
| meta | description |
|---|---|
| 类型 | Node[] |
| 定义于 | cocos2d/core/utils/base-node.js:237 |
示例
var children = node.children;
for (var i = 0; i < children.length; ++i) {
cc.log("Node: " + children[i]);
}
childrenCount
节点的子节点数量。
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/utils/base-node.js:255 |
示例
var count = node.childrenCount;
cc.log("Node Children Count: " + count);
active
当前节点的自身激活状态。
值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。
如果你想检查节点在场景中实际的激活状态可以使用 Node/activeInHierarchy:property。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/utils/base-node.js:271 |
示例
node.active = false;
activeInHierarchy
表示此节点是否在场景中激活。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/utils/base-node.js:305 |
示例
cc.log("activeInHierarchy: " + node.activeInHierarchy);
__eventTargets
Register all related EventTargets, all event callbacks will be removed in _onPreDestroy
| meta | description |
|---|---|
| 类型 | EventTarget[] |
| 定义于 | cocos2d/core/utils/base-node.js:331 |
parent
该节点的父节点。
| meta | description |
|---|---|
| 类型 | Node |
| 定义于 | cocos2d/core/utils/base-node.js:342 |
示例
cc.log("Node Parent: " + node.parent);
_name
| meta | description |
|---|---|
| 类型 | String |
| 定义于 | cocos2d/core/platform/CCObject.js:76 |
_objFlags
| meta | description |
|---|---|
| 类型 | Number |
| 定义于 | cocos2d/core/platform/CCObject.js:83 |
isValid
表示该对象是否可用(被 destroy 后将不可用)。
当一个对象的destroy调用以后,会在这一帧结束后才真正销毁。因此从下一帧开始isValid就会返回 false,而当前帧内isValid仍然会是 true。如果希望判断当前帧是否调用过destroy,请使用cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
| meta | description |
|---|---|
| 类型 | Boolean |
| 定义于 | cocos2d/core/platform/CCObject.js:261 |
示例
var node = new cc.Node();
cc.log(node.isValid); // true
node.destroy();
cc.log(node.isValid); // true, still valid in this frame
// after a frame...
cc.log(node.isValid); // false, destroyed in the end of last frame
方法
constructor
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1137 |
参数列表
nameString
on
在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。
鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
- 捕获阶段:派发事件给捕获目标(通过
_getCapturingTargets获取),比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。 - 目标阶段:派发给目标节点的监听器。
- 冒泡阶段:派发事件给冒泡目标(通过
_getBubblingTargets获取),比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。
同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。
推荐使用这种方式来监听节点上的触摸或鼠标事件,请不要在节点上直接使用 cc.eventManager。
你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器
你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表
| meta | description |
|---|---|
| 返回 | Function |
| 定义于 | cocos2d/core/CCNode.js:1441 |
参数列表
typeString | Node.EventType A string representing the event type to listen for.
See Node/EventTyupe/POSITION_CHANGED for all builtin events.callbackFunction The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).eventEvent | Any event or first argument when emitarg2Any arg2arg3Any arg3arg4Any arg4arg5Any arg5
targetObject The target (this object) to invoke the callback, can be nulluseCaptureBoolean When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
示例
this.node.on(cc.Node.EventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
node.on(cc.Node.EventType.TOUCH_START, callback, this);
node.on(cc.Node.EventType.TOUCH_MOVE, callback, this);
node.on(cc.Node.EventType.TOUCH_END, callback, this);
node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this);
node.on(cc.Node.EventType.ANCHOR_CHANGED, callback);
node.on(cc.Node.EventType.COLOR_CHANGED, callback);
once
注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1520 |
参数列表
typeString A string representing the event type to listen for.callbackFunction The callback that will be invoked when the event is dispatched.The callback is ignored if it is a duplicate (the callbacks are unique).eventEvent | Any event or first argument when emitarg2Any arg2arg3Any arg3arg4Any arg4arg5Any arg5
targetObject The target (this object) to invoke the callback, can be null
示例
node.once(cc.Node.EventType.ANCHOR_CHANGED, callback);
off
删除之前与同类型,回调,目标或 useCapture 注册的回调。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1597 |
参数列表
typeString A string representing the event type being removed.callbackFunction The callback to remove.targetObject The target (this object) to invoke the callback, if it's not given, only callback without target will be removeduseCaptureBoolean When set to true, the listener will be triggered at capturing phase which is ahead of the final target emit, otherwise it will be triggered during bubbling phase.
示例
this.node.off(cc.Node.EventType.TOUCH_START, this.memberFunction, this);
node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
node.off(cc.Node.EventType.ANCHOR_CHANGED, callback, this);
targetOff
移除目标上的所有注册事件。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1685 |
参数列表
targetObject The target to be searched for all related callbacks
示例
node.targetOff(target);
hasEventListener
检查事件目标对象是否有为特定类型的事件注册的回调。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/CCNode.js:1732 |
参数列表
typeString The type of event.
emit
通过事件名发送自定义事件
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1750 |
参数列表
typeString event typearg1Any First argument in callbackarg2Any Second argument in callbackarg3Any Third argument in callbackarg4Any Fourth argument in callbackarg5Any Fifth argument in callback
示例
eventTarget.emit('fire', event);
eventTarget.emit('fire', message, emitter);
dispatchEvent
分发事件到事件流中。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1774 |
参数列表
eventEvent The Event object that is dispatched into the event flow
pauseSystemEvents
暂停当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1788 |
参数列表
recursiveBoolean Whether to pause node system events on the sub node tree.
示例
node.pauseSystemEvents(true);
resumeSystemEvents
恢复当前节点上注册的所有节点系统事件,节点系统事件包含触摸和鼠标事件。 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。 参考:https://www.cocos.com/docs/creator/scripting/internal-events.html
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1804 |
参数列表
recursiveBoolean Whether to resume node system events on the sub node tree.
示例
node.resumeSystemEvents(true);
_getCapturingTargets
Get all the targets listening to the supplied type of event in the target's capturing phase. The capturing phase comprises the journey from the root to the last node BEFORE the event target's node. The result should save in the array parameter, and MUST SORT from child nodes to parent nodes.
Subclasses can override this method to make event propagable.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1866 |
参数列表
示例
----------
Subclasses can override this method to make event propagable
```js
for (var target = this._parent; target; target = target._parent) {
if (target._capturingListeners && target._capturingListeners.hasEventListener(type)) {
array.push(target);
}
}
_getBubblingTargets
Get all the targets listening to the supplied type of event in the target's bubbling phase. The bubbling phase comprises any SUBSEQUENT nodes encountered on the return trip to the root of the tree. The result should save in the array parameter, and MUST SORT from child nodes to parent nodes.
Subclasses can override this method to make event propagable.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1888 |
参数列表
runAction
执行并返回该执行的动作。该节点将会变成动作的目标。
调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
| meta | description |
|---|---|
| 返回 | Action |
| 定义于 | cocos2d/core/CCNode.js:1910 |
参数列表
actionAction
示例
var action = cc.scaleTo(0.2, 1, 0.6);
node.runAction(action);
node.runAction(action).repeatForever(); // fail
node.runAction(action.repeatForever()); // right
pauseAllActions
暂停本节点上所有正在运行的动作。和 cc.director.getActionManager().pauseTarget(node); 等价。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1939 |
示例
node.pauseAllActions();
resumeAllActions
恢复运行本节点上所有暂停的动作。和 cc.director.getActionManager().resumeTarget(node); 等价。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1950 |
示例
node.resumeAllActions();
stopAllActions
停止并且移除所有正在运行的动作列表。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1961 |
示例
node.stopAllActions();
stopAction
停止并移除指定的动作。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1972 |
参数列表
actionAction An action object to be removed.
示例
var action = cc.scaleTo(0.2, 1, 0.6);
node.stopAction(action);
stopActionByTag
停止并且移除指定标签的动作。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:1985 |
参数列表
tagNumber A tag that indicates the action to be removed.
示例
node.stopAction(1);
getActionByTag
通过标签获取指定动作。
| meta | description |
|---|---|
| 返回 | Action |
| 定义于 | cocos2d/core/CCNode.js:2001 |
参数列表
tagNumber
示例
var action = node.getActionByTag(1);
getNumberOfRunningActions
获取运行着的动作加上正在调度运行的动作的总数。
例如:
- 如果你正在运行 7 个动作中的 1 个 Sequence,它将返回 1。
- 如果你正在运行 2 个动作中的 7 个 Sequence,它将返回 7。
| meta | description |
|---|---|
| 返回 | Number |
| 定义于 | cocos2d/core/CCNode.js:2021 |
示例
var count = node.getNumberOfRunningActions();
cc.log("Running Action Count: " + count);
getPosition
获取节点在父节点坐标系中的位置(x, y)。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2047 |
示例
cc.log("Node Position: " + node.getPosition());
setPosition
设置节点在父节点坐标系中的位置。
可以通过两种方式设置坐标点:
- 传入 2 个数值 x 和 y。
- 传入 cc.v2(x, y) 类型为 cc.Vec2 的对象。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2059 |
参数列表
newPosOrXVec2 | Number X coordinate for position or the position (x, y) of the node in coordinatesyNumber Y coordinate for position
示例
node.setPosition(cc.v2(0, 0));
node.setPosition(0, 0);
getScale
获取节点的缩放。当 X 轴和 Y 轴有相同的缩放数值时。
| meta | description |
|---|---|
| 返回 | Number |
| 定义于 | cocos2d/core/CCNode.js:2119 |
示例
cc.log("Node Scale: " + node.getScale());
setScale
设置节点的缩放比例,默认值为 1.0。这个函数可以在同一时间修改 X 和 Y 缩放。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2135 |
参数列表
示例
node.setScale(cc.v2(1, 1));
node.setScale(1);
setRotation
设置该节点以局部坐标系 Z 轴为轴进行旋转的角度。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2165 |
参数列表
rotationNumber Degree rotation value
getRotation
获取该节点以局部坐标系 Z 轴为轴进行旋转的角度。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2172 |
参数列表
rotationNumber Degree rotation value
getContentSize
获取节点自身大小,不受该节点是否被缩放或者旋转的影响。
| meta | description |
|---|---|
| 返回 | Size |
| 定义于 | cocos2d/core/CCNode.js:2179 |
示例
cc.log("Content Size: " + node.getContentSize());
setContentSize
设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2194 |
参数列表
sizeSize | Number The untransformed size of the node or The untransformed size's width of the node.heightNumber The untransformed size's height of the node.
示例
node.setContentSize(cc.size(100, 100));
node.setContentSize(100, 100);
getAnchorPoint
获取节点锚点,用百分比表示。
锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2237 |
示例
cc.log("Node AnchorPoint: " + node.getAnchorPoint());
setAnchorPoint
设置锚点的百分比。
锚点应用于所有变换和坐标点的操作,它就像在节点上连接其父节点的大头针。
锚点是标准化的,就像百分比一样。(0,0) 表示左下角,(1,1) 表示右上角。
但是你可以使用比(1,1)更高的值或者比(0,0)更低的值。
默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。
注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2261 |
参数列表
pointVec2 | Number The anchor point of node or The x axis anchor of node.yNumber The y axis anchor of node.
示例
node.setAnchorPoint(cc.v2(1, 1));
node.setAnchorPoint(1, 1);
lookAt
通过观察目标来设置 rotation,一般用于 Camera Node 上
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2439 |
参数列表
getLocalMatrix
返回局部空间坐标系的矩阵,基于父节点坐标系。
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/CCNode.js:2582 |
参数列表
outMat4 The matrix object to be filled with data
示例
let mat4 = cc.mat4();
node.getLocalMatrix(mat4);
getWorldMatrix
返回世界空间坐标系的矩阵。
| meta | description |
|---|---|
| 返回 | Mat4 |
| 定义于 | cocos2d/core/CCNode.js:2598 |
参数列表
outMat4 The matrix object to be filled with data
示例
let mat4 = cc.mat4();
node.getWorldMatrix(mat4);
convertToNodeSpace
将一个点转换到节点 (局部) 坐标系,并加上锚点的坐标。
也就是说返回的坐标是相对于节点包围盒左下角的坐标。
这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToNodeSpaceAR。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2614 |
参数列表
worldPointVec2
示例
var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
convertToWorldSpace
将一个相对于节点左下角的坐标位置转换到世界空间坐标系。 这个 API 的设计是为了和 cocos2d-x 中行为一致,更多情况下你可能需要使用 convertToWorldSpaceAR
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2637 |
参数列表
nodePointVec2
示例
var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
convertToNodeSpaceAR
将一个点转换到节点 (局部) 空间坐标系,这个坐标系以锚点为原点。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2657 |
参数列表
worldPointVec2
示例
var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
convertToWorldSpaceAR
将节点坐标系下的一个点转换到世界空间坐标系。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2675 |
参数列表
nodePointVec2
示例
var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
getNodeToParentTransform
返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。这个矩阵以像素为单位。
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2693 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransform(affineTransform);
getNodeToParentTransformAR
返回这个将节点(局部)的空间坐标系转换成父节点的空间坐标系的矩阵。
这个矩阵以像素为单位。
该方法基于节点坐标。
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2721 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getNodeToParentTransformAR(affineTransform);
getNodeToWorldTransform
返回节点到世界坐标系的仿射变换矩阵。矩阵单位是像素。
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2746 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransform(affineTransform);
getNodeToWorldTransformAR
返回节点到世界坐标仿射变换矩阵。矩阵单位是像素。
该方法基于节点坐标。
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2773 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getNodeToWorldTransformAR(affineTransform);
getParentToNodeTransform
返回将父节点的坐标系转换成节点(局部)的空间坐标系的矩阵。
该矩阵以像素为单位。返回的矩阵是只读的,不能更改。
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2796 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getParentToNodeTransform(affineTransform);
getWorldToNodeTransform
| meta | description |
|---|---|
| 返回 | AffineTransform |
| 定义于 | cocos2d/core/CCNode.js:2820 |
| 废弃(Deprecated) | since v2.0 |
参数列表
outAffineTransform The affine transform object to be filled with data
示例
let affineTransform = cc.AffineTransform.create();
node.getWorldToNodeTransform(affineTransform);
convertTouchToNodeSpace
将触摸点转换成本地坐标系中位置。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2840 |
| 废弃(Deprecated) | since v2.0 |
参数列表
touchTouch The touch object
示例
var newVec2 = node.convertTouchToNodeSpace(touch);
convertTouchToNodeSpaceAR
转换一个 cc.Touch(世界坐标)到一个局部坐标,该方法基于节点坐标。
| meta | description |
|---|---|
| 返回 | Vec2 |
| 定义于 | cocos2d/core/CCNode.js:2854 |
| 废弃(Deprecated) | since v2.0 |
参数列表
touchTouch The touch object
示例
var newVec2 = node.convertTouchToNodeSpaceAR(touch);
getBoundingBox
返回父节坐标系下的轴向对齐的包围盒。
| meta | description |
|---|---|
| 返回 | Rect |
| 定义于 | cocos2d/core/CCNode.js:2868 |
示例
var boundingBox = node.getBoundingBox();
getBoundingBoxToWorld
返回节点在世界坐标系下的对齐轴向的包围盒(AABB)。
该边框包含自身和已激活的子节点的世界边框。
| meta | description |
|---|---|
| 返回 | Rect |
| 定义于 | cocos2d/core/CCNode.js:2890 |
示例
var newRect = node.getBoundingBoxToWorld();
addChild
添加子节点,并且可以修改该节点的 局部 Z 顺序和名字。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2956 |
参数列表
childNode A child nodezIndexNumber Z order for drawing priority. Please refer to zIndex propertynameString A name to identify the node easily. Please refer to name property
示例
node.addChild(newNode, 1, "node");
cleanup
停止所有正在播放的动作和计时器。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:2986 |
示例
node.cleanup();
sortAllChildren
根据子节点的 zIndex 和 arrivalOrder 进行排序,正常情况下开发者不需要手动调用这个函数。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:3008 |
getDisplayedOpacity
获取节点显示透明度, 显示透明度和透明度之间的不同之处在于当启用级连透明度时, 显示透明度是基于自身透明度和父节点透明度计算的。
| meta | description |
|---|---|
| 返回 | number |
| 定义于 | cocos2d/core/CCNode.js:3161 |
| 废弃(Deprecated) | since v2.0, please use opacity property, cascade opacity is removed |
getDisplayedColor
获取节点的显示颜色, 显示颜色和颜色之间的不同之处在于当启用级连颜色时, 显示颜色是基于自身颜色和父节点颜色计算的。
| meta | description |
|---|---|
| 返回 | Color |
| 定义于 | cocos2d/core/CCNode.js:3175 |
| 废弃(Deprecated) | since v2.0, please use color property, cascade color is removed |
isCascadeOpacityEnabled
透明度级联功能从 v2.0 开始已移除 返回节点的不透明度值是否影响其子节点。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/CCNode.js:3199 |
| 废弃(Deprecated) | since v2.0 |
setCascadeOpacityEnabled
透明度级联功能从 v2.0 开始已移除 启用或禁用级连不透明度,如果级连启用,子节点的不透明度将是父不透明度乘上它自己的不透明度。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:3209 |
| 废弃(Deprecated) | since v2.0 |
参数列表
cascadeOpacityEnabledBoolean
setOpacityModifyRGB
透明度影响颜色配置已经被废弃 设置更改透明度时是否修改RGB值,
| meta | description |
|---|---|
| 定义于 | cocos2d/core/CCNode.js:3219 |
| 废弃(Deprecated) | since v2.0 |
参数列表
opacityValueBoolean
isOpacityModifyRGB
透明度影响颜色配置已经被废弃 获取更改透明度时是否修改RGB值。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/CCNode.js:3230 |
| 废弃(Deprecated) | since v2.0 |
getParent
获取该节点的父节点。
| meta | description |
|---|---|
| 返回 | Node |
| 定义于 | cocos2d/core/utils/base-node.js:350 |
示例
var parent = this.node.getParent();
setParent
设置该节点的父节点。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:362 |
参数列表
valueNode
示例
node.setParent(newNode);
attr
属性配置函数。在 attrs 的所有属性将被设置为节点属性。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:419 |
参数列表
attrsObject Properties to be set to node
示例
var attrs = { key: 0, num: 100 };
node.attr(attrs);
getChildByUuid
通过 uuid 获取节点的子节点。
| meta | description |
|---|---|
| 返回 | Node |
| 定义于 | cocos2d/core/utils/base-node.js:438 |
参数列表
uuidString The uuid to find the child node.
示例
var child = node.getChildByUuid(uuid);
getChildByName
通过名称获取节点的子节点。
| meta | description |
|---|---|
| 返回 | Node |
| 定义于 | cocos2d/core/utils/base-node.js:461 |
参数列表
nameString A name to find the child node.
示例
var child = node.getChildByName("Test Node");
insertChild
插入子节点到指定位置
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:499 |
参数列表
childNode the child node to be insertedsiblingIndexNumber the sibling index to place the child in
示例
node.insertChild(child, 2);
getSiblingIndex
获取同级索引。
| meta | description |
|---|---|
| 返回 | Number |
| 定义于 | cocos2d/core/utils/base-node.js:517 |
示例
var index = node.getSiblingIndex();
setSiblingIndex
设置节点同级索引。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:534 |
参数列表
indexNumber
示例
node.setSiblingIndex(1);
walk
遍历该节点的子树里的所有节点并按规则执行回调函数。 对子树中的所有节点,包含当前节点,会执行两次回调,prefunc 会在访问它的子节点之前调用,postfunc 会在访问所有子节点之后调用。 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:565 |
参数列表
prefuncFunction The callback to process node when reach the node for the first timetarget_BaseNode The current visiting node
postfuncFunction The callback to process node when re-visit the node after walked all children in its sub treetarget_BaseNode The current visiting node
示例
node.walk(function (target) {
console.log('Walked through node ' + target.name + ' for the first time');
}, function (target) {
console.log('Walked through node ' + target.name + ' after walked all children in its sub tree');
});
removeFromParent
从父节点中删除该节点。如果不传入 cleanup 参数或者传入 true,那么这个节点上所有绑定的事件、action 都会被删除。
因此建议调用这个 API 时总是传入 false 参数。
如果这个节点是一个孤节点,那么什么都不会发生。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:679 |
参数列表
cleanupBoolean true if all actions and callbacks on this node should be removed, false otherwise.
示例
node.removeFromParent();
node.removeFromParent(false);
removeChild
移除节点中指定的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
如果 cleanup 参数不传入,默认为 true 表示清理。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:703 |
参数列表
childNode The child node which will be removed.cleanupBoolean true if all running actions and callbacks on the child node will be cleanup, false otherwise.
示例
node.removeChild(newNode);
node.removeChild(newNode, false);
removeAllChildren
移除节点所有的子节点,是否需要清理所有正在运行的行为取决于 cleanup 参数。
如果 cleanup 参数不传入,默认为 true 表示清理。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:731 |
参数列表
cleanupBoolean true if all running actions on all children nodes should be cleanup, false otherwise.
示例
node.removeAllChildren();
node.removeAllChildren(false);
isChildOf
是否是指定节点的子节点?
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/utils/base-node.js:762 |
参数列表
parentNode
示例
node.isChildOf(newNode);
getComponent
获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
传入参数也可以是脚本的名称。
| meta | description |
|---|---|
| 返回 | Component |
| 定义于 | cocos2d/core/utils/base-node.js:785 |
参数列表
示例
// get sprite component.
var sprite = node.getComponent(cc.Sprite);
// get custom test calss.
var test = node.getComponent("Test");
getComponents
返回节点上指定类型的所有组件。
| meta | description |
|---|---|
| 返回 | Component[] |
| 定义于 | cocos2d/core/utils/base-node.js:812 |
参数列表
示例
var sprites = node.getComponents(cc.Sprite);
var tests = node.getComponents("Test");
getComponentInChildren
递归查找所有子节点中第一个匹配指定类型的组件。
| meta | description |
|---|---|
| 返回 | Component |
| 定义于 | cocos2d/core/utils/base-node.js:833 |
参数列表
示例
var sprite = node.getComponentInChildren(cc.Sprite);
var Test = node.getComponentInChildren("Test");
getComponentsInChildren
递归查找自身或所有子节点中指定类型的组件
| meta | description |
|---|---|
| 返回 | Component[] |
| 定义于 | cocos2d/core/utils/base-node.js:854 |
参数列表
示例
var sprites = node.getComponentsInChildren(cc.Sprite);
var tests = node.getComponentsInChildren("Test");
addComponent
向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
| meta | description |
|---|---|
| 返回 | Component |
| 定义于 | cocos2d/core/utils/base-node.js:890 |
参数列表
示例
var sprite = node.addComponent(cc.Sprite);
var test = node.addComponent("Test");
_addComponentAt
This api should only used by undo system
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:979 |
参数列表
removeComponent
删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 如果你已经获得组件引用,你也可以直接调用 component.destroy()
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:1027 |
| 废弃(Deprecated) | please destroy the component to remove it. |
参数列表
示例
node.removeComponent(cc.Sprite);
var Test = require("Test");
node.removeComponent(Test);
_getDependComponent
| meta | description |
|---|---|
| 返回 | Component |
| 定义于 | cocos2d/core/utils/base-node.js:1055 |
参数列表
dependedComponent
destroyAllChildren
销毁所有子节点,并释放所有它们对其它对象的引用。
实际销毁操作会延迟到当前帧渲染前执行。
| meta | description |
|---|---|
| 定义于 | cocos2d/core/utils/base-node.js:1101 |
示例
node.destroyAllChildren();
destroy
销毁该对象,并释放所有它对其它对象的引用。
实际销毁操作会延迟到当前帧渲染前执行。从下一帧开始,该对象将不再可用。
您可以在访问对象之前使用 cc.isValid(obj) 来检查对象是否已被销毁。
| meta | description |
|---|---|
| 返回 | Boolean |
| 定义于 | cocos2d/core/platform/CCObject.js:296 |
示例
obj.destroy();
_destruct
Clear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; } } }
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:430 |
_onPreDestroy
Called before the object being destroyed.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:463 |
_serialize
The customized serialization for this object. (Editor Only)
| meta | description |
|---|---|
| 返回 | object |
| 定义于 | cocos2d/core/platform/CCObject.js:488 |
参数列表
exportingBoolean
_deserialize
Init this object from the custom serialized data.
| meta | description |
|---|---|
| 定义于 | cocos2d/core/platform/CCObject.js:498 |
参数列表
dataObject the serialized json datactx_Deserializer
事件
position-changed Event
模块: cc
位置变动监听事件, 通过 this.node.on(cc.Node.EventType.POSITION_CHANGED, callback, this); 进行监听。
索引
Details
size-changed Event
模块: cc
尺寸变动监听事件,通过 this.node.on(cc.Node.EventType.SIZE_CHANGED, callback, this); 进行监听。
索引
Details
anchor-changed Event
模块: cc
锚点变动监听事件,通过 this.node.on(cc.Node.EventType.ANCHOR_CHANGED, callback, this); 进行监听。
索引
Details
child-added Event
模块: cc
增加子节点监听事件,通过 this.node.on(cc.Node.EventType.CHILD_ADDED, callback, this); 进行监听。
索引
Details
child-removed Event
模块: cc
删除子节点监听事件,通过 this.node.on(cc.Node.EventType.CHILD_REMOVED, callback, this); 进行监听。
索引
Details
child-reorder Event
模块: cc
子节点顺序变动监听事件,通过 this.node.on(cc.Node.EventType.CHILD_REORDER, callback, this); 进行监听。
索引
Details
group-changed Event
模块: cc
节点分组变动监听事件,通过 this.node.on(cc.Node.EventType.GROUP_CHANGED, callback, this); 进行监听。
索引
Details
active-in-hierarchy-changed Event
注意:此节点激活时,此事件仅从最顶部的节点发出。