Class LayerPopUp

界面层对象

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

__editorExtras__: unknown
_active: boolean
_activeInHierarchy: boolean
_children: LayerPopUp[]
_components: Component[]
_euler: Vec3
_eulerDirty: boolean
_eventMask: number
_eventProcessor: _cocos_scene_graph_node_event_processor__NodeEventProcessor
_flagChangeVersion: number
_hasChangedFlags: number
_id: string
_layer: number
_lpos: Vec3
_lrot: Quat
_lscale: Vec3
_mobility: number
_name: string
_objFlags: number
_originalSceneId: string

En

record scene's id when set this node as persist node

Zh

当设置节点为常驻节点时记录场景的 id

Deprecated

since v3.5.0, this is an engine private interface that will be removed in the future.

_parent: null | LayerPopUp
_prefab: null | PrefabInfo

TODO(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

_scene: Scene
_siblingIndex: number
_static: boolean

Deprecated

since v3.5.0, this is an engine private interface that will be removed in the future.

_transformFlags: TransformBit
_uiProps: _cocos_scene_graph_node_ui_properties__NodeUIProperties

Deprecated

since v3.5.0, this is an engine private interface that will be removed in the future.

black: BlockInputEvents

触摸事件阻挡

mask: Node

半透明遮罩资源

ui_cache: Map<string, ViewParams> = ...

被移除的界面缓存数据

ui_nodes: Map<string, ViewParams> = ...

显示界面节点集合

EventType: typeof NodeEventType

En

Event types emitted by Node

Zh

节点可能发出的事件类型

NodeSpace: typeof NodeSpace

En

Coordinates space

Zh

空间变换操作的坐标系

TransformBit: typeof TransformBit

En

Bit masks for Node transformation parts, can be used to determine which part changed in NodeEventType.TRANSFORM_CHANGED event

Zh

节点变换更新的具体部分,可用于判断 NodeEventType.TRANSFORM_CHANGED 事件的具体类型

TransformDirtyBit: typeof TransformBit

En

Bit masks for Node transformation parts

Zh

节点变换更新的具体部分

Deprecated

please use Node.TransformBit

_stackId: number
_stacks: (null | Node)[][]

for walk

idGenerator: IDGenerator
reserveContentsForAllSyncablePrefabTag: symbol

Deprecated

since v3.5.0, this is an engine private interface that will be removed in the future.

Accessors

  • get _persistNode(): boolean
  • En

    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.

    Zh

    如果为true,则该节点是一个常驻节点,不会在场景转换期间被销毁。 如果为false,节点将在加载新场景时自动销毁。默认为 false。

    Default

    false

    Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Returns boolean

  • set _persistNode(value: boolean): void
  • Parameters

    • value: boolean

    Returns void

  • get active(): boolean
  • En

    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.

    Zh

    当前节点的自身激活状态。 值得注意的是,一个节点的父节点如果不被激活,那么即使它自身设为激活,它仍然无法激活。 如果你想检查节点在场景中实际的激活状态可以使用 activeInHierarchy

    Default

    true

    Returns boolean

  • set active(isActive: boolean): void
  • Parameters

    • isActive: boolean

    Returns void

  • get activeInHierarchy(): boolean
  • En

    Indicates whether this node is active in the scene.

    Zh

    表示此节点是否在场景中激活。

    Returns boolean

  • get angle(): number
  • En

    Rotation in local coordinate system, represented by euler angles, but limited on z axis

    Zh

    本地坐标系下的旋转,用欧拉角表示,但是限定在 z 轴上。

    Returns number

  • set angle(val: number): void
  • Parameters

    • val: number

    Returns void

  • get children(): Node[]
  • En

    All children nodes.

    Zh

    节点的所有子节点。

    Read Only

    Returns Node[]

  • get components(): readonly Component[]
  • En

    Gets all components attached to this node.

    Zh

    获取附加到此节点的所有组件。

    Returns readonly Component[]

  • get eulerAngles(): Readonly<Vec3>
  • Returns Readonly<Vec3>

  • set eulerAngles(val: Readonly<Vec3>): void
  • En

    Rotation in local coordinate system, represented by euler angles

    Zh

    本地坐标系下的旋转,用欧拉角表示

    Parameters

    • val: Readonly<Vec3>

    Returns void

  • get eventProcessor(): _cocos_scene_graph_node_event_processor__NodeEventProcessor
  • En

    The event processor of the current node, it provides EventTarget ability.

    Zh

    当前节点的事件处理器,提供 EventTarget 能力。

    Deprecated

    since v3.4.0

    Returns _cocos_scene_graph_node_event_processor__NodeEventProcessor

  • get forward(): Vec3
  • En

    The vector representing forward direction in local coordinate system, it's the minus z direction by default

    Zh

    当前节点面向的前方方向,默认前方为 -z 方向

    Returns Vec3

  • set forward(dir: Vec3): void
  • Parameters

    • dir: Vec3

    Returns void

  • get hasChangedFlags(): number
  • En

    Whether the node's transformation have changed during the current frame.

    Zh

    这个节点的空间变换信息在当前帧内是否有变过?

    Returns number

  • set hasChangedFlags(val: number): void
  • Parameters

    • val: number

    Returns void

  • get hideFlags(): Flags
  • Returns Flags

  • set hideFlags(hideFlags: Flags): void
  • En

    After inheriting CCObject objects, control whether you need to hide, lock, serialize, and other functions.

    Zh

    在继承 CCObject 对象后,控制是否需要隐藏,锁定,序列化等功能。

    Parameters

    • hideFlags: Flags

    Returns void

  • get isValid(): boolean
  • En

    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.

    Zh

    表示该对象是否可用(被 destroy 后将不可用)。
    当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。
    因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。
    如果希望判断当前帧是否调用过 destroy,请使用 isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。

    Default

    true

    Read Only

    Example

    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

    Returns boolean

  • get layer(): number
  • Returns number

  • set layer(l: number): void
  • En

    Layer of the current Node, it affects raycast, physics etc, refer to Layers

    Zh

    节点所属层,主要影响射线检测、物理碰撞等,参考 Layers

    Parameters

    • l: number

    Returns void

  • set matrix(val: Readonly<Mat4>): void
  • En

    Local transformation matrix

    Zh

    本地坐标系变换矩阵

    Parameters

    • val: Readonly<Mat4>

    Returns void

  • get mobility(): number
  • Returns number

  • set mobility(m: number): void
  • Parameters

    • m: number

    Returns void

  • get name(): string
  • En

    Name of node.

    Zh

    该节点名称。

    Returns string

  • set name(value: string): void
  • Parameters

    • value: string

    Returns void

  • get parent(): null | Node
  • En

    The parent node

    Zh

    父节点

    Returns null | Node

  • set parent(value: null | Node): void
  • Parameters

    • value: null | Node

    Returns void

  • get position(): Readonly<Vec3>
  • En

    Position in local coordinate system

    Zh

    本地坐标系下的坐标

    Returns Readonly<Vec3>

  • set position(val: Readonly<Vec3>): void
  • Parameters

    • val: Readonly<Vec3>

    Returns void

  • get right(): Vec3
  • En

    Return the right direction vector of this node in world space.

    Zh

    返回当前节点在世界空间中朝右的方向向量

    Returns Vec3

  • get rotation(): Readonly<Quat>
  • En

    Rotation in local coordinate system, represented by a quaternion

    Zh

    本地坐标系下的旋转,用四元数表示

    Returns Readonly<Quat>

  • set rotation(val: Readonly<Quat>): void
  • Parameters

    • val: Readonly<Quat>

    Returns void

  • get scale(): Readonly<Vec3>
  • En

    Scale in local coordinate system

    Zh

    本地坐标系下的缩放

    Returns Readonly<Vec3>

  • set scale(val: Readonly<Vec3>): void
  • Parameters

    • val: Readonly<Vec3>

    Returns void

  • get scene(): Scene
  • En

    Which scene this node belongs to.

    Zh

    此节点属于哪个场景。

    Returns Scene

  • get up(): Vec3
  • En

    Return the up direction vertor of this node in world space.

    Zh

    返回当前节点在世界空间中朝上的方向向量

    Returns Vec3

  • get uuid(): string
  • En

    The uuid for editor, will be stripped after building project.

    Zh

    主要用于编辑器的 uuid,在编辑器下可用于持久化存储,在项目构建之后将变成自增的 id。

    Read Only

    Returns string

  • get worldMatrix(): Readonly<Mat4>
  • En

    World transformation matrix

    Zh

    世界坐标系变换矩阵

    Returns Readonly<Mat4>

  • get worldPosition(): Readonly<Vec3>
  • En

    Position in world coordinate system

    Zh

    世界坐标系下的坐标

    Returns Readonly<Vec3>

  • set worldPosition(val: Readonly<Vec3>): void
  • Parameters

    • val: Readonly<Vec3>

    Returns void

  • get worldRotation(): Readonly<Quat>
  • En

    Rotation in world coordinate system, represented by a quaternion

    Zh

    世界坐标系下的旋转,用四元数表示

    Returns Readonly<Quat>

  • set worldRotation(val: Readonly<Quat>): void
  • Parameters

    • val: Readonly<Quat>

    Returns void

  • get worldScale(): Readonly<Vec3>
  • En

    Scale in world coordinate system

    Zh

    世界坐标系下的缩放

    Returns Readonly<Vec3>

  • set worldScale(val: Readonly<Vec3>): void
  • Parameters

    • val: Readonly<Vec3>

    Returns void

Methods

  • Internal

    Parameters

    • serializationOutput: SerializationOutput
    • context: SerializationContext

    Returns void

  • En

    Ensures that this node has already had the specified component(s). If not, this method throws.

    Zh

    检查节点已经包含对应的组件,如果没有,则抛出异常

    Throws

    If one or more component of same type have been existed in this node.

    Type Parameters

    • T extends Component<T>

    Parameters

    • constructor: __types_globals__Constructor<T>

      Constructor of the component.

    Returns void

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Returns void

  • En

    Clear all references in the instance.

    NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject.

    Zh

    清理实例的所有引用 注意:此方法不会清理实例上的 getter 与 setter 方法。

    Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Example

    // 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;
    }
    }
    }

    Returns void

  • Parameters

    • cloned: any
    • isSyncedNode: any

    Returns any

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Parameters

    • dontSyncChildPrefab: boolean

    Returns void

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Parameters

    • active: boolean

    Returns void

  • Returns boolean

  • Returns boolean

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Parameters

    • oldParent: null | LayerPopUp
    • Optional keepWorldTransform: boolean

    Returns void

  • Parameters

    • siblingIndex: number

    Returns void

  • Do remove component, only used internally.

    Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Parameters

    • component: Component

    Returns void

  • Set _scene field of this node. The derived Scene overrides this method to behavior differently.

    Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Returns void

  • Deprecated

    since v3.5.0, this is an engine private interface that will be removed in the future.

    Returns void

  • 添加一个预制件节点到层容器中,该方法将返回一个唯一uuid来标识该操作节点

    Returns

    ture为成功,false为失败

    Parameters

    • config: UIConfig
    • Optional params: any

      自定义参数

    • Optional callbacks: UICallbacks

      回调函数对象,可选

    Returns void

  • En

    Add a child to the current node.

    Zh

    添加一个子节点。

    Parameters

    • child: Node

      the child node to be added

    Returns void

  • En

    Adds a component class to the node. You can also add component to node by passing in the name of the script.

    Zh

    向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。

    Throws

    TypeError if the classConstructor does not specify a cc-class constructor extending the Component.

    Example

    var sprite = node.addComponent(Sprite);
    

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T>

      The class of the component to add

    Returns T

  • En

    Adds a component class to the node. You can also add component to node by passing in the name of the script.

    Zh

    向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。

    Throws

    TypeError if the className does not specify a cc-class constructor extending the Component.

    Example

    var test = node.addComponent("Test");
    

    Parameters

    • className: string

      The class name of the component to add

    Returns Component

  • En

    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.

    Zh

    属性配置函数。在 attrs 的所有属性将被设置为节点属性。

    Example

    var attrs = { name: 'New Name', active: false };
    node.attr(attrs);

    Parameters

    • attrs: unknown

      Properties to be set to node

    Returns void

  • 清除所有节点,队列当中的也删除

    Parameters

    • isDestroy: boolean

      移除后是否释放

    Returns void

  • 关闭遮罩

    Returns void

  • 关闭触摸非窗口区域关闭

    Returns void

  • Returns boolean

  • En

    Destroy all children from the node, and release all their own references to other objects. Actual destruct operation will delayed until before rendering.

    Zh

    销毁所有子节点,并释放所有它们对其它对象的引用。 实际销毁操作会延迟到当前帧渲染前执行。

    Returns void

  • En

    Dispatches an event into the event flow. The event target is the EventTarget object upon which the dispatchEvent() method is called.

    Zh

    分发事件到事件流中。

    Parameters

    • event: Event

      The Event object that is dispatched into the event flow

    Returns void

  • En

    Trigger an event directly with the event name and necessary arguments.

    Zh

    通过事件名发送自定义事件

    Example

    eventTarget.emit('fire', event);
    eventTarget.emit('fire', message, emitter);

    Parameters

    • type: string

      event type

    • Optional arg0: any
    • Optional arg1: any

      First argument in callback

    • Optional arg2: any

      Second argument in callback

    • Optional arg3: any

      Third argument in callback

    • Optional arg4: any

      Fourth argument in callback

    Returns void

  • 根据预制路径获取已打开界面的节点对象

    Parameters

    • prefabPath: string

      预制路径

    Returns Node

  • En

    Returns a child with the same name.

    Zh

    通过名称获取节点的子节点。

    Returns

    a CCNode object whose name equals to the input parameter

    Example

    var child = node.getChildByName("Test Node");
    

    Parameters

    • name: string

      A name to find the child node.

    Returns null | Node

  • En

    Returns a child with the given path.

    Zh

    通过路径获取节点的子节点。

    Returns

    a Node object whose path equals to the input parameter

    Example

    var child = node.getChildByPath("subNode/Test Node");
    

    Parameters

    • path: string

      A path to find the child node.

    Returns null | Node

  • En

    Returns a child with the same uuid.

    Zh

    通过 uuid 获取节点的子节点。

    Returns

    a Node whose uuid equals to the input parameter

    Parameters

    • uuid: string

      The uuid to find the child node.

    Returns null | Node

  • En

    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.

    Zh

    获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。 传入参数也可以是脚本的名称。

    Example

    // get sprite component.
    var sprite = node.getComponent(Sprite);

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

      The class of the target component

    Returns null | T

  • En

    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.

    Zh

    获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。 传入参数也可以是脚本的名称。

    Example

    // get custom test class.
    var test = node.getComponent("Test");

    Parameters

    • className: string

      The class name of the target component

    Returns null | Component

  • En

    Returns the component of given type in any of its children using depth first search.

    Zh

    递归查找所有子节点中第一个匹配指定类型的组件。

    Example

    var sprite = node.getComponentInChildren(Sprite);
    

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

      The class of the target component

    Returns null | T

  • En

    Returns the component of given type in any of its children using depth first search.

    Zh

    递归查找所有子节点中第一个匹配指定类型的组件。

    Example

    var Test = node.getComponentInChildren("Test");
    

    Parameters

    • className: string

      The class name of the target component

    Returns null | Component

  • En

    Returns all components of given type in the node.

    Zh

    返回节点上指定类型的所有组件。

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

      The class of the target component

    Returns T[]

  • En

    Returns all components of given type in the node.

    Zh

    返回节点上指定类型的所有组件。

    Parameters

    • className: string

      The class name of the target component

    Returns Component[]

  • En

    Returns all components of given type in self or any of its children.

    Zh

    递归查找自身或所有子节点中指定类型的组件

    Example

    var sprites = node.getComponentsInChildren(Sprite);
    

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

      The class of the target component

    Returns T[]

  • En

    Returns all components of given type in self or any of its children.

    Zh

    递归查找自身或所有子节点中指定类型的组件

    Example

    var tests = node.getComponentsInChildren("Test");
    

    Parameters

    • className: string

      The class name of the target component

    Returns Component[]

  • En

    Get parent of the node.

    Zh

    获取该节点的父节点。

    Returns null | Node

  • En

    Get the complete path of the current node in the hierarchy.

    Zh

    获得当前节点在 hierarchy 中的完整路径。

    Returns string

  • En

    Get position in local coordinate system, please try to pass out vector and reuse it to avoid garbage.

    Zh

    获取本地坐标,注意,尽可能传递复用的 Vec3 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new vector will be generated and return

    Parameters

    • Optional out: Vec3

      Set the result to out vector

    Returns Vec3

  • En

    Get rotation as quaternion in local coordinate system, please try to pass out quaternion and reuse it to avoid garbage.

    Zh

    获取本地旋转,注意,尽可能传递复用的 Quat 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new quaternion will be generated and return

    Parameters

    • Optional out: Quat

      Set the result to out quaternion

    Returns Quat

  • En

    Get scale in local coordinate system, please try to pass out vector and reuse it to avoid garbage.

    Zh

    获取本地缩放,注意,尽可能传递复用的 Vec3 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new vector will be generated and return

    Parameters

    • Optional out: Vec3

      Set the result to out vector

    Returns Vec3

  • En

    Get the sibling index of the current node in its parent's children array.

    Zh

    获取当前节点在父节点的 children 数组中的位置。

    Returns number

  • En

    Get a world transform matrix

    Zh

    获取世界变换矩阵

    Returns

    If out given, the return value equals to out, otherwise a new matrix will be generated and return

    Parameters

    • Optional out: Mat4

      Set the result to out matrix

    Returns Mat4

  • En

    Get position in world coordinate system, please try to pass out vector and reuse it to avoid garbage.

    Zh

    获取世界坐标,注意,尽可能传递复用的 Vec3 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new vector will be generated and return

    Parameters

    • Optional out: Vec3

      Set the result to out vector

    Returns Vec3

  • En

    Get a world transform matrix with only rotation and scale

    Zh

    获取只包含旋转和缩放的世界变换矩阵

    Returns

    If out given, the return value equals to out, otherwise a new matrix will be generated and return

    Parameters

    • Optional out: Mat4

      Set the result to out matrix

    Returns Mat4

  • En

    Get a world transform matrix with only rotation and translation

    Zh

    获取只包含旋转和位移的世界变换矩阵

    Returns

    If out given, the return value equals to out, otherwise a new matrix will be generated and return

    Parameters

    • Optional out: Mat4

      Set the result to out matrix

    Returns Mat4

  • En

    Get rotation as quaternion in world coordinate system, please try to pass out quaternion and reuse it to avoid garbage.

    Zh

    获取世界坐标系下的旋转,注意,尽可能传递复用的 Quat 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new quaternion will be generated and return

    Parameters

    • Optional out: Quat

      Set the result to out quaternion

    Returns Quat

  • En

    Get scale in world coordinate system, please try to pass out vector and reuse it to avoid garbage.

    Zh

    获取世界缩放,注意,尽可能传递复用的 Vec3 以避免产生垃圾。

    Returns

    If out given, the return value equals to out, otherwise a new vector will be generated and return

    Parameters

    • Optional out: Vec3

      Set the result to out vector

    Returns Vec3

  • 判断当前层是否包含 uuid或预制件路径对应的Node节点

    Parameters

    • prefabPath: string

      预制件路径或者UUID

    Returns boolean

  • En

    Checks whether the EventTarget object has any callback registered for a specific type of event.

    Zh

    检查事件目标对象是否有为特定类型的事件注册的回调。

    Returns

    True if a callback of the specified type is registered; false otherwise.

    Parameters

    • type: string

      The type of event.

    • Optional callback: Function

      The callback function of the event listener, if absent all event listeners for the given type will be removed

    • Optional target: unknown

      The callback callee of the event listener

    Returns any

  • Returns void

  • En

    Inserts a child to the node at a specified index.

    Zh

    插入子节点到指定位置

    Example

    node.insertChild(child, 2);
    

    Parameters

    • child: Node

      the child node to be inserted

    • siblingIndex: number

      the sibling index to place the child in

    Returns void

  • En

    Invalidate the world transform information for this node and all its children recursively

    Zh

    递归标记节点世界变换为 dirty

    Parameters

    • dirtyBit: TransformBit

      The dirty bits to setup to children, can be composed with multiple dirty bits

    Returns void

  • En

    Inversely transform a point from world coordinate system to local coordinate system.

    Zh

    逆向变换一个空间点,一般用于将世界坐标转换到本地坐标系中。

    Parameters

    • out: Vec3

      The result point in local coordinate system will be stored in this vector

    • p: Vec3

      A position in world coordinate system

    Returns Vec3

  • En

    Is this node a child of the given node?

    Zh

    是否是指定节点的子节点?

    Returns

    True if this node is a child, deep child or identical to the given node.

    Parameters

    Returns boolean

  • En

    Does the world transform information of this node need to be updated?

    Zh

    这个节点的空间变换信息是否需要更新?

    Returns boolean

  • 加载界面资源

    Parameters

    • vp: ViewParams

      显示参数

    • Optional bundle: string

      远程资源包名,如果为空就是默认本地资源包

    Returns void

  • En

    Set the orientation of the node to face the target position, the node is facing minus z direction by default

    Zh

    设置当前节点旋转为面向目标位置,默认前方为 -z 方向

    Parameters

    • pos: Readonly<Vec3>

      Target position

    • Optional up: Readonly<Vec3>

      Up direction

    Returns void

  • En

    Removes the callback previously registered with the same type, callback, target and or useCapture. This method is merely an alias to removeEventListener.

    Zh

    删除之前与同类型,回调,目标或 useCapture 注册的回调。

    Example

    this.node.off(NodeEventType.TOUCH_START, this.memberFunction, this);
    node.off(NodeEventType.TOUCH_START, callback, this.node);

    Parameters

    • type: string

      A string representing the event type being removed.

    • Optional callback: Function

      The callback to remove.

    • Optional target: unknown

      The target (this object) to invoke the callback, if it's not given, only callback without target will be removed

    • Optional useCapture: any

      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.

    Returns void

  • En

    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:

    1. Capturing phase: dispatch in capture targets, e.g. parents in node tree, from root to the real target
    2. At target phase: dispatch to the listeners of the real target
    3. Bubbling phase: dispatch in bubble targets, e.g. parents in node tree, from the real target to root In any moment of the dispatching process, it can be stopped via 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.

    Zh

    在节点上注册指定类型的回调函数,也可以设置 target 用于绑定响应函数的 this 对象。 鼠标或触摸事件会被系统调用 dispatchEvent 方法触发,触发的过程包含三个阶段:

    1. 捕获阶段:派发事件给捕获目标,比如,节点树中注册了捕获阶段的父节点,从根节点开始派发直到目标节点。
    2. 目标阶段:派发给目标节点的监听器。
    3. 冒泡阶段:派发事件给冒泡目标,比如,节点树中注册了冒泡阶段的父节点,从目标节点开始派发直到根节点。 同时您可以将事件派发到父节点或者通过调用 stopPropagation 拦截它。 你也可以注册自定义事件到节点上,并通过 emit 方法触发此类事件,对于这类事件,不会发生捕获冒泡阶段,只会直接派发给注册在该节点上的监听器 你可以通过在 emit 方法调用时在 type 之后传递额外的参数作为事件回调的参数列表

    Returns

    • Just returns the incoming callback so you can save the anonymous function easier.

    Example

    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);

    Parameters

    • type: string

      A string representing the event type to listen for.
      See Node.EventType.POSITION_CHANGED for all builtin events.

    • callback: Function

      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: unknown

      The target (this object) to invoke the callback, can be null

    • Optional useCapture: any

      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.

    Returns void

  • Parameters

    • event: EventTouch

    Returns void

  • En

    Register an callback of a specific event type on the Node, the callback will remove itself after the first time it is triggered.

    Zh

    注册节点的特定事件类型回调,回调会在第一时间被触发后删除自身。

    Parameters

    • type: string

      A string representing the event type to listen for.

    • callback: Function

      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: unknown

      The target (this object) to invoke the callback, can be null

    • Optional useCapture: any

    Returns void

  • 启动触摸非窗口区域关闭

    Parameters

    Returns void

  • En

    Pause 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.

    Zh

    暂停所有 SystemEvent 派发的系统事件。 如果传递 recursive 为 true,那么这个 API 将暂停本节点和它的子树上所有节点的节点系统事件。

    Parameters

    • recursive: boolean

      Whether pause system events recursively for the child node tree

    Returns void

  • 根据预制件路径删除,预制件如在队列中也会被删除,如果该预制件存在多个也会一起删除

    Parameters

    • prefabPath: string

      预制路径

    • Optional isDestroy: boolean

      移除后是否释放

    Returns void

  • En

    Removes all children from the container.

    Zh

    移除节点所有的子节点。

    Returns void

  • En

    Removes a child from the container.

    Zh

    移除节点中指定的子节点。

    Parameters

    • child: Node | LayerPopUp

      The child node which will be removed.

    Returns void

  • En

    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.

    Zh

    删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 如果你已经获得组件引用,你也可以直接调用 component.destroy()

    Deprecated

    please destroy the component to remove it.

    Example

    node.removeComponent(Sprite);
    

    Type Parameters

    • T extends Component<T>

    Parameters

    • classConstructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

      The class of the component to remove

    Returns void

  • En

    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.

    Zh

    删除节点上的指定组件,传入参数可以是一个组件构造函数或组件名,也可以是已经获得的组件引用。 如果你已经获得组件引用,你也可以直接调用 component.destroy()

    Deprecated

    please destroy the component to remove it.

    Example

    import { Sprite } from 'cc';
    const sprite = node.getComponent(Sprite);
    if (sprite) {
    node.removeComponent(sprite);
    }
    node.removeComponent('Sprite');

    Parameters

    • classNameOrInstance: string | Component

      The class name of the component to remove or the component instance to be removed

    Returns void

  • En

    Remove itself from its parent node. If the node have no parent, then nothing happens.

    Zh

    从父节点中删除该节点。 如果这个节点是一个孤立节点,那么什么都不会发生。

    Returns void

  • En

    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.

    Zh

    恢复所有 SystemEvent 派发的系统事件。 如果传递 recursive 为 true,那么这个 API 将恢复本节点和它的子树上所有节点的节点系统事件。

    Parameters

    • recursive: boolean

      Whether resume system events recursively for the child node tree

    Returns void

  • En

    Perform a rotation on the node

    Zh

    旋转节点

    Parameters

    • rot: Quat

      The increment on rotation

    • Optional ns: NodeSpace

      The operation coordinate space

    Returns void

  • 设置触摸事件阻挡

    Returns void

  • En

    Set parent of the node.

    Zh

    设置该节点的父节点。

    Parameters

    • value: null | Node

      Parent node

    • Optional keepWorldTransform: boolean

      Whether keep node's current world transform unchanged after this operation

    Returns void

  • En

    Set position in local coordinate system

    Zh

    设置本地坐标

    Parameters

    • position: Readonly<Vec3>

      Target position

    Returns void

  • En

    Set position in local coordinate system

    Zh

    设置本地坐标

    Parameters

    • x: number

      X axis position

    • y: number

      Y axis position

    • Optional z: number

      Z axis position

    Returns void

  • En

    Set local transformation with rotation, position and scale separately.

    Zh

    一次性设置所有局部变换(平移、旋转、缩放)信息

    Parameters

    • Optional rot: Vec3 | Quat

      The rotation

    • Optional pos: Vec3

      The position

    • Optional scale: Vec3

      The scale

    Returns void

  • En

    Set rotation in local coordinate system with a quaternion representing the rotation. Please make sure the rotation is normalized.

    Zh

    用四元数设置本地旋转, 请确保设置的四元数已归一化。

    Parameters

    • rotation: Readonly<Quat>

      Rotation in quaternion

    Returns void

  • En

    Set rotation in local coordinate system with a quaternion representing the rotation. Please make sure the rotation is normalized.

    Zh

    用四元数设置本地旋转, 请确保设置的四元数已归一化。

    Parameters

    • x: number

      X value in quaternion

    • y: number

      Y value in quaternion

    • z: number

      Z value in quaternion

    • w: number

      W value in quaternion

    Returns void

  • En

    Set rotation in local coordinate system with a vector representing euler angles

    Zh

    用欧拉角设置本地旋转

    Parameters

    • rotation: Vec3

      Rotation in vector

    Returns void

  • En

    Set rotation in local coordinate system with euler angles

    Zh

    用欧拉角设置本地旋转

    Parameters

    • x: number

      X axis rotation

    • y: number

      Y axis rotation

    • Optional zOpt: number

    Returns void

  • En

    Set scale in local coordinate system

    Zh

    设置本地缩放

    Parameters

    • scale: Readonly<Vec3>

      Target scale

    Returns void

  • En

    Set scale in local coordinate system

    Zh

    设置本地缩放

    Parameters

    • x: number

      X axis scale

    • y: number

      Y axis scale

    • Optional z: number

      Z axis scale

    Returns void

  • En

    Set the sibling index of the current node in its parent's children array.

    Zh

    设置当前节点在父节点的 children 数组中的位置。

    Parameters

    • index: number

    Returns void

  • En

    Set position in world coordinate system

    Zh

    设置世界坐标

    Parameters

    • position: Vec3

      Target position

    Returns void

  • En

    Set position in world coordinate system

    Zh

    设置世界坐标

    Parameters

    • x: number

      X axis position

    • y: number

      Y axis position

    • z: number

      Z axis position

    Returns void

  • En

    Set rotation in world coordinate system with a quaternion representing the rotation

    Zh

    用四元数设置世界坐标系下的旋转

    Parameters

    • rotation: Quat

      Rotation in quaternion

    Returns void

  • En

    Set rotation in world coordinate system with a quaternion representing the rotation

    Zh

    用四元数设置世界坐标系下的旋转

    Parameters

    • x: number

      X value in quaternion

    • y: number

      Y value in quaternion

    • z: number

      Z value in quaternion

    • w: number

      W value in quaternion

    Returns void

  • En

    Set rotation in world coordinate system with euler angles

    Zh

    用欧拉角设置世界坐标系下的旋转

    Parameters

    • x: number

      X axis rotation

    • y: number

      Y axis rotation

    • z: number

      Z axis rotation

    Returns void

  • En

    Set scale in world coordinate system

    Zh

    设置世界坐标系下的缩放

    Parameters

    • scale: Vec3

      Target scale

    Returns void

  • En

    Set scale in world coordinate system

    Zh

    设置世界坐标系下的缩放

    Parameters

    • x: number

      X axis scale

    • y: number

      Y axis scale

    • z: number

      Z axis scale

    Returns void

  • 创建界面节点

    Parameters

    Returns void

  • En

    Removes all callbacks previously registered with the same target.

    Zh

    移除目标上的所有注册事件。

    Parameters

    • target: unknown

      The target to be searched for all related callbacks

    Returns void

  • En

    Perform a translation on the node

    Zh

    移动节点

    Parameters

    • trans: Vec3

      The increment on position

    • Optional ns: NodeSpace

      The operation coordinate space

    Returns void

  • En

    Update the world transform information if outdated

    Zh

    更新节点的世界变换信息

    Returns void

  • En

    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.

    Zh

    遍历该节点的子树里的所有节点并按规则执行回调函数。 对子树中的所有节点,包含当前节点,会执行两次回调,preFunc 会在访问它的子节点之前调用,postFunc 会在访问所有子节点之后调用。 这个函数的实现不是基于递归的,而是基于栈展开递归的方式。 请不要在 walk 过程中对任何其他的节点嵌套执行 walk。

    Example

    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');
    });

    Parameters

    • preFunc: ((target: LayerPopUp) => void)

      The callback to process node when reach the node for the first time

    • Optional postFunc: ((target: LayerPopUp) => void)

      The callback to process node when re-visit the node after walked all children in its sub tree

    Returns void

  • Returns void

  • Type Parameters

    • T extends Component<T>

    Parameters

    • children: Node[]
    • constructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

    Returns null | T

  • Parameters

    • children: Node[]
    • constructor: any
    • components: any

    Returns void

  • Type Parameters

    • T extends Component<T>

    Parameters

    • node: Node
    • constructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>

    Returns null | T

  • Type Parameters

    • T extends Component<T>

    Parameters

    • node: Node
    • constructor: __types_globals__Constructor<T> | __types_globals__AbstractedConstructor<T>
    • components: Component[]

    Returns void

  • Internal

    Call _updateScene of specified node.

    Parameters

    • node: Node

      The node.

    Returns void

  • En

    clear node array

    Zh

    清除节点数组

    Returns void

  • En

    Determine whether the given object is a normal Node. Will return false if Scene given.

    Zh

    指定对象是否是普通的节点?如果传入 Scene 会返回 false。

    Parameters

    • obj: unknown

    Returns obj is Node

  • En

    clear all node dirty state.

    Zh

    清除所有节点的脏标记。

    Returns void

Generated using TypeDoc