Core. Node

Node Class is the base class of all objects that can be placed in the display list. The display list manages all objects displayed in the Laya runtime. Use Node Class displays the display objects in the list. Node objects can have child display objects.

Constructor

new Node()

Extends

Member

(static) ARRAY_EMPTY :Array

destroyed :Boolean

[只读] Has it been destroyed?. Object cannot be used after destruction.

displayedInStage :Boolean

Indicates whether it is displayed in the display list.

name :String

Node name.
Default Value:
  • ""

numChildren :int

Number of child objects.

parent :Node

Parent node.

timer :Timer

The time controller defaults to global Laya.timer. You can also separate instances of a Timer to control time scaling

Methods

_setParent()

addChild(node) → {Node}

Adding child nodes.
Parameters:
Name Type Description
node Node Node object
Returns:
Type:
Node
Returns the node added

addChildAt(node, index) → {Node}

Adds a child node to the specified index location.
Parameters:
Name Type Description
node Node Node object.
index int Index location.
Returns:
Type:
Node
Returns the node added.

addChildren()

Adding child nodes in batches
Parameters:
Name Type Attributes Description
...args Rest <repeatable>
Innumerable child nodes.

clearTimer(caller, method)

Clean timer. Function same as Laya.timer.clearTimer ().
Parameters:
Name Type Description
caller Object Execute domain (this).
method function Callback method at the end.

contains(node) → {Boolean}

Does the current container contain the specified? Node Node object.
Parameters:
Name Type Description
node Node Designated Node Node object.
Returns:
Type:
Boolean
A Boolean value indicating whether the specified Node node object is included.

destroy(destroyChild)

Destroy this object. The destroy object defaults to removing itself from the parent node and cleaning its reference relationship and waiting for the JS automatic garbage recovery mechanism to be recycled. No more can be used after destroy.

Destroy removes its own event listening, its own timer listening, removing the child object and removing itself from the parent node.

Parameters:
Name Type Description
destroyChild Boolean (optional) destroy the child node at the same time. If the value is true, the child node is destroyed, otherwise the child node is not destroyed.

destroyChildren()

Destroy all child objects without destroying themselves.

event(type, dataopt) → {Boolean}

Dispatch events.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String Event type.
data Object <optional>
null data (optional) callback data. Be careful: If you need to pass multiple parameters, P1, P2, P3, you can use the array structure, such as: [p1,p2,p3,...] If you need to call a single parameter P, and P is an array, you need to use a structure such as: [p] Other single parameters, P, can be passed directly to the parameter P.
Returns:
Type:
Boolean
Is there a listener for this event type? If there is a listener, the value is true, otherwise the value is false.

frameLoop(delay, caller, method, argsopt, coverBefore)

Executes a function repeatedly (based on frame rate). Function same as Laya.timer.frameLoop ().
Parameters:
Name Type Attributes Default Description
delay int How many frames (frames per frame) are spaced?.
caller Object Execute domain (this).
method function Callback method at the end.
args Array <optional>
null args Optional callback parameters.
coverBefore Boolean (optional) whether the delay is covered before default is true.

frameOnce(delay, caller, method, argsopt, coverBefore)

Perform a function at a certain time (based on frame rate). Function same as Laya.timer.frameOnce ().
Parameters:
Name Type Attributes Default Description
delay int Delays several frames (frames per unit).
caller Object Execute domain (this)
method function Callback method at the end
args Array <optional>
null args Optional callback parameters
coverBefore Boolean (optional) whether the delay is covered before default is true

getChildAt(index) → {Node}

Gets the child node object based on the index position of the child node.
Parameters:
Name Type Description
index int Index location
Returns:
Type:
Node
Child node

getChildByName(name) → {Node}

Gets the child node object based on the name of the child node.
Parameters:
Name Type Description
name String Child node name.
Returns:
Type:
Node
Node object.

getChildIndex(node) → {int}

Gets the index position of the child node based on the child node object.
Parameters:
Name Type Description
node Node Child node.
Returns:
Type:
int
The index position at which the child node is located.

hasListener(type) → {Boolean}

inspect EventDispatcher Object registers any listeners for a particular event type.
Inherited From:
Parameters:
Name Type Description
type String Event type.
Returns:
Type:
Boolean
If the specified type of listener has been registered, the value is true; otherwise, the value is false.

isMouseEvent(type) → {Boolean}

Detects whether the specified event type is a mouse event.
Inherited From:
Parameters:
Name Type Description
type String Event type.
Returns:
Type:
Boolean
If it is a mouse event, the value is true; otherwise, the value is false.

off(type, caller, listener, onceOnly) → {EventDispatcher}

from EventDispatcher Delete listeners in object.
Inherited From:
Parameters:
Name Type Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
onceOnly Boolean (optional) if the value is true, only the listeners added by the once method are removed.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

offAll(typeopt) → {EventDispatcher}

from EventDispatcher Removes all listeners that specify the type of event in the object.
Inherited From:
Parameters:
Name Type Attributes Default Description
type String <optional>
null type (optional) event type. If the value is null, all types of listeners for this object are removed.
Returns:
Type:
EventDispatcher
this EventDispatcher Object.

on(type, caller, listener, argsopt) → {EventDispatcher}

Adds an event listener to enable listeners to receive event notifications.

If you listen to mouse events, you automatically set the property of your own and father nodes. The value of mouseEnabled is true (if the parent node is mouseEnabled=false, then stop setting the parent node mouseEnabled attribute).

Overrides:
Parameters:
Name Type Attributes Default Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
args Array <optional>
null args Optional callback parameters for the event listener function.
Returns:
Type:
EventDispatcher
This EventDispatcher object.

once(type, caller, listener, argsopt) → {EventDispatcher}

Adds an event listener to enable listeners to receive event notifications that automatically remove listeners after the listener event responds.

If you listen to mouse events, you automatically set the property of your own and father nodes. The value of mouseEnabled is true (if the parent node is mouseEnabled=false, then stop setting the parent node mouseEnabled attribute).

Overrides:
Parameters:
Name Type Attributes Default Description
type String Event type.
caller Object The domain of the event listener function.
listener function Event listener function.
args Array <optional>
null args Optional callback parameters for the event listener function.
Returns:
Type:
EventDispatcher
This EventDispatcher object.

removeChild(node) → {Node}

Delete child node.
Parameters:
Name Type Description
node Node Child node
Returns:
Type:
Node
Deleted nodes

removeChildAt(index) → {Node}

Deletes the corresponding child node object according to the index location of the child node.
Parameters:
Name Type Description
index int Node index location.
Returns:
Type:
Node
Deleted nodes.

removeChildByName(name) → {Node}

Deletes the corresponding child node object based on the child node name and, if not found, does not throw an exception.
Parameters:
Name Type Description
name String Object name.
Returns:
Type:
Node
Node found ( Node Objects.

removeChildren(beginIndexopt, endIndexopt) → {Node}

Removes all child objects from the specified index interval.
Parameters:
Name Type Attributes Default Description
beginIndex int <optional>
0 beginIndex Start index.
endIndex int <optional>
0x7fffffff endIndex End index.
Returns:
Type:
Node
Current node object.

removeSelf() → {Node}

Remove yourself from the parent container. If you have been deleted, no exception will be thrown.
Returns:
Type:
Node
Current node ( Node Objects.

replaceChild(newNode, oldNode) → {Node}

Replace child node.
Parameters:
Name Type Description
newNode Node New node.
oldNode Node Old node.
Returns:
Type:
Node
Return new node.

setChildIndex(node, index) → {Node}

Sets the index position of the child node.
Parameters:
Name Type Description
node Node Child node.
index int New index.
Returns:
Type:
Node
Returns the child node itself.

timerLoop(delay, caller, method, argsopt, coverBefore, jumpFrame)

Execute a function repeatedly at regular intervals. Function same as Laya.timer.timerLoop ().
Parameters:
Name Type Attributes Default Description
delay int Interval time (ms per unit).
caller Object Execute domain (this).
method function Callback method at the end.
args Array <optional>
null args Optional callback parameters.
coverBefore Boolean (optional) whether the delay is covered before default is true.
jumpFrame Boolean The clock is skipping. Time based callback, in the unit time interval, if you can perform multiple callbacks, for performance reasons, the engine defaults to only once. After setting the jumpFrame=true, the callback is executed several times in succession

timerOnce(delay, caller, method, argsopt, coverBefore)

Execute a function at regular intervals. Function same as Laya.timer.timerOnce ().
Parameters:
Name Type Attributes Default Description
delay int Delay time (in milliseconds).
caller Object Execute domain (this).
method function Callback method at the end.
args Array <optional>
null args Optional callback parameters.
coverBefore Boolean (optional) whether the delay is covered before default is true.

Event

added

See:
  • events.Event

display

See:
  • events.Event

removed

See:
  • events.Event

undisplay

See:
  • events.Event