Event types emitted by Node
Coordinates space
Bit masks for Node transformation parts, can be used to determine which part changed in SystemEventType.TRANSFORM_CHANGED event
Bit masks for Node transformation parts
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.
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.
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.
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.
Indicates whether this node is active in the scene.
All children nodes.
Gets all components attached to this node.
Rotation in local coordinate system, represented by euler angles
Rotation in local coordinate system, represented by euler angles
The event processor of the current node, it provides EventTarget ability.
Whether the node's transformation have changed during the current frame.
Whether the node's transformation have changed during the current frame.
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.
Local transformation matrix
Name of node.
Name of node.
The parent node
The parent node
Which scene this node belongs to.
The uuid for editor, will be stripped after building project.
World transformation matrix
Ensures that this node has already had the specified component(s). If not, this method throws.
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. 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; } } }
Adds a component class to the node. You can also add component to node by passing in the name of the script.
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.
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.
Properties to be set to node
Destroy all children from the node, and release all their own references to other objects. Actual destruct operation will delayed until before rendering.
Dispatches an event into the event flow. The event target is the EventTarget object upon which the dispatchEvent() method is called.
The Event object that is dispatched into the event flow
Trigger an event directly with the event name and necessary arguments.
event type
First argument in callback
Second argument in callback
Third argument in callback
Fourth argument in callback
Returns a child with the same name.
A name to find the child node.
a CCNode object whose name equals to the input parameter
Returns a child with the given path.
A path to find the child node.
a Node object whose path equals to the input parameter
Returns a child with the same uuid.
The uuid to find the child node.
a Node whose uuid equals to the input parameter
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.
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.
The class name of the target component
Returns the component of given type in any of its children using depth first search.
The class of the target component
Returns the component of given type in any of its children using depth first search.
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.
The class of the target component
Returns all components of given type in self or any of its children.
The class name of the target component
Get parent of the node.
Get the sibling index of the current node in its parent's children array.
Checks whether the EventTarget object has any callback registered for a specific type of event.
The type of event.
The callback function of the event listener, if absent all event listeners for the given type will be removed
The callback callee of the event listener
True if a callback of the specified type is registered; false otherwise.
Inserts a child to the node at a specified index.
the child node to be inserted
the sibling index to place the child in
Invalidate the world transform information for this node and all its children recursively
The dirty bits to setup to children, can be composed with multiple dirty bits
Is this node a child of the given node?
True if this node is a child, deep child or identical to the given node.
Removes the callback previously registered with the same type, callback, target and or useCapture. This method is merely an alias to removeEventListener.
A string representing the event type being removed.
The callback to remove.
The target (this object) to invoke the callback, if it's not given, only callback without target will be removed
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.
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:
_getCapturingTargets
), e.g. parents in node tree, from root to the real target_getBubblingTargets
), 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.stopPropagationImmidiate()
.
It's the recommended way to register touch/mouse event for Node,
please do not use eventManager
directly for Node.
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
.A string representing the event type to listen for.
See {{#crossLink "Node/EventTyupe/POSITION_CHANGED"}}Node Events{{/crossLink}} 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).
The target (this object) to invoke the callback, can be null
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.
Register 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).
The target (this object) to invoke the callback, can be null
Pause all system events which is dispatched by SystemEvent
Whether pause system events recursively for the child node tree
Removes all children from the container.
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.
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.
The class name of the component to remove or the component instance to be removed
Remove itself from its parent node. If the node have no parent, then nothing happens.
Resume all paused system events which is dispatched by SystemEvent
Whether resume system events recursively for the child node tree
Set parent of the node.
Parent node
Whether keep node's current world transform unchanged after this operation
Set position in local coordinate system
Target position
Set position in local coordinate system
X axis position
Y axis position
Z axis position
Set rotation in local coordinate system with a quaternion representing the rotation
Rotation in quaternion
Set rotation in local 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 rotation in local coordinate system with euler angles
X axis rotation
Y axis rotation
Z axis rotation
Set scale in local coordinate system
Target scale
Set scale in local coordinate system
X axis scale
Y axis scale
Z axis scale
Set the sibling index of the current node in its parent's children array.
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 rotation in world coordinate system with euler angles
X axis rotation
Y axis rotation
Z axis rotation
Set scale in world coordinate system
Target scale
Set scale in world coordinate system
X axis scale
Y axis scale
Z axis scale
Removes all callbacks previously registered with the same target.
The target to be searched for all related callbacks
Update the world transform information if outdated
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.
The callback to process node when reach the node for the first time
The callback to process node when re-visit the node after walked all children in its sub tree
Determine whether the given object is a normal Node. Will return false if Scene given.
Generated using TypeDoc
Class of private entities in Cocos Creator 3d scenes.
The PrivateNode is hidden in editor, and completely transparent to users.
It's normally used as Node's private content created by components in parent node.
So in theory private nodes are not children, they are part of the parent node.
Private node have two important characteristics:
In this way, they can be easily kept inside the bounding box.
Currently, it's used by RichText component and TileMap component.