Per-scene level rendering info
Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
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.
Refer to Node.eulerAngles
The event processor of the current node, it provides EventTarget ability.
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.
Name of node.
Name of node.
The parent node
The parent node
Refer to Node.position
The renderer scene, normally user don't need to use it
Refer to Node.rotation
Refer to Node.scale
Which scene this node belongs to.
The uuid for editor, will be stripped after building project.
Refer to Node.worldMatrix
Refer to Node.worldPosition
Refer to Node.worldRotation
Refer to Node.worldScale
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; } } }
Add a child to the current node.
the child node to be added
Only for compatibility purpose, user should not add any component to the scene
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 the current scene and all its nodes, this action won't destroy related assets
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.
Refer to Node.getPosition
Refer to Node.getRotation
Refer to Node.getScale
Get the sibling index of the current node in its parent's children array.
Refer to Node.getWorldMatrix
Refer to Node.getWorldPosition
Refer to Node.getWorldRS
Refer to Node.getWorldRT
Refer to Node.getWorldRotation
Refer to Node.getWorldScale
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
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.stopPropagationImmediate()
.
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/EventType/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
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.
Set parent of the node.
Set the sibling index of the current node in its parent's children array.
Removes all callbacks previously registered with the same target.
The target to be searched for all related callbacks
Refer to Node.updateWorldTransform
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
Call _updateScene
of specified node.
The node.
Generated using TypeDoc
Scene is a subclass of BaseNode, composed by nodes, representing the root of a runnable environment in the game. It's managed by Director and user can switch from a scene to another using Director.loadScene