Node
Description:
Class used for building a hierarchical tree structure of game objects.
Class Object: Node Class.
Inherits from: Object.
order
Type: Field.
Description:
The order of the node in the parent's children array.
Signature:
order: integer
angle
Type: Field.
Description:
The rotation angle of the node in degrees.
Signature:
angle: number
angleX
Type: Field.
Description:
The X-axis rotation angle of the node in degrees.
Signature:
angleX: number
angleY
Type: Field.
Description:
The Y-axis rotation angle of the node in degrees.
Signature:
angleY: number
scaleX
Type: Field.
Description:
The X-axis scale factor of the node.
Signature:
scaleX: number
scaleY
Type: Field.
Description:
The Y-axis scale factor of the node.
Signature:
scaleY: number
x
Type: Field.
Description:
The X-axis position of the node.
Signature:
x: number
y
Type: Field.
Description:
The Y-axis position of the node.
Signature:
y: number
z
Type: Field.
Description:
The Z-axis position of the node.
Signature:
z: number
position
Type: Field.
Description:
The position of the node as a Vec2 object.
Signature:
position: Vec2
skewX
Type: Field.
Description:
The X-axis skew angle of the node in degrees.
Signature:
skewX: number
skewY
Type: Field.
Description:
The Y-axis skew angle of the node in degrees.
Signature:
skewY: number
visible
Type: Field.
Description:
Whether the node is visible.
Signature:
visible: boolean
anchor
Type: Field.
Description:
The anchor point of the node as a Vec2 object.
Signature:
anchor: Vec2
width
Type: Field.
Description:
The width of the node.
Signature:
width: number
height
Type: Field.
Description:
The height of the node.
Signature:
height: number
size
Type: Field.
Description:
The size of the node as a Size object.
Signature:
size: Size
tag
Type: Field.
Description:
The tag of the node as a string.
Signature:
tag: string
opacity
Type: Field.
Description:
The opacity of the node, should be 0 to 1.0.
Signature:
opacity: number
color
Type: Field.
Description:
The color of the node as a Color object.
Signature:
color: Color
color3
Type: Field.
Description:
The color of the node as a Color3 object.
Signature:
color3: Color3
passOpacity
Type: Field.
Description:
Whether to pass the opacity value to child nodes.
Signature:
passOpacity: boolean
passColor3
Type: Field.
Description:
Whether to pass the color value to child nodes.
Signature:
passColor3: boolean
transformTarget
Type: Field.
Description:
The target node acts as a parent node for transforming this node.
Signature:
transformTarget: Node
scheduler
Type: Field.
Description:
The scheduler used for scheduling update and action callbacks.
Signature:
scheduler: Scheduler
hasChildren
Type: Readonly Field.
Description:
Whether the node has children.
Signature:
const hasChildren: boolean
children
Type: Readonly Field.
Description:
The children of the node as an Array object, could be nil.
Signature:
const children: Array
parent
Type: Readonly Field.
Description:
The parent node of the node.
Signature:
const parent: Node
running
Type: Readonly Field.
Description:
Whether the node is currently running in a scene tree.
Signature:
const running: boolean
scheduled
Type: Readonly Field.
Description:
Whether the node is currently scheduling a function or a coroutine for updates.
Signature:
const scheduled: boolean
actionCount
Type: Readonly Field.
Description:
The number of actions currently running on the node.
Signature:
const actionCount: integer
data
Type: Readonly Field.
Description:
Additional data stored on the node as a Dictionary object.
Signature:
const data: Dictionary
touchEnabled
Type: Field.
Description:
Whether touch events are enabled on the node.
Signature:
touchEnabled: boolean
swallowTouches
Type: Field.
Description:
Whether the node should swallow touch events.
Signature:
swallowTouches: boolean
swallowMouseWheel
Type: Field.
Description:
Whether the node should swallow mouse wheel events.
Signature:
swallowMouseWheel: boolean
keyboardEnabled
Type: Field.
Description:
Whether keyboard events are enabled on the node.
Signature:
keyboardEnabled: boolean
controllerEnabled
Type: Field.
Description:
Whether controller events are enabled on the node.
Signature:
controllerEnabled: boolean
renderGroup
Type: Field.
Description:
Whether to group the node's rendering with all its recursive children.
Signature:
renderGroup: boolean
showDebug
Type: Field.
Description:
Whether debug graphic should be displayed for the node.
Signature:
showDebug: boolean
renderOrder
Type: Field.
Description:
The rendering order number for group rendering. Nodes with lower rendering orders are rendered earlier.
Signature:
renderOrder: integer
addChild
Type: Function.
Description:
Adds a child node to the current node.
Signature:
addChild: function(
self: Node,
child: Node,
order?: integer --[[0]],
tag?: string --[[""]]
)
Parameters:
Parameter | Type | Description |
---|---|---|
child | Node | The child node to add. |
order | integer | [optional] The drawing order of the child node. Default is 0. |
tag | string | [optional] The tag of the child node. Default is an empty string. |
addTo
Type: Function.
Description:
Adds the current node to a parent node.
Signature:
addTo: function(
self: Node,
parent: Node,
order?: integer --[[0]],
tag?: string --[[""]]
): Node
Parameters:
Parameter | Type | Description |
---|---|---|
parent | Node | The parent node to add the current node to. |
order | integer | [optional] The drawing order of the current node. Default is 0. |
tag | string | [optional] The tag of the current node. Default is an empty string. |
Returns:
Return Type | Description |
---|---|
Node | The current node. |
removeChild
Type: Function.
Description:
Removes a child node from the current node.
Signature:
removeChild: function(
self: Node,
child: Node,
cleanup?: boolean --[[true]]
)
Parameters:
Parameter | Type | Description |
---|---|---|
child | Node | The child node to remove. |
cleanup | boolean | [optional] Whether to cleanup the child node. Default is true. |
removeChildByTag
Type: Function.
Description:
Removes a child node from the current node by tag.
Signature:
removeChildByTag: function(
self: Node,
tag: string,
cleanup?: boolean --[[true]]
)
Parameters:
Parameter | Type | Description |
---|---|---|
tag | string | The tag of the child node to remove. |
cleanup | boolean | [optional] Whether to cleanup the child node. Default is true. |
removeAllChildren
Type: Function.
Description:
Removes all child nodes from the current node.
Signature:
removeAllChildren: function(
self: Node,
cleanup?: boolean --[[true]]
)
Parameters:
Parameter | Type | Description |
---|---|---|
cleanup | boolean | [optional] Whether to cleanup the child nodes. Default is true. |
removeFromParent
Type: Function.
Description:
Removes the current node from its parent node.
Signature:
removeFromParent: function(
self: Node,
cleanup?: boolean --[[true]]
)
Parameters:
Parameter | Type | Description |
---|---|---|
cleanup | boolean | [optional] Whether to cleanup the current node. Default is true. |
moveToParent
Type: Function.
Description:
Moves the current node to a new parent node without triggering node events.
Signature:
moveToParent: function(self: Node, parent: Node)
Parameters:
Parameter | Type | Description |
---|---|---|
parent | Node | The new parent node to move the current node to. |
cleanup
Type: Function.
Description:
Cleans up the current node.
Signature:
cleanup: function(self: Node)
getChildByTag
Type: Function.
Description:
Gets a child node by tag.
Signature:
getChildByTag: function(self: Node, tag: string): Node
Parameters:
Parameter | Type | Description |
---|---|---|
tag | string | The tag of the child node to get. |
Returns:
Return Type | Description |
---|---|
Node | The child node, or nil if not found. |
schedule
Type: Function.
Description:
Schedules a main function to run every frame. Call this function again to replace the previous scheduled main function or coroutine.
Signature:
schedule: function(self: Node, func: function(number): boolean)
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The main function to run, returns true to stop. |
schedule
Type: Function.
Description:
Schedules a main coroutine to run. Call this function again to replace the previous scheduled main function or coroutine.
Signature:
schedule: function(self: Node, job: Routine.Job)
Parameters:
Parameter | Type | Description |
---|---|---|
job | Routine.Job | The main coroutine to run, return or yield true to stop. |
unschedule
Type: Function.
Description:
Unschedules the current node's scheduled main function or coroutine.
Signature:
unschedule: function(self: Node)
once
Type: Function.
Description:
Schedules a function that runs in a coroutine once. Call this function to replace the previous scheduled main function or coroutine.
Signature:
once: function(self: Node, func: function())
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to run once. |
loop
Type: Function.
Description:
Schedules a function that runs in a coroutine in a loop. Call this function to replace the previous scheduled main function or coroutine.
Signature:
loop: function(self: Node, func: function(): boolean)
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to run in a loop, returns true to stop. |
convertToNodeSpace
Type: Function.
Description:
Converts a point in world space to node space.
Signature:
convertToNodeSpace: function(self: Node, worldPoint: Vec2): Vec2
Parameters:
Parameter | Type | Description |
---|---|---|
worldPoint | Vec2 | The point to convert. |
Returns:
Return Type | Description |
---|---|
Vec2 | The converted point. |
convertToNodeSpace
Type: Function.
Description:
Converts a point in world space to node space.
Signature:
convertToNodeSpace: function(self: Node, worldPoint: Vec2, z: number): Vec2, number
Parameters:
Parameter | Type | Description |
---|---|---|
worldPoint | Vec2 | The point to convert. |
z | number | The z-coordinate of the point. |
Returns:
Return Type | Description |
---|---|
Vec2 | The converted point. |
number | The converted z-coordinate. |
convertToWorldSpace
Type: Function.
Description:
Converts a point from node space to world space.
Signature:
convertToWorldSpace: function(self: Node, nodePoint: Vec2): Vec2
Parameters:
Parameter | Type | Description |
---|---|---|
nodePoint | Vec2 | The point in node space. |
Returns:
Return Type | Description |
---|---|
Vec2 | The converted point in world space. |
convertToWorldSpace
Type: Function.
Description:
Converts a point from node space to world space.
Signature:
convertToWorldSpace: function(self: Node, nodePoint: Vec2, z: number): Vec2, number
Parameters:
Parameter | Type | Description |
---|---|---|
nodePoint | Vec2 | The point in node space. |
z | number | The z coordinate in node space. |
Returns:
Return Type | Description |
---|---|
Vec2 | The converted point in world space. |
number | The converted z coordinate in world space . |
convertToWindowSpace
Type: Function.
Description:
Converts a point from node space to window space.
Signature:
convertToWindowSpace: function(self: Node, nodePoint: Vec2, callback: function(Vec2))
Parameters:
Parameter | Type | Description |
---|---|---|
nodePoint | Vec2 | The point in node space. |
callback | function | The callback function to receive the converted point in window space. |
eachChild
Type: Function.
Description:
Calls the given function for each child node of this node.
Signature:
eachChild: function(self: Node, func: function(Node): boolean): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to call for each child node. The function should return a boolean value indicating whether to continue the iteration. Return true to stop iteration. |
Returns:
Return Type | Description |
---|---|
boolean | False if all children have been visited, true if the iteration was interrupted by the function. |
traverse
Type: Function.
Description:
Traverses the node hierarchy starting from this node and calls the given function for each visited node. The nodes without TraverseEnabled
flag are not visited.
Signature:
traverse: function(self: Node, func: function(Node): boolean): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to call for each visited node. The function should return a boolean value indicating whether to continue the traversal. Return true to stop iteration. |
Returns:
Return Type | Description |
---|---|
boolean | False if all nodes have been visited, true if the traversal was interrupted by the function. |
traverseAll
Type: Function.
Description:
Traverses the entire node hierarchy starting from this node and calls the given function for each visited node.
Signature:
traverseAll: function(self: Node, func: function(Node): boolean): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to call for each visited node. The function should return a boolean value indicating whether to continue the traversal. |
Returns:
Return Type | Description |
---|---|
boolean | True if all nodes have been visited, false if the traversal was interrupted by the function. |
runAction
Type: Function.
Description:
Runs the given action on this node.
Signature:
runAction: function(self: Node, action: Action, loop?: boolean): number
Parameters:
Parameter | Type | Description |
---|---|---|
action | Action | The action to run. |
loop | boolean | [optional] Whether to loop the action. Default is false. |
Returns:
Return Type | Description |
---|---|
number | The duration of the newly running action in seconds. |
runAction
Type: Function.
Description:
Runs an action defined by the given action definition on this node.
Signature:
runAction: function(self: Node, actionDef: ActionDef, loop?: boolean): number
Parameters:
Parameter | Type | Description |
---|---|---|
actionDef | ActionDef | The action definition to run. |
loop | boolean | [optional] Whether to loop the action. Default is false. |
Returns:
Return Type | Description |
---|---|
number | The duration of the newly running action in seconds. |
stopAllActions
Type: Function.
Description:
Stops all actions running on this node.
Signature:
stopAllActions: function(self: Node)
perform
Type: Function.
Description:
Runs the given action immediately without adding it to the action queue.
Signature:
perform: function(self: Node, action: Action, loop?: boolean): number
Parameters:
Parameter | Type | Description |
---|---|---|
action | Action | The action to run. |
loop | boolean | [optional] Whether to loop the action. Default is false. |
Returns:
Return Type | Description |
---|---|
number | The duration of the newly running action. |
perform
Type: Function.
Description:
Runs an action defined by the given action definition right after clear all the previous running actions.
Signature:
perform: function(self: Node, actionDef: ActionDef, loop?: boolean): number
Parameters:
Parameter | Type | Description |
---|---|---|
actionDef | ActionDef | The action definition to run. |
loop | boolean | [optional] Whether to loop the action. Default is false. |
Returns:
Return Type | Description |
---|---|
number | The duration of the newly running action. |
stopAction
Type: Function.
Description:
Stops the given action running on this node.
Signature:
stopAction: function(self: Node, action: Action)
Parameters:
Parameter | Type | Description |
---|---|---|
action | Action | The action to stop. |
alignItemsVertically
Type: Function.
Description:
Vertically aligns all child nodes of this node.
Signature:
alignItemsVertically: function(
self: Node,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
padding | number | [optional] The padding between child nodes. Defaults to 10. |
Returns:
Return Type | Description |
---|---|
Size | The size of the aligned child nodes. |
alignItemsVertically
Type: Function.
Description:
Vertically aligns all child nodes within the node using the given size and padding.
Signature:
alignItemsVertically: function(
self: Node,
size: Size,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
size | Size | The size to use for alignment. |
padding | number | [optional] The amount of padding to use between each child node (default is 10). |
Returns:
Return Type | Description |
---|---|
Size | The size of the node after alignment. |
alignItemsHorizontally
Type: Function.
Description:
Horizontally aligns all child nodes within the node using the given padding.
Signature:
alignItemsHorizontally: function(
self: Node,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
padding | number | [optional] The amount of padding to use between each child node (default is 10). |
Returns:
Return Type | Description |
---|---|
Size | The size of the node after alignment. |
alignItemsHorizontally
Type: Function.
Description:
Horizontally aligns all child nodes within the node using the given size and padding.
Signature:
alignItemsHorizontally: function(
self: Node,
size: Size,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
size | Size | The size to hint for alignment. |
padding | number | [optional] The amount of padding to use between each child node (default is 10). |
Returns:
Return Type | Description |
---|---|
Size | The size of the node after alignment. |
alignItems
Type: Function.
Description:
Aligns all child nodes within the node using the given size and padding.
Signature:
alignItems: function(
self: Node,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
padding | number | [optional] The amount of padding to use between each child node (default is 10). |
Returns:
Return Type | Description |
---|---|
Size | The size of the node after alignment. |
alignItems
Type: Function.
Description:
Aligns all child nodes within the node using the given size and padding.
Signature:
alignItems: function(
self: Node,
size: Size,
padding?: number --[[10]]
): Size
Parameters:
Parameter | Type | Description |
---|---|---|
size | Size | The size to use for alignment. |
padding | number | [optional] The amount of padding to use between each child node (default is 10). |
Returns:
Return Type | Description |
---|---|
Size | The size of the node after alignment. |
moveAndCullItems
Type: Function.
Description:
Moves and changes child nodes' visibility based on their position in parent's area.
Signature:
moveAndCullItems: function(self: Node, delta: Vec2)
Parameters:
Parameter | Type | Description |
---|---|---|
delta | Vec2 | The distance to move its children. |
attachIME
Type: Function.
Description:
Attaches the input method editor (IME) to the node. Makes node recieving "AttachIME", "DetachIME", "TextInput", "TextEditing" events.
Signature:
attachIME: function(self: Node)
detachIME
Type: Function.
Description:
Detaches the input method editor (IME) from the node.
Signature:
detachIME: function(self: Node)
gslot
Type: Function.
Description:
Gets the global event listener associated with the given event name in this node.
Signature:
gslot: function(self: Node, eventName: string): {GSlot}
Parameters:
Parameter | Type | Description |
---|---|---|
eventName | string | The name of the global event. |
Returns:
Return Type | Description |
---|---|
{GSlot} | All the global event listeners associated with the event. |
gslot
Type: Function.
Description:
Associates the given event handler function with a global event.
Signature:
gslot: function(self: Node, eventName: string, handler: function()): GSlot
Parameters:
Parameter | Type | Description |
---|---|---|
eventName | string | The name of the global event. |
handler | function | The handler function to associate with the event. |
Returns:
Return Type | Description |
---|---|
GSlot | The global event listener associated with the event in this node. |
slot
Type: Function.
Description:
Gets the node event listener associated with the given node event name.
Signature:
slot: function(self: Node, eventName: string): Slot
Parameters:
Parameter | Type | Description |
---|---|---|
eventName | string | The name of the node event. |
Returns:
Return Type | Description |
---|---|
Slot | The node event listener associated with the node event. |
slot
Type: Function.
Description:
Associates the given handler function with the node event.
Signature:
slot: function(self: Node, eventName: string, handler: function())
Parameters:
Parameter | Type | Description |
---|---|---|
eventName | string | The name of the node event. |
handler | function | The handler function to associate with the node event. |
emit
Type: Function.
Description:
Emits a node event with a given event name and arguments.
Signature:
emit: function(self: Node, eventName: string, ...: any)
Parameters:
Parameter | Type | Description |
---|---|---|
eventName | string | The name of the node event. |
... | ...any | The arguments to pass to the node event handler functions. |
grab
Type: Function.
Description:
Creates or removes a texture grabber for the specified node.
Signature:
grab: function(
self: Node,
enabled?: boolean --[[true]]
): Grabber
Parameters:
Parameter | Type | Description |
---|---|---|
enabled | boolean | [optional] Whether to enable or disable the grabber. Default is true. |
Returns:
Return Type | Description |
---|---|
Grabber | A Grabber object with gridX == 1 and gridY == 1 when enabled. |
grab
Type: Function.
Description:
Creates a texture grabber for the specified node with a specified grid size.
Signature:
grab: function(self: Node, gridX: number, gridY: number): Grabber
Parameters:
Parameter | Type | Description |
---|---|---|
gridX | number | The number of horizontal grid cells to divide the grabber into. |
gridY | number | The number of vertical grid cells to divide the grabber into. |
Returns:
Return Type | Description |
---|---|
Grabber | A Grabber object. |
onUpdate
Type: Function.
Description:
Schedules a function to run every frame. Call this function again to schedule multiple functions.
Signature:
onUpdate: function(self: Node, func: function(number): boolean)
Parameters:
Parameter | Type | Description |
---|---|---|
func | function | The function to run every frame, returns true to stop. |
onUpdate
Type: Function.
Description: