Skip to content

CanvasController

rech edited this page Jun 15, 2026 · 1 revision

Description

Controller for a canvas object.

Remarks

Inherited from Controller

A canvas does not draw anything on its own, but is used for containing other objects like images, texts, sprites, etc.

It's also how you can change the sorting layer and sorting order of images and texts (except sprites), which do not have such properties on their own.

A canvas can either be world-space, or screen-space, which is determined by when it was created through Scene.createCanvas

Properties


Name Type Description
active ValueChannel value 1 means object is enabled, 0 means object is disabled
translationX ValueChannel The canvas's position
translationY ValueChannel The canvas's position
translationZ ValueChannel The canvas's position
rotationX ValueChannel The canvas's rotation
rotationY ValueChannel The canvas's rotation
rotationZ ValueChannel The canvas's rotation
scaleX ValueChannel The canvas's scaling
scaleY ValueChannel The canvas's scaling
scaleZ ValueChannel The canvas's scaling
layer StringChannel The sorting layer name of the canvas
sort ValueChannel The sorting order within a layer of the canvas
alpha ValueChannel The alpha of the canvas
rectW ValueChannel The canvas's width
rectH ValueChannel The canvas's height
anchorMinX ValueChannel The canvas's rect transform anchor
anchorMinY ValueChannel The canvas's rect transform anchor
anchorMaxX ValueChannel The canvas's rect transform anchor
anchorMaxY ValueChannel The canvas's rect transform anchor
pivotX ValueChannel The canvas's rect transform pivot
pivotY ValueChannel The canvas's rect transform pivot

Remarks

anchorMinX, anchorMinY, anchorMaxX, anchorMaxY will affect how width and height will convert into actual size of the object.

pivotX, pivotY will affect how translationX and translationY will convert into actual position of the object.

alpha will determine the opacity of all images and texts parented to this controller.

Methods


copy()

Description

Create a copy of this controller, along with all of its chilren.

Parameters

_

Return types

CanvasController

Remarks

A copied controller will never be persistent.

Example

local sprite = Scene.createSprite("test.png")
sprite.setParent(Scene.worldCanvas)
local world = Scene.worldCanvas.copy()

getChildren()

Description

Return all controllers parented to this controller.

Parameters

_

Return types

Table of Controller

Remarks

_

Example

local children = canvas.getChildren()

setParent(controller)

Description

Set the parent to another controller.

Parameters

Name Type Description
controller Controller The controller to parent to

Return types

nil

Remarks

_

Example

local canvas = Scene.createCanvas()
local text = Scene.createText()
text.setParent(canvas)

Clone this wiki locally