Internal
__editorProtected
_activeProtected
_activeProtected
_childrenProtected
_componentsProtected
_eulerProtected
_eulerProtected
_eventProtected
_eventProtected
_flagProtected
_hasProtected
_idProtected
_layerProtected
_lposProtected
_lrotProtected
_lscaleProtected
_mobilityProtected
_nameInternal
_objrecord scene's id when set this node as persist node
当设置节点为常驻节点时记录场景的 id
since v3.5.0, this is an engine private interface that will be removed in the future.
Protected
_parentProtected
_prefabTODO(PP_Pro): this property should be exported to editor only, we should support editorOnly tag. Tracking issue: https://github.com/cocos/cocos-engine/issues/14613
Protected
_sceneProtected
_siblingsince v3.5.0, this is an engine private interface that will be removed in the future.
Protected
_transformsince v3.5.0, this is an engine private interface that will be removed in the future.
Protected
black触摸事件阻挡
Protected
mask半透明遮罩资源
Private
params窗口调用参数队列
Protected
ui_被移除的界面缓存数据
Protected
ui_显示界面节点集合
Static
EventEvent types emitted by Node
节点可能发出的事件类型
Static
NodeCoordinates space
空间变换操作的坐标系
Static
TransformBit masks for Node transformation parts, can be used to determine which part changed in NodeEventType.TRANSFORM_CHANGED event
节点变换更新的具体部分,可用于判断 NodeEventType.TRANSFORM_CHANGED 事件的具体类型
Static
TransformBit masks for Node transformation parts
节点变换更新的具体部分
please use Node.TransformBit
Static
Protected
Internal
_stackStatic
Protected
Internal
_stacksfor walk
Static
Protected
Internal
idStatic
reservesince v3.5.0, this is an engine private interface that will be removed in the future.
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.
如果为true,则该节点是一个常驻节点,不会在场景转换期间被销毁。 如果为false,节点将在加载新场景时自动销毁。默认为 false。
false
since v3.5.0, this is an engine private interface that will be removed in the future.
The local active state of this node. Note that a Node may be inactive because a parent is not active, even if this returns true. Use activeInHierarchy if you want to check if the Node is actually treated as active in the scene.
当前节点的自身激活状态。 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。 如果你想检查节点在场景中实际的激活状态可以使用 activeInHierarchy
true
Indicates whether this node is active in the scene.
表示此节点是否在场景中激活。
Rotation in local coordinate system, represented by euler angles, but limited on z axis
本地坐标系下的旋转,用欧拉角表示,但是限定在 z 轴上。
All children nodes.
节点的所有子节点。
Gets all components attached to this node.
获取附加到此节点的所有组件。
Rotation in local coordinate system, represented by euler angles
本地坐标系下的旋转,用欧拉角表示
The event processor of the current node, it provides EventTarget ability.
当前节点的事件处理器,提供 EventTarget 能力。
since v3.4.0
The vector representing forward direction in local coordinate system, it's the minus z direction by default
当前节点面向的前方方向,默认前方为 -z 方向
Whether the node's transformation have changed during the current frame.
这个节点的空间变换信息在当前帧内是否有变过?
After inheriting CCObject objects, control whether you need to hide, lock, serialize, and other functions.
在继承 CCObject 对象后,控制是否需要隐藏,锁定,序列化等功能。
Indicates whether the object is not yet destroyed. (It will not be available after being destroyed)
When an object's destroy
is called, it is actually destroyed after the end of this frame.
So isValid
will return false from the next frame, while isValid
in the current frame will still be true.
If you want to determine whether the current frame has called destroy
, use isValid(obj, true)
,
but this is often caused by a particular logical requirements, which is not normally required.
表示该对象是否可用(被 destroy 后将不可用)。
当一个对象的 destroy
调用以后,会在这一帧结束后才真正销毁。
因此从下一帧开始 isValid
就会返回 false,而当前帧内 isValid
仍然会是 true。
如果希望判断当前帧是否调用过 destroy
,请使用 isValid(obj, true)
,不过这往往是特殊的业务需求引起的,通常情况下不需要这样。
true
import { Node, log } from 'cc';
const node = new Node();
log(node.isValid); // true
node.destroy();
log(node.isValid); // true, still valid in this frame
// after a frame...
log(node.isValid); // false, destroyed in the end of last frame
Layer of the current Node, it affects raycast, physics etc, refer to Layers
节点所属层,主要影响射线检测、物理碰撞等,参考 Layers
Local transformation matrix
本地坐标系变换矩阵
Name of node.
该节点名称。
The parent node
父节点
Position in local coordinate system
本地坐标系下的坐标
Return the right direction vector of this node in world space.
返回当前节点在世界空间中朝右的方向向量
Rotation in local coordinate system, represented by a quaternion
本地坐标系下的旋转,用四元数表示
Scale in local coordinate system
本地坐标系下的缩放
Which scene this node belongs to.
此节点属于哪个场景。
Return the up direction vertor of this node in world space.
返回当前节点在世界空间中朝上的方向向量
The uuid for editor, will be stripped after building project.
主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。
World transformation matrix
世界坐标系变换矩阵
Position in world coordinate system
世界坐标系下的坐标
Rotation in world coordinate system, represented by a quaternion
世界坐标系下的旋转,用四元数表示
Scale in world coordinate system
世界坐标系下的缩放
Protected
Optional
_checkEnsures that this node has already had the specified component(s). If not, this method throws.
检查节点已经包含对应的组件,如果没有,则抛出异常
If one or more component of same type have been existed in this node.
Constructor of the component.
Clear all references in the instance.
NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject.
清理实例的所有引用 注意:此方法不会清理实例上的 getter 与 setter 方法。
since v3.5.0, this is an engine private interface that will be removed in the future.
// 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;
}
}
}
Protected
_instantiateProtected
_onProtected
_onProtected
_onProtected
_onsince v3.5.0, this is an engine private interface that will be removed in the future.
Optional
keepWorldTransform: booleanProtected
Optional
_onProtected
_update添加一个预制件节点到层容器中,该方法将返回一个唯一uuid
来标识该操作节点
ture为成功,false为失败
Optional
params: any自定义参数
Optional
callbacks: UICallbacks回调函数对象,可选
Adds a component class to the node. You can also add component to node by passing in the name of the script.
向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
TypeError
if the classConstructor
does not specify a cc-class constructor extending the Component
.
var sprite = node.addComponent(Sprite);
The class of the component to add
Adds a component class to the node. You can also add component to node by passing in the name of the script.
向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
TypeError
if the className
does not specify a cc-class constructor extending the Component
.
var test = node.addComponent("Test");
The class name of the component to add
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 的所有属性将被设置为节点属性。
var attrs = { name: 'New Name', active: false };
node.attr(attrs);
Properties to be set to node
Protected
closeProtected
closeTrigger an event directly with the event name and necessary arguments.
通过事件名发送自定义事件
eventTarget.emit('fire', event);
eventTarget.emit('fire', message, emitter);
event type
Optional
arg0: anyOptional
arg1: anyFirst argument in callback
Optional
arg2: anySecond argument in callback
Optional
arg3: anyThird argument in callback
Optional
arg4: anyFourth argument in callback
Returns the component of supplied type if the node has one attached, null if it doesn't. You can also get component in the node by passing in the name of the script.
获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。 传入参数也可以是脚本的名称。
// get sprite component.
var sprite = node.getComponent(Sprite);
The class of the target component
Returns the component of supplied type if the node has one attached, null if it doesn't. You can also get component in the node by passing in the name of the script.
获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。 传入参数也可以是脚本的名称。
// get custom test class.
var test = node.getComponent("Test");
The class name of the target component
Returns the component of given type in any of its children using depth first search.
递归查找所有子节点中第一个匹配指定类型的组件。
var sprite = node.getComponentInChildren(Sprite);
The class of the target component
Returns the component of given type in any of its children using depth first search.
递归查找所有子节点中第一个匹配指定类型的组件。
var Test = node.getComponentInChildren("Test");
The class name of the target component
Returns all components of given type in the node.
返回节点上指定类型的所有组件。
The class of the target component
Returns all components of given type in the node.
返回节点上指定类型的所有组件。
The class name of the target component
Returns all components of given type in self or any of its children.
递归查找自身或所有子节点中指定类型的组件
var sprites = node.getComponentsInChildren(Sprite);
The class of the target component
Returns all components of given type in self or any of its children.
递归查找自身或所有子节点中指定类型的组件
var tests = node.getComponentsInChildren("Test");
The class name of the target component
Get position in local coordinate system, please try to pass out
vector and reuse it to avoid garbage.
获取本地坐标,注意,尽可能传递复用的 Vec3 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new vector will be generated and return
Optional
out: Vec3Set the result to out vector
Get rotation as quaternion in local coordinate system, please try to pass out
quaternion and reuse it to avoid garbage.
获取本地旋转,注意,尽可能传递复用的 Quat 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new quaternion will be generated and return
Optional
out: QuatSet the result to out quaternion
Get scale in local coordinate system, please try to pass out
vector and reuse it to avoid garbage.
获取本地缩放,注意,尽可能传递复用的 Vec3 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new vector will be generated and return
Optional
out: Vec3Set the result to out vector
Get position in world coordinate system, please try to pass out
vector and reuse it to avoid garbage.
获取世界坐标,注意,尽可能传递复用的 Vec3 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new vector will be generated and return
Optional
out: Vec3Set the result to out vector
Get rotation as quaternion in world coordinate system, please try to pass out
quaternion and reuse it to avoid garbage.
获取世界坐标系下的旋转,注意,尽可能传递复用的 Quat 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new quaternion will be generated and return
Optional
out: QuatSet the result to out quaternion
Get scale in world coordinate system, please try to pass out
vector and reuse it to avoid garbage.
获取世界缩放,注意,尽可能传递复用的 Vec3 以避免产生垃圾。
If out
given, the return value equals to out
, otherwise a new vector will be generated and return
Optional
out: Vec3Set the result to out vector
Checks whether the EventTarget object has any callback registered for a specific type of event.
检查事件目标对象是否有为特定类型的事件注册的回调。
True if a callback of the specified type is registered; false otherwise.
The type of event.
Optional
callback: FunctionThe callback function of the event listener, if absent all event listeners for the given type will be removed
Optional
target: unknownThe callback callee of the event listener
Inversely transform a point from world coordinate system to local coordinate system.
逆向变换一个空间点,一般用于将世界坐标转换到本地坐标系中。
The result point in local coordinate system will be stored in this vector
A position in world coordinate system
Is this node a child of the given node?
是否是指定节点的子节点?
True if this node is a child, deep child or identical to the given node.
Protected
load加载界面资源
显示参数
Optional
bundle: string远程资源包名,如果为空就是默认本地资源包
Private
nextRemoves the callback previously registered with the same type, callback, target and or useCapture. This method is merely an alias to removeEventListener.
删除之前与同类型,回调,目标或 useCapture 注册的回调。
this.node.off(NodeEventType.TOUCH_START, this.memberFunction, this);
node.off(NodeEventType.TOUCH_START, callback, this.node);
A string representing the event type being removed.
Optional
callback: FunctionThe callback to remove.
Optional
target: unknownThe target (this object) to invoke the callback, if it's not given, only callback without target will be removed
Optional
useCapture: anyWhen 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.
Register a callback of a specific event type on Node. Use this method to register touch or mouse event permit propagation based on scene graph, These kinds of event are triggered with dispatchEvent, the dispatch process has three steps:
event.stopPropagation()
or event.stopPropagationImmediate()
.
You can also register custom event and use emit
to trigger custom event on Node.
For such events, there won't be capturing and bubbling phase,
your event will be dispatched directly to its listeners registered on the same node.
You can also pass event callback parameters with emit
by passing parameters after type
.在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:
this.node.on(NodeEventType.TOUCH_START, this.memberFunction, this); // if "this" is component and the "memberFunction" declared in CCClass.
node.on(NodeEventType.TOUCH_START, callback, this);
node.on(NodeEventType.TOUCH_MOVE, callback, this);
node.on(NodeEventType.TOUCH_END, callback, this);
A string representing the event type to listen for.
See Node.EventType.POSITION_CHANGED for all builtin events.
The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
Optional
target: unknownThe target (this object) to invoke the callback, can be null
Optional
useCapture: anyWhen 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.
Protected
onRegister an callback of a specific event type on the Node, the callback will remove itself after the first time it is triggered.
注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。
A string representing the event type to listen for.
The callback that will be invoked when the event is dispatched. The callback is ignored if it is a duplicate (the callbacks are unique).
Optional
target: unknownThe target (this object) to invoke the callback, can be null
Optional
useCapture: anyProtected
openPause all system events which is dispatched by SystemEvent. If recursive is set to true, then this API will pause the node system events for the node and all nodes in its sub node tree.
暂停所有 SystemEvent 派发的系统事件。 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。
Whether pause system events recursively for the child node tree
Removes a child from the container.
移除节点中指定的子节点。
The child node which will be removed.
Removes a component identified by the given name or removes the component object given. You can also use component.destroy() if you already have the reference.
删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 如果你已经获得组件引用,你也可以直接调用 component.destroy()
please destroy the component to remove it.
node.removeComponent(Sprite);
The class of the component to remove
Removes a component identified by the given name or removes the component object given. You can also use component.destroy() if you already have the reference.
删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 如果你已经获得组件引用,你也可以直接调用 component.destroy()
please destroy the component to remove it.
import { Sprite } from 'cc';
const sprite = node.getComponent(Sprite);
if (sprite) {
node.removeComponent(sprite);
}
node.removeComponent('Sprite');
The class name of the component to remove or the component instance to be removed
Resume all paused system events which is dispatched by SystemEvent. If recursive is set to true, then this API will resume the node system events for the node and all nodes in its sub node tree.
恢复所有 SystemEvent 派发的系统事件。 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。
Whether resume system events recursively for the child node tree
Protected
setSet position in local coordinate system
设置本地坐标
Target position
Set position in local coordinate system
设置本地坐标
X axis position
Y axis position
Optional
z: numberZ axis position
Set rotation in local coordinate system with a quaternion representing the rotation. Please make sure the rotation is normalized.
用四元数设置本地旋转, 请确保设置的四元数已归一化。
Rotation in quaternion
Set rotation in local coordinate system with a quaternion representing the rotation. Please make sure the rotation is normalized.
用四元数设置本地旋转, 请确保设置的四元数已归一化。
X value in quaternion
Y value in quaternion
Z value in quaternion
W value in quaternion
Set rotation in local coordinate system with a vector representing euler angles
用欧拉角设置本地旋转
Rotation in vector
Set rotation in local coordinate system with euler angles
用欧拉角设置本地旋转
X axis rotation
Y axis rotation
Optional
zOpt: numberSet scale in local coordinate system
设置本地缩放
Target scale
Set scale in local coordinate system
设置本地缩放
X axis scale
Y axis scale
Optional
z: numberZ axis scale
Set position in world coordinate system
设置世界坐标
Target position
Set position in world coordinate system
设置世界坐标
X axis position
Y axis position
Z axis position
Set rotation in world coordinate system with a quaternion representing the rotation
用四元数设置世界坐标系下的旋转
Rotation in quaternion
Set rotation in world coordinate system with a quaternion representing the rotation
用四元数设置世界坐标系下的旋转
X value in quaternion
Y value in quaternion
Z value in quaternion
W value in quaternion
Set scale in world coordinate system
设置世界坐标系下的缩放
Target scale
Set scale in world coordinate system
设置世界坐标系下的缩放
X axis scale
Y axis scale
Z axis scale
Private
show显示模式弹窗
Optional
params: anyOptional
callbacks: UICallbacksProtected
show创建界面节点
视图参数
Walk though the sub children tree of the current node. Each node, including the current node, in the sub tree will be visited two times, before all children and after all children. This function call is not recursive, it's based on stack. Please don't walk any other node inside the walk process.
遍历该节点的子树里的所有节点并按规则执行回调函数。 对子树中的所有节点,包含当前节点,会执行两次回调,preFunc 会在访问它的子节点之前调用,postFunc 会在访问所有子节点之后调用。 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。
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');
});
The callback to process node when reach the node for the first time
Optional
postFunc: ((target: LayerDialog) => void)The callback to process node when re-visit the node after walked all children in its sub tree
Static
_deferredStatic
Protected
_findStatic
Protected
_findStatic
Protected
_findStatic
Protected
_findStatic
Protected
_setStatic
clearStatic
isStatic
resetGenerated using TypeDoc
界面层对象