Module components_ui_canvas

Canvas that groups UI elements and registers their render tasks on a screen.

Info:

  • Author: Sharper Dev

Functions

Canvas:new (gameObject) Creates a canvas on the top screen and assigns it to its game object.
Canvas:switchScreen (screen) Moves the canvas elements' render tasks to another screen.

Engine internal functions

Canvas:addElement (element) Adds an element and registers its render task on this canvas's screen when present.
Canvas:delElement (element) Removes the first matching element and unregisters its render task when present.
Canvas:destroy () Removes all elements and clears the canvas reference on its game object.


Functions

Canvas:new (gameObject)
Creates a canvas on the top screen and assigns it to its game object.

Parameters:

  • gameObject table Game object that owns the canvas.

Returns:

    table The new Canvas instance.

Usage:

    local canvas = gameObject:addComponent("Canvas")
Canvas:switchScreen (screen)
Moves the canvas elements' render tasks to another screen.

Parameters:

  • screen number Destination screen, such as BOTTOM_SCREEN.

Usage:

    canvas:switchScreen(BOTTOM_SCREEN)

Engine internal functions

Canvas:addElement (element)
Adds an element and registers its render task on this canvas's screen when present.

Parameters:

  • element table UI element to add.

Usage:

    canvas:addElement(image)
Canvas:delElement (element)
Removes the first matching element and unregisters its render task when present.

Parameters:

  • element table UI element to remove.

Usage:

    canvas:delElement(image)
Canvas:destroy ()
Removes all elements and clears the canvas reference on its game object.
generated by LDoc 1.5.0 Last updated 2026-10-04 12:53:32