CanvasItem

abstract class CanvasItem : Node

A Node with 2D transformations.

Author

Colton Daily

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addChild(child: Node): Node

Sets the parent of the child to this Node.

Link copied to clipboard
fun addChildAt(child: Node, index: Int): Node

Sets the parent of the child to this Node sets it at the specified index.

Link copied to clipboard
fun addChildren(vararg children: Node): Node

Sets the parent of the children to this Node.

Link copied to clipboard
open override fun callInput(event: InputEvent<*>)
Link copied to clipboard
open override fun callUnhandledInput(event: InputEvent<*>)
Link copied to clipboard
open operator override fun compareTo(other: Node): Int

Compares Node by depth and position at each depth.

Link copied to clipboard
fun copyFrom(node: CanvasItem)
Link copied to clipboard
open fun debugRender(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

Draw any debug related items here.

Link copied to clipboard
fun destroy()

Remove the Node from the SceneGraph and destroys all children.

Link copied to clipboard

Removes & destroys all children nodes.

Link copied to clipboard
fun enabled(value: Boolean): Node

Enables/disables the Node. When disabled colliders are removed from the Physics system and will not be called.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Sets the position of the CanvasItem in global space.

Link copied to clipboard

Sets the rotation of the CanvasItem in global space in radians.

Link copied to clipboard

Sets the global scale of the CanvasItem.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Determines if this Node has zero children nodes.

Link copied to clipboard

Determines if this Node contains any children.

Link copied to clipboard
operator fun minusAssign(child: Node)
Link copied to clipboard
fun moveChild(child: Node, index: Int): Node

Moves a child node to the specified index.

Link copied to clipboard
open fun onDescendantAdded(child: Node)
Link copied to clipboard
open fun onDescendantRemoved(child: Node)
Link copied to clipboard
open override fun onDestroy()

Called when destroy is invoked and all of its children have been destroyed.

Link copied to clipboard
open override fun parent(parent: Node?): Node

Sets the parent Node of this Node.

Link copied to clipboard
operator fun plusAssign(child: Node)
Link copied to clipboard
fun position(x: Float, y: Float, invokeCallback: Boolean = true): CanvasItem

Sets the position of the CanvasItem relative to the parent Node. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalPosition

Link copied to clipboard
open fun postRender(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

Invoked after render. Calculations or logic that needs to be done after rendering such as flushing the batch or ending a frame buffer. The Camera can be used for culling and the Batch instance to draw with.

Link copied to clipboard
open fun preRender(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

Invoked before render. Calculations or logic that needs to be done before rendering such as flushing the batch or starting a frame buffer. The Camera can be used for culling and the Batch instance to draw with.

Link copied to clipboard
fun propagateDebugRender(batch: Batch, camera: Camera, camera3d: Camera, shapeRenderer: ShapeRenderer, renderCallback: (Node, Batch, Camera, Camera, ShapeRenderer) -> Unit?)

Internal debug rendering that needs to be done on the node that shouldn't be overridden. Calls propagateInternalDebugRender method.

Link copied to clipboard
Link copied to clipboard
open fun propagateHit(hx: Float, hy: Float): Control?
Link copied to clipboard
open fun propagateInput(event: InputEvent<*>): Boolean
Link copied to clipboard
open override fun propagateInternalDebugRender(batch: Batch, camera: Camera, camera3d: Camera, shapeRenderer: ShapeRenderer, renderCallback: (Node, Batch, Camera, Camera, ShapeRenderer) -> Unit?)
Link copied to clipboard
open override fun propagateInternalRender(batch: Batch, camera: Camera, camera3d: Camera, shapeRenderer: ShapeRenderer, renderCallback: (Node, Batch, Camera, Camera, ShapeRenderer) -> Unit?)
Link copied to clipboard
fun propagatePostRender(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

Internal post rendering that needs to be done on the node that shouldn't be overridden. Calls propagatePostRender method.

Link copied to clipboard
Link copied to clipboard
fun propagatePreRender(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

Internal pre rendering that needs to be done on the node that shouldn't be overridden. Calls propagatePreRender method.

Link copied to clipboard
Link copied to clipboard
fun propagateRender(batch: Batch, camera: Camera, camera3d: Camera, shapeRenderer: ShapeRenderer, renderCallback: (Node, Batch, Camera, Camera, ShapeRenderer) -> Unit?)

Internal rendering that needs to be done on the node that shouldn't be overridden. Calls propagateInternalRender method.

Link copied to clipboard
fun propagateResize(width: Int, height: Int, center: Boolean)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun removeChild(child: Node): Node

Removes the node if this node is its parent.

Link copied to clipboard

Removes the child at the specified index.

Link copied to clipboard
open fun render(batch: Batch, camera: Camera, shapeRenderer: ShapeRenderer)

The main render method. The Camera can be used for culling and the Batch instance to draw with.

Link copied to clipboard

Sets the rotation of the CanvasItem relative to the parent Node in radians. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalRotation

Link copied to clipboard
fun scale(value: Vec2f): CanvasItem

Sets the scale of the CanvasItem relative to the parent transform's scales. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalScale

Link copied to clipboard

Sends the child node at the specified index to the bottom of this list which will be rendered on top.

Link copied to clipboard

Sends the child node at the specified index to the top of this list which will be rendered behind.

Link copied to clipboard

Sends the child node to the bottom of this list which will be rendered on top.

Link copied to clipboard
fun sendChildToTop(child: Node): Node

Sends the child node to the top of this list which will be rendered behind.

Link copied to clipboard
fun swapChildren(child: Node, child2: Node): Node

Swaps the two children positions within the parents list

Link copied to clipboard
fun swapChildrenAt(idx: Int, idx2: Int): Node

Swaps children positions at the specified indices.

Link copied to clipboard
fun toGlobal(point: Vec2f): Vec2f
fun toGlobal(x: Float, y: Float): Vec2f

Transforms the provided local position into a position in global coordinate space. The input is expected to be local relative to the Node2D it is called on. e.g. Applying this method to the positions of child nodes will correctly transform their positions into the global coordinate space, but applying it to a node's own position will give an incorrect result, as it will incorporate the node's own transformation into its global position.

Link copied to clipboard
fun toLocal(point: Vec2f): Vec2f
fun toLocal(x: Float, y: Float): Vec2f

Transforms the provided global position into a position in local coordinate space. The output will be local relative to the Node2D it is called on. e.g. It is appropriate for determining the positions of child nodes, but it is not appropriate for determining its own position relative to its parent.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun translate(offset: Vec2f)
fun translate(x: Float, y: Float)

Translates the position by the offset vector in local coordinates.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun updateTransform()

Updates the current CanvasItem transform if it is dirty.

Link copied to clipboard
fun visible(value: Boolean): Node

Shows/hides the Node. When disabled propagateInternalRender is no longer called.

Properties

Link copied to clipboard
var canvas: CanvasLayer? = null

The CanvasLayer that this Node belongs to. The closest parent CanvasLayer will be selected. If none are found, the scene root viewport will be used.

Link copied to clipboard

The current child count for this Node. Alias for NodeList.size.

Link copied to clipboard

The children of this Node. Alias for nodes.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Enables/disables the node.

Link copied to clipboard

Attempts to grab the SceneGraph.fixedProgressionRatio. Defaults to 1 if not.

Link copied to clipboard
Link copied to clipboard

The position of the CanvasItem in global space. If you want to set the x,y properties of this Vec2f then use the globalX and globalY properties of this CanvasItem

Link copied to clipboard

The rotation of the CanvasItem in global space in radians

Link copied to clipboard

The global scale of the CanvasItem. If you want to set the x,y properties of this Vec2f then use the globalScaleX and globalScaleY properties of this CanvasItem.

Link copied to clipboard

The global x-scale of the CanvasItem.

Link copied to clipboard

The global y-scale of the CanvasItem.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val id: Int

Unique identifier for this node.

Link copied to clipboard
val index: Int

The index of this Node as a child in it's parent.

Link copied to clipboard

Check if this Node is in a SceneGraph

Link copied to clipboard

If destroy was called, this will be true until the next time node's are processed.

Link copied to clipboard
Link copied to clipboard
var material: Material? = null
Link copied to clipboard
Link copied to clipboard

Node name. useful for doing scene-wide searches for an node

Link copied to clipboard

The list of Nodes in this scene.

Link copied to clipboard

List of 'addedToScene' callbacks called when onAddedToScene is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

List of 'debugRender' callbacks called when debugRender is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'destroy' callbacks called when destroy is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'onDisabled' callbacks called when onDisabled is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'onEnabled' callbacks called when onEnabled is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'fixed-update' callbacks called when fixedUpdate is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'input' callbacks called when input is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'onInvisible' callbacks called when onInvisible is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'postRender' callbacks called after postRender is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'post-update' callbacks called when postUpdate is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'preRender' callbacks called when onPreRender is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'pre-update' callbacks called when preUpdate is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'ready' callbacks called when ready is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'removedFromScene' callbacks called when onRemovedFromScene is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard
Link copied to clipboard

List of 'render' callbacks called when propagateInternalRender is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'resize' callbacks called when resize is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'unhandledInput' callbacks called when unhandledInput is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'update' callbacks called when update is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard

List of 'onVisible' callbacks called when onVisible is called. Add any additional callbacks directly to this list. The main use is to add callbacks directly to nodes inline when building a SceneGraph vs having to extend a class directly.

Link copied to clipboard
var parent: Node?

The parent Node, if any.

Link copied to clipboard

The position of the CanvasItem relative to the parent transform. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalPosition. If you want to set the x,y properties of this Vec2f then use the x and y properties of this CanvasItem

Link copied to clipboard
val ppu: Float

Pixels per unit. Mainly used when rendering a Node. This is based off of the SceneGraph.ppu.

Link copied to clipboard

The inverse of ppu. This is based off the SceneGraph.ppuInv.

Link copied to clipboard

The rotation of the CanvasItem relative to the parent transform's rotation. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalRotation

Link copied to clipboard

The scale of the CanvasItem relative to the parent transform's scales. If the CanvasItem has no parent or if the parent node is NOT a CanvasItem, then it is the same a globalScale. If you want to set the x,y properties of this Vec2f then use the scaleX and scaleY properties of this CanvasItem.

Link copied to clipboard

The x-scale of the CanvasItem relative to the parent transform's scales.

Link copied to clipboard

The y-scale of the CanvasItem relative to the parent transform's scales.

Link copied to clipboard
var scene: SceneGraph<*>?

The scene this node belongs to.

Link copied to clipboard

Specifies how often this node's update method should be called. 1 means every frame, 2 is every other, etc

Link copied to clipboard

Shows/hides the node if it is renderable.

Link copied to clipboard
var x: Float
Link copied to clipboard
var y: Float

Inheritors

Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
inline fun Node.button(callback: Button.() -> Unit = {}): Button

Adds a Button to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.camera2d(callback: Camera2D.() -> Unit = {}): Camera2D

Adds a Camera2D to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.camera3d(callback: Camera3D.() -> Unit = {}): Camera3D

Adds a Camera3D to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.canvasLayer(callback: CanvasLayer.() -> Unit = {}): CanvasLayer

Adds a CanvasLayer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.centerContainer(callback: CenterContainer.() -> Unit = {}): CenterContainer

Adds a CenterContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.column(callback: VBoxContainer.() -> Unit = {}): VBoxContainer

Adds a VBoxContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.container(callback: Container.() -> Unit = {}): Container

Adds a Container to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.control(callback: Control.() -> Unit = {}): Control

Adds a Control to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.directionalLight(callback: DirectionalLight.() -> Unit = {}): DirectionalLight

Adds a DirectionalLight to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun <T : Node> Node.findFirstNodeOfType(): T?
Link copied to clipboard
inline fun Node.frameBuffer(callback: FrameBufferNode.() -> Unit = {}): FrameBufferNode
Link copied to clipboard

Adds a FrameBufferContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.hBoxContainer(callback: HBoxContainer.() -> Unit = {}): HBoxContainer

Adds a HBoxContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.hScrollBar(callback: HScrollBar.() -> Unit = {}): HScrollBar

Adds a HScrollBar to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.label(callback: Label.() -> Unit = {}): Label

Adds a Label to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.lineEdit(callback: LineEdit.() -> Unit = {}): LineEdit

Adds a LineEdit to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.meshNode(callback: MeshNode.() -> Unit = {}): MeshNode

Adds a MeshNode to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.ninePatchRect(callback: NinePatchRect.() -> Unit = {}): NinePatchRect

Adds a NinePatchRect to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.node(callback: Node.() -> Unit = {}): Node

Adds a Node to the current Node as a child and then triggers the callback

inline fun <T : Node> Node.node(node: T, callback: T.() -> Unit = {}): T

Adds the specified Node to the current Node as a child and then triggers the callback. This can be used for classes that extend node that perhaps they don't have a DSL method to initialize it.

Link copied to clipboard
inline fun Node.node2d(callback: Node2D.() -> Unit = {}): Node2D

Adds a Node2D to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.node3d(callback: Node3D.() -> Unit = {}): Node3D

Adds a Node3D to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.paddedContainer(callback: PaddedContainer.() -> Unit = {}): PaddedContainer

Adds a PaddedContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.panel(callback: Panel.() -> Unit = {}): Panel

Adds a Panel to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.panelContainer(callback: PanelContainer.() -> Unit = {}): PanelContainer

Adds a PanelContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.progressBar(callback: ProgressBar.() -> Unit = {}): ProgressBar

Adds a ProgressBar to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.row(callback: HBoxContainer.() -> Unit = {}): HBoxContainer

Adds a HBoxContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.scrollContainer(callback: ScrollContainer.() -> Unit = {}): ScrollContainer

Adds a ScrollContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.textureProgress(callback: TextureProgress.() -> Unit = {}): TextureProgress

Adds a TextureProgress to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.textureRect(callback: TextureRect.() -> Unit = {}): TextureRect

Adds a TextureRect to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.vBoxContainer(callback: VBoxContainer.() -> Unit = {}): VBoxContainer

Adds a VBoxContainer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.viewport(callback: ViewportCanvasLayer.() -> Unit = {}): ViewportCanvasLayer

Adds a ViewportCanvasLayer to the current Node as a child and then triggers the callback

Link copied to clipboard
inline fun Node.vScrollBar(callback: VScrollBar.() -> Unit = {}): VScrollBar

Adds a VScrollBar to the current Node as a child and then triggers the callback