Director
Description:
A singleton class manages the game scene trees and provides access to root scene nodes for different game uses.
Usage:
local Director = require("Director")
Director.entry:addChild(node)
clearColor
Type: Field.
Description:
The background color for the game world.
Signature:
clearColor: Color
scheduler
Type: Field.
Description:
Provides access to the game scheduler, which is used for scheduling tasks like animations and gameplay events.
Signature:
scheduler: Scheduler
ui
Type: Readonly Field.
Description:
The root node for 2D user interface elements like buttons and labels.
Signature:
const ui: Node
ui3D
Type: Readonly Field.
Description:
The root node for 3D user interface elements with 3D projection effect.
Signature:
const ui3D: Node
entry
Type: Readonly Field.
Description:
The root node for the starting point of a game.
Signature:
const entry: Node
postNode
Type: Readonly Field.
Description:
The root node for post-rendering scene tree.
Signature:
const postNode: Node
systemScheduler
Type: Readonly Field.
Description:
Provides access to the system scheduler, which is used for low-level system tasks, should not put any game logic in it.
Signature:
const systemScheduler: Scheduler
postScheduler
Type: Readonly Field.
Description:
Provides access to the scheduler used for processing post game logic.
Signature:
const postScheduler: Scheduler
currentCamera
Type: Readonly Field.
Description:
The current active camera in Director's camera stack.
Signature:
const currentCamera: Camera
frustumCulling
Type: Field.
Description:
The flag to enable or disable frustum culling.
Signature:
frustumCulling: boolean
profilerSending
Type: Field.
Description:
The flag to enable or disable sending collected statistics via built-in Web Socket server. For Web IDE use only.
Signature:
profilerSending: boolean
pushCamera
Type: Function.
Description:
Adds a new camera to Director's camera stack and sets it to the current camera.
Signature:
pushCamera: function(self: Director, camera: Camera)
Parameters:
Parameter | Type | Description |
---|---|---|
camera | Camera | The camera to add. |
popCamera
Type: Function.
Description:
Removes the current camera from Director's camera stack.
Signature:
popCamera: function(self: Director)
removeCamera
Type: Function.
Description:
Removes a specified camera from Director's camera stack.
Signature:
removeCamera: function(self: Director, camera: Camera): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
camera | Camera | The camera to remove. |
Returns:
Return Type | Description |
---|---|
boolean | True if the camera was removed, false otherwise. |
clearCamera
Type: Function.
Description:
Removes all cameras from Director's camera stack.
Signature:
clearCamera: function(self: Director)
cleanup
Type: Function.
Description:
Cleans up all resources managed by the Director, including scene trees and cameras.
Signature:
cleanup: function(self: Director)