Skip to main content

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:

ParameterTypeDescription
childNodeThe child node to add.
orderinteger[optional] The drawing order of the child node. Default is 0.
tagstring[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:

ParameterTypeDescription
parentNodeThe parent node to add the current node to.
orderinteger[optional] The drawing order of the current node. Default is 0.
tagstring[optional] The tag of the current node. Default is an empty string.

Returns:

Return TypeDescription
NodeThe 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:

ParameterTypeDescription
childNodeThe child node to remove.
cleanupboolean[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:

ParameterTypeDescription
tagstringThe tag of the child node to remove.
cleanupboolean[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:

ParameterTypeDescription
cleanupboolean[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:

ParameterTypeDescription
cleanupboolean[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:

ParameterTypeDescription
parentNodeThe 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:

ParameterTypeDescription
tagstringThe tag of the child node to get.

Returns:

Return TypeDescription
NodeThe 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:

ParameterTypeDescription
funcfunctionThe 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:

ParameterTypeDescription
jobRoutine.JobThe 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:

ParameterTypeDescription
funcfunctionThe 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:

ParameterTypeDescription
funcfunctionThe 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:

ParameterTypeDescription
worldPointVec2The point to convert.

Returns:

Return TypeDescription
Vec2The 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:

ParameterTypeDescription
worldPointVec2The point to convert.
znumberThe z-coordinate of the point.

Returns:

Return TypeDescription
Vec2The converted point.
numberThe 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:

ParameterTypeDescription
nodePointVec2The point in node space.

Returns:

Return TypeDescription
Vec2The 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:

ParameterTypeDescription
nodePointVec2The point in node space.
znumberThe z coordinate in node space.

Returns:

Return TypeDescription
Vec2The converted point in world space.
numberThe 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:

ParameterTypeDescription
nodePointVec2The point in node space.
callbackfunctionThe 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:

ParameterTypeDescription
funcfunctionThe 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 TypeDescription
booleanFalse 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:

ParameterTypeDescription
funcfunctionThe 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 TypeDescription
booleanFalse 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:

ParameterTypeDescription
funcfunctionThe function to call for each visited node. The function should return a boolean value indicating whether to continue the traversal.

Returns:

Return TypeDescription
booleanTrue 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:

ParameterTypeDescription
actionActionThe action to run.
loopboolean[optional] Whether to loop the action. Default is false.

Returns:

Return TypeDescription
numberThe 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:

ParameterTypeDescription
actionDefActionDefThe action definition to run.
loopboolean[optional] Whether to loop the action. Default is false.

Returns:

Return TypeDescription
numberThe 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:

ParameterTypeDescription
actionActionThe action to run.
loopboolean[optional] Whether to loop the action. Default is false.

Returns:

Return TypeDescription
numberThe 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:

ParameterTypeDescription
actionDefActionDefThe action definition to run.
loopboolean[optional] Whether to loop the action. Default is false.

Returns:

Return TypeDescription
numberThe 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:

ParameterTypeDescription
actionActionThe 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:

ParameterTypeDescription
paddingnumber[optional] The padding between child nodes. Defaults to 10.

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
sizeSizeThe size to use for alignment.
paddingnumber[optional] The amount of padding to use between each child node (default is 10).

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
paddingnumber[optional] The amount of padding to use between each child node (default is 10).

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
sizeSizeThe size to hint for alignment.
paddingnumber[optional] The amount of padding to use between each child node (default is 10).

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
paddingnumber[optional] The amount of padding to use between each child node (default is 10).

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
sizeSizeThe size to use for alignment.
paddingnumber[optional] The amount of padding to use between each child node (default is 10).

Returns:

Return TypeDescription
SizeThe 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:

ParameterTypeDescription
deltaVec2The 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:

ParameterTypeDescription
eventNamestringThe name of the global event.

Returns:

Return TypeDescription
{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:

ParameterTypeDescription
eventNamestringThe name of the global event.
handlerfunctionThe handler function to associate with the event.

Returns:

Return TypeDescription
GSlotThe 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:

ParameterTypeDescription
eventNamestringThe name of the node event.

Returns:

Return TypeDescription
SlotThe 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:

ParameterTypeDescription
eventNamestringThe name of the node event.
handlerfunctionThe 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:

ParameterTypeDescription
eventNamestringThe name of the node event.
......anyThe 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:

ParameterTypeDescription
enabledboolean[optional] Whether to enable or disable the grabber. Default is true.

Returns:

Return TypeDescription
GrabberA 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:

ParameterTypeDescription
gridXnumberThe number of horizontal grid cells to divide the grabber into.
gridYnumberThe number of vertical grid cells to divide the grabber into.

Returns:

Return TypeDescription
GrabberA 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:

ParameterTypeDescription
funcfunctionThe function to run every frame, returns true to stop.

onUpdate

Type: Function.

Description:

  Schedules a coroutine to run every frame. Call this function again to schedule multiple coroutines.

Signature:

onUpdate: function(self: Node, job: Routine.Job)

Parameters:

ParameterTypeDescription
jobRoutine.JobThe coroutine to run every frame.

onActionEnd

Type: Function.

Description:

  Registers a callback for event triggered when an action is finished.

Signature:

onActionEnd: function(self: Node, callback: function(action: Action, target: Node))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTapFilter

Type: Function.

Description:

  Registers a callback for event triggered before the TapBegan slot and can be used to filter out certain taps. This function also sets node.touchEnabled = true.

Signature:

onTapFilter: function(self: Node, callback: function(touch: Touch))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTapBegan

Type: Function.

Description:

  Registers callback for event triggered when a tap is detected. This function also sets node.touchEnabled = true.

Signature:

onTapBegan: function(self: Node, callback: function(touch: Touch))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTapEnded

Type: Function.

Description:

  Registers callback for event triggered when a tap ends. This function also sets node.touchEnabled = true.

Signature:

onTapEnded: function(self: Node, callback: function(touch: Touch))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTapped

Type: Function.

Description:

  Registers callback for event triggered when a tap is detected and has ended. This function also sets node.touchEnabled = true.

Signature:

onTapped: function(self: Node, callback: function(touch: Touch))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTapMoved

Type: Function.

Description:

  Registers callback for event triggered when a tap moves. This function also sets node.touchEnabled = true.

Signature:

onTapMoved: function(self: Node, callback: function(touch: Touch))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onMouseWheel

Type: Function.

Description:

  Registers callback for event triggered when the mouse wheel is scrolled. This function also sets node.touchEnabled = true.

Signature:

onMouseWheel: function(self: Node, callback: function(delta: Vec2))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onGesture

Type: Function.

Description:

  Registers callback for event triggered when a gesture is recognized. This function also sets node.touchEnabled = true.

Signature:

onGesture: function(self: Node, callback: function(center: Vec2, numFingers: integer, deltaDist: number, deltaAngle: number))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onEnter

Type: Function.

Description:

  Registers callback for event triggered when a node is added to the scene graph.

Signature:

onEnter: function(self: Node, callback: function())

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onExit

Type: Function.

Description:

  Registers callback for event triggered when a node is removed from the scene graph.

Signature:

onExit: function(self: Node, callback: function())

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onCleanup

Type: Function.

Description:

  Registers callback for event triggered when a node is cleaned up.

Signature:

onCleanup: function(self: Node, callback: function())

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onKeyDown

Type: Function.

Description:

  Registers callback for event triggered when a key is pressed down. This function also sets node.keyboardEnabled = true.

Signature:

onKeyDown: function(self: Node, callback: function(keyName: Keyboard.KeyName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onKeyUp

Type: Function.

Description:

  Registers callback for event triggered when a key is released. This function also sets node.keyboardEnabled = true.

Signature:

onKeyUp: function(self: Node, callback: function(keyName: Keyboard.KeyName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onKeyPressed

Type: Function.

Description:

  Registers callback for event triggered when a key is pressed. This function also sets node.keyboardEnabled = true.

Signature:

onKeyPressed: function(self: Node, callback: function(keyName: Keyboard.KeyName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onAttachIME

Type: Function.

Description:

  Registers callback for event triggered when the input method editor (IME) is attached.

Signature:

onAttachIME: function(self: Node, callback: function())

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onDetachIME

Type: Function.

Description:

  Registers callback for event triggered when the input method editor (IME) is detached.

Signature:

onDetachIME: function(self: Node, callback: function())

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTextInput

Type: Function.

Description:

  Registers callback for event triggered when text input is received.

Signature:

onTextInput: function(self: Node, callback: function(text: string))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onTextEditing

Type: Function.

Description:

  Registers callback for event triggered when text is being edited.

Signature:

onTextEditing: function(self: Node, callback: function(text: string, startPos: integer))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onButtonDown

Type: Function.

Description:

  Registers callback for event triggered when a button is pressed down on a controller. This function also sets node.controllerEnabled = true.

Signature:

onButtonDown: function(self: Node, callback: function(controllerId: integer, buttonName: Controller.ButtonName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onButtonUp

Type: Function.

Description:

  Registers callback for event triggered when a button is released on a controller. This function also sets node.controllerEnabled = true.

Signature:

onButtonUp: function(self: Node, callback: function(controllerId: integer, buttonName: Controller.ButtonName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onButtonPressed

Type: Function.

Description:

  Registers callback for event triggered when a button is pressed on a controller. This function also sets node.controllerEnabled = true.

Signature:

onButtonPressed: function(self: Node, callback: function(controllerId: integer, buttonName: Controller.ButtonName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

onAxis

Type: Function.

Description:

  Registers callback for event triggered when an axis is moved on a controller. This function also sets node.controllerEnabled = true.

Signature:

onAxis: function(self: Node, callback: function(controllerId: integer, axisName: Controller.AxisName, value: number))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

Node.AppEventType

Type: Enumeration.

Description:

  Enumeration of application events.

Signature:

enum AppEventType

-- The application is about to quit.
"Quit"

-- The application gets a low memory warning.
"LowMemory"

-- The application is about to enter the background.
"WillEnterBackground"

-- The application has entered the background.
"DidEnterBackground"

-- The application is about to enter the foreground.
"WillEnterForeground"

-- The application has entered the foreground.
"DidEnterForeground"
end

onAppEvent

Type: Function.

Description:

  Registers callback for event triggered when an application event occurs.

Signature:

onAppEvent: function(self: Node, callback: function(eventType: AppEventType))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

Node.AppSettingName

Type: Enumeration.

Description:

  Enumeration of application settings.

Signature:

enum AppSettingName

-- The application's locale.
"Locale"

-- The application's theme color.
"Theme"

-- The application window's fullscreen state.
"FullScreen"

-- The application window's position.
"Position"

-- The application window's size.
"Size"
end

onAppChange

Type: Function.

Description:

  Registers callback for event triggered when an application setting changes.

Signature:

onAppChange: function(self: Node, callback: function(settingName: AppSettingName))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.

Node.AppWSEvent

Type: Enumeration.

Description:

  Enumeration of application WebSocket events.

Signature:

enum AppWSEvent

-- A WebSocket connection is opened.
"Open"

-- A WebSocket connection is closed.
"Close"

-- The WebSocket receives a message.
"Send"

-- The WebSocket broadcasts a message.
"Receive"
end

onAppWS

Type: Function.

Description:

  Registers callback for event triggered when an application WebSocket event occurs.

Signature:

onAppWS: function(self: Node, callback: function(event: AppWSEvent, message: string))

Parameters:

ParameterTypeDescription
callbackfunctionThe callback function to register.