SceneGraph

open class SceneGraph<InputType>(val context: Context, viewport: Viewport = ScreenViewport( context.graphics.width, context.graphics.height ), batch: Batch? = null, val uiInputSignals: SceneGraph.UiInputSignals<InputType> = UiInputSignals(), val controller: InputMapController<InputType> = createDefaultSceneGraphController( context.input, uiInputSignals ), whitePixel: TextureSlice = Textures.white) : InputMapProcessor<InputType> , Disposable

A class for creating a scene graph of nodes.

Author

Colton Daily

Parameters

context

the current context

viewport

the viewport that the camera of the scene graph will own

batch

an option sprite batch. If omitted, the scene graph will create and manage its own.

uiInputSignals

the input signals mapped to the UI input of type InputType.

controller

the input map controller for the scene graph

whitePixel

a white 1x1 pixel TextureSlice that is used for rendering with ShapeRenderer.

Constructors

Link copied to clipboard
fun <InputType> SceneGraph(context: Context, viewport: Viewport = ScreenViewport( context.graphics.width, context.graphics.height ), batch: Batch? = null, uiInputSignals: SceneGraph.UiInputSignals<InputType> = UiInputSignals(), controller: InputMapController<InputType> = createDefaultSceneGraphController( context.input, uiInputSignals ), whitePixel: TextureSlice = Textures.white)

Types

Link copied to clipboard
data class UiInputSignals<InputType>(val uiAccept: InputType? = null, val uiSelect: InputType? = null, val uiCancel: InputType? = null, val uiFocusNext: InputType? = null, val uiFocusPrev: InputType? = null, val uiLeft: InputType? = null, val uiRight: InputType? = null, val uiUp: InputType? = null, val uiDown: InputType? = null, val uiHome: InputType? = null, val uiEnd: InputType? = null)

Functions

Link copied to clipboard
open override fun charTyped(character: Char): Boolean

Invoked when a Key is pressed and a Char is associated with that key.

Link copied to clipboard
open override fun dispose()

Lifecycle method. Do any necessary unloading / disposing here. This is called when this scene is removed from the active slot.

Link copied to clipboard
open override fun gamepadButtonPressed(button: GameButton, pressure: Float, gamepad: Int): Boolean

Invoked when a GameButton is initially pressed on a GamepadInfo.

Link copied to clipboard
open override fun gamepadButtonReleased(button: GameButton, gamepad: Int): Boolean

Invoked when a GameButton is released on a GamepadInfo.

Link copied to clipboard
open override fun gamepadJoystickMoved(stick: GameStick, xAxis: Float, yAxis: Float, gamepad: Int): Boolean

Invoked when a GameStick is moved on a GamepadInfo.

Link copied to clipboard
open override fun gamepadTriggerChanged(button: GameButton, pressure: Float, gamepad: Int): Boolean

Invoked when a GameButton that is considered a trigger is changed / moved.

Link copied to clipboard
fun hasFocus(control: Control): Boolean

Checks if the Control has the current keyboard focus.

Link copied to clipboard
open suspend fun initialize()

Initializes the root Node and InputProcessor. This must be called before an update or render calls.

open suspend fun Node.initialize()

Lifecycle method. This is called whenever the SceneGraph is set before initialize is called. Any nodes added to this Node context won't be added until the next frame update.

Link copied to clipboard
open override fun keyDown(key: Key): Boolean

Invoked when a Key is initially pressed down.

Link copied to clipboard
open override fun keyRepeat(key: Key): Boolean

Invoked when a Key is pressed and held down.

Link copied to clipboard
open override fun keyUp(key: Key): Boolean

Invoked when a Key is released.

Link copied to clipboard
operator fun minusAssign(node: Node)

Removes the node from the root.

Link copied to clipboard
open override fun mouseMoved(screenX: Float, screenY: Float): Boolean

Invoked when the mouse is moved.

Link copied to clipboard
open fun onActionChange(inputType: InputType, pressure: Float): Boolean
Link copied to clipboard
open override fun onActionDown(inputType: InputType): Boolean
Link copied to clipboard
open override fun onActionRepeat(inputType: InputType): Boolean
Link copied to clipboard
open override fun onActionUp(inputType: InputType): Boolean
Link copied to clipboard
open fun onStart()

Lifecycle method. This is called when this scene becomes the active scene.

Link copied to clipboard
operator fun plusAssign(node: Node)

Adds the new to the root.

Link copied to clipboard

Releases any current keyboard focus.

Link copied to clipboard
open fun render()

Renders the entire tree.

Link copied to clipboard
fun requestFocus(control: Control)

Request a Control to receive keyboard focus.

Link copied to clipboard
open fun resize(width: Int, height: Int, centerCamera: Boolean = false)

Resizes the internal graph's OrthographicCamera and CanvasLayer.

Link copied to clipboard
open override fun scrolled(amountX: Float, amountY: Float): Boolean

Invoked when the mouse is scrolled.

Link copied to clipboard
open override fun touchDown(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is initially touched or clicked. This includes mouse and touch.

Link copied to clipboard
open override fun touchDragged(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is pressed/clicked and dragged. This includes mouse and touch.

Link copied to clipboard
open override fun touchUp(screenX: Float, screenY: Float, pointer: Pointer): Boolean

Invoked when a Pointer is released. This includes mouse and touch.

Link copied to clipboard
open fun uiInput(control: Control, event: InputEvent<InputType>)

Open method that is triggered whenever a Control node receives an input event.

Link copied to clipboard
open fun update(dt: Duration)

Updates all the nodes in the tree.

Properties

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

Holds the current Material of the last rendered Node if no changes were made)

Link copied to clipboard
Link copied to clipboard

The current delta time.

Link copied to clipboard
Link copied to clipboard

The fixed progression lerp ratio for fixed updates. This is used for rendering nodes that use Node.fixedUpdate for movement / physics logic.

Link copied to clipboard

The interval for Node.fixedUpdate to fire. Defaults to 30 times per second.

Link copied to clipboard
val frame: Int

The current frame count.

Link copied to clipboard

The virtual height of hte sceneCanvas.

Link copied to clipboard
open var ppu: Float = 1.0f

Pixel Per Unit. Changing this value affects ppuInv. Defaults to 1.

Link copied to clipboard

The inverse of ppu. Can be used to scale nodes correctly when using a ppu that isn't 1.

Link copied to clipboard

When true, nodes will handle rendering debug related info such as node bounds. When false nodes will not be rendered.

Link copied to clipboard
val root: Node

The root node that should be used to add any children nodes to.

Link copied to clipboard

The root ViewportCanvasLayer that is used for rendering all the children in the graph. Do not add children directly to this node. Instead, add children to the root node.

Link copied to clipboard
Link copied to clipboard
var showDebugInfo: Boolean = false

This is the true current value if debugging is rendering. To change this value see requestShowDebugInfo.

Link copied to clipboard
var targetFPS: Int = 60

The target FPS for tmod.

Link copied to clipboard
var tmod: Float = 1.0f

The time modifier based off of targetFPS.

Link copied to clipboard

The virtual width of the sceneCanvas.

Extensions

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

Adds a Button to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Camera2D to the current SceneGraph.root as a child and then triggers the Camera2D

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

Adds a Camera3D to the current SceneGraph.root as a child and then triggers the Camera3D

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

Adds a CanvasLayer to the current SceneGraph.root as a child and then triggers the CanvasLayer

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

Adds a CenterContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a VBoxContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Container to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Control to the current SceneGraph.root as a child and then triggers the callback

Link copied to clipboard

Adds a DirectionalLight to the current SceneGraph.root as a child and then triggers the DirectionalLight

Link copied to clipboard
inline fun SceneGraph<*>.frameBuffer(callback: FrameBufferNode.() -> Unit = {}): FrameBufferNode
Link copied to clipboard

Adds a FrameBufferContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a HBoxContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a HScrollBar to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Label to the current SceneGraph.root as a child and then triggers the callback

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

Adds a LineEdit to the current SceneGraph.root as a child and then triggers the callback

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

Adds a MeshNode to the current SceneGraph.root as a child and then triggers the MeshNode

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

Adds a NinePatchRect to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Node to the current SceneGraph.root as a child and then triggers the Node

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

Adds a Node to the current SceneGraph.root as a child and then triggers the Node. 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 SceneGraph<*>.node2d(callback: Node2D.() -> Unit = {}): Node2D

Adds a Node2D to the current SceneGraph.root as a child and then triggers the Node2D

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

Adds a Node3D to the current SceneGraph.root as a child and then triggers the Node3D

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

Adds a PaddedContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a Panel to the SceneGraph.root as a child and then triggers the callback

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

Adds a PanelContainer to the SceneGraph.root as a child and then triggers the callback

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

Adds a ProgressBar to the current SceneGraph.root as a child and then triggers the callback

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

Adds a HBoxContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a ScrollContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a TextureProgress to the current SceneGraph.root as a child and then triggers the callback

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

Adds a TextureRect to the SceneGraph.root as a child and then triggers the callback

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

Adds a VBoxContainer to the current SceneGraph.root as a child and then triggers the callback

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

Adds a ViewportCanvasLayer to the current SceneGraph.root as a child and then triggers the ViewportCanvasLayer

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

Adds a VScrollBar to the current SceneGraph.root as a child and then triggers the callback