GameWindow

A GameWindow represents a window, canvas or headless virtual frame where a game is displayed and can receive user events, it provides:

Updating and Rendering:

  • An EventLoop and a coroutineDispatcher where run code in a single thread like on JavaScript

  • Provides an onUpdateEvent that will be executed in the EventLoop at a fixed rate determined by fps used for updating the game, and having a lock to prevent rendering while running

  • Provides an onRenderEvent that will be executed in the Rendering thread at vsync or whenever a rendering is required. It has a lock to prevent executing at the same time as the onUpdateEvent.

  • If needing to update the game state outside the provided EventLoop, you can use the updateRenderLock function

Events:

Window properties:

Dialogs DialogInterface:

Virtual Keyboard:

Device Dimensions provider:

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class CustomCursor(val shape: Shape, val name: String = "custom") : GameWindow.ICursor, Extra
Link copied to clipboard
interface ICursor
Link copied to clipboard
data class MenuItem(val text: String?, val enabled: Boolean = true, val children: List<GameWindow.MenuItem>? = null, val action: () -> Unit = {})
Link copied to clipboard
class MenuItemBuilder(text: String? = null, enabled: Boolean = true, action: () -> Unit = {})
Link copied to clipboard

Describes if the rendering should focus on performance or quality. PERFORMANCE will use lower resolutions, while QUALITY will use the devicePixelRatio to render high quality images.

Properties

Link copied to clipboard
open override val ag: AG
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var bgcolor: RGBA
Link copied to clipboard
open val bufferHeight: Int
Link copied to clipboard
open val bufferWidth: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var debug: Boolean
Link copied to clipboard
open val debugComponent: Any? = null
Link copied to clipboard
Link copied to clipboard
open override val dialogInterface: DialogInterface
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var extra: ExtraType
Link copied to clipboard
open var fps: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val height: Int = 0
Link copied to clipboard
open var icon: Bitmap?
Link copied to clipboard
Link copied to clipboard

Flag to keep the screen on, even when there is no user input and the user is idle

Link copied to clipboard
open override val key: CoroutineContext.Key<*>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Approximate on iOS

Link copied to clipboard

Approximate on iOS

Link copied to clipboard
Link copied to clipboard
open var preferredFps: Int
Link copied to clipboard
open override var quality: GameWindow.Quality
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var title: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var visible: Boolean
Link copied to clipboard
open var vsync: Boolean
Link copied to clipboard
open val width: Int = 0

Functions

Link copied to clipboard
suspend fun DialogInterfaceProvider.alert(message: String)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <T : BEvent> clearEvents(type: EventType<T>)
Link copied to clipboard
open suspend fun clipboardRead(): ClipboardData?
Link copied to clipboard
open suspend fun clipboardWrite(data: ClipboardData)
Link copied to clipboard
open fun close(exitCode: Int = 0)
Link copied to clipboard
Link copied to clipboard
fun GameWindow.configure(size: Size, title: String? = "GameWindow", icon: Bitmap? = null, fullscreen: Boolean? = null, bgcolor: RGBA = Colors.BLACK)
Link copied to clipboard
Link copied to clipboard
override fun <T : BEvent> dispatch(event: T): Boolean
override fun <T : BEvent> dispatch(type: EventType<T>, event: T, result: EventResult?): Boolean

open override fun <T : BEvent> dispatch(type: EventType<T>, event: T, result: EventResult?, up: Boolean, down: Boolean): Boolean

Dispatched a event of type that will execute all the handlers registered with onEvents in this object and its children.

Link copied to clipboard
open fun <T : BEvent> dispatchChildren(type: EventType<T>, event: T, result: EventResult?)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun <T : BEvent> dispatchDown(type: EventType<T>, event: T, result: EventResult? = null): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Triggers an update envent and potential CONNECTED/DISCONNECTED events.

Link copied to clipboard
Link copied to clipboard
fun dispatchKeyEvent(type: KeyEvent.Type, id: Int, character: Char, key: Key, keyCode: Int, str: String? = null): Boolean
Link copied to clipboard
fun dispatchKeyEventDownUp(id: Int, character: Char, key: Key, keyCode: Int, str: String? = null): Boolean
Link copied to clipboard
fun dispatchKeyEventEx(type: KeyEvent.Type, id: Int, character: Char, key: Key, keyCode: Int, shift: Boolean = this.shift, ctrl: Boolean = this.ctrl, alt: Boolean = this.alt, meta: Boolean = this.meta, str: String? = null): Boolean
Link copied to clipboard
fun dispatchMouseEvent(type: MouseEvent.Type, id: Int, x: Int, y: Int, button: MouseButton, buttons: Int = this.mouseButtons, scrollDeltaX: Float = this.scrollDeltaX, scrollDeltaY: Float = this.scrollDeltaY, scrollDeltaZ: Float = this.scrollDeltaZ, isShiftDown: Boolean = this.shift, isCtrlDown: Boolean = this.ctrl, isAltDown: Boolean = this.alt, isMetaDown: Boolean = this.meta, scaleCoords: Boolean = this.scaleCoords, simulateClickOnUp: Boolean = false, scrollDeltaMode: MouseEvent.ScrollDeltaMode = MouseEvent.ScrollDeltaMode.LINE)
Link copied to clipboard
Link copied to clipboard
open fun <T : BEvent> dispatchParent(type: EventType<T>, event: T, result: EventResult?)
Link copied to clipboard
Link copied to clipboard
fun dispatchRenderEvent(update: Boolean = true, render: Boolean = true)
Link copied to clipboard
fun dispatchReshapeEvent(x: Int, y: Int, width: Int, height: Int)
Link copied to clipboard
fun dispatchReshapeEventEx(x: Int, y: Int, width: Int, height: Int, fullWidth: Int, fullHeight: Int)
Link copied to clipboard
Link copied to clipboard
fun dispatchSimpleMouseEvent(type: MouseEvent.Type, id: Int, x: Int, y: Int, button: MouseButton, simulateClickOnUp: Boolean = false)
Link copied to clipboard
Link copied to clipboard
open fun <T : BEvent> dispatchUp(type: EventType<T>, event: T, result: EventResult? = null): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override fun <T : BEvent> dispatchWithResult(event: T, out: EventResult): EventResult
Link copied to clipboard
fun entry(callback: suspend () -> Unit)
Link copied to clipboard
fun executePending(availableTime: TimeSpan)
Link copied to clipboard
fun exit(exitCode: Int = 0)
Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
fun frame(doUpdate: Boolean = true, doRender: Boolean = true, frameStartTime: TimeSpan = PerformanceCounter.reference): TimeSpan
Link copied to clipboard
fun frameRender(doUpdate: Boolean = true, doRender: Boolean = true)
Link copied to clipboard
fun frameUpdate(startTime: TimeSpan)
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun handleReshapeEventIfRequired(x: Int, y: Int, width: Int, height: Int)
Link copied to clipboard
fun hide()
Link copied to clipboard
open fun hideSoftKeyboard()
Link copied to clipboard
Link copied to clipboard
open suspend fun loop(entry: suspend GameWindow.() -> Unit)
Link copied to clipboard
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
Link copied to clipboard
override fun <T : BEvent> onEvent(type: EventType<T>, handler: (T) -> Unit): CloseableCancellable

Registers a handler block to be executed when an event of type is dispatched

Link copied to clipboard
override fun onEventCount(type: EventType<*>): Int
Link copied to clipboard
open fun <T : BEvent> onEvents(vararg etypes: EventType<out T>, handler: (T) -> Unit): Closeable
Link copied to clipboard
Link copied to clipboard

Happens on the rendering thread

Link copied to clipboard

Happens on the updater thread

Link copied to clipboard
suspend fun DialogInterfaceProvider.openFileDialog(filter: String? = null, write: Boolean = false, multi: Boolean = false): List<VfsFile>
suspend fun DialogInterfaceProvider.openFileDialog(filter: FileFilter? = null, write: Boolean = false, multi: Boolean = false, currentDir: VfsFile? = null): List<VfsFile>
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext
Link copied to clipboard
suspend fun DialogInterfaceProvider.prompt(message: String, default: String = ""): String
Link copied to clipboard
fun queue(callback: () -> Unit)
fun queue(callback: Runnable)
Link copied to clipboard
fun <T> queueBlocking(callback: () -> T): T
Link copied to clipboard
inline fun <T> registerTime(name: String, block: () -> T): T
open fun registerTime(name: String, time: TimeSpan)
Link copied to clipboard
open override fun repaint()
Link copied to clipboard
open fun setInputRectangle(windowRect: Rectangle)
Link copied to clipboard
Link copied to clipboard
open fun setSize(width: Int, height: Int)
Link copied to clipboard
fun show()
Link copied to clipboard
Link copied to clipboard
open fun showSoftKeyboard(force: Boolean = true, config: ISoftKeyboardConfig? = null)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun updateGamepads()
Link copied to clipboard
inline fun updateRenderLock(block: () -> Unit)
Link copied to clipboard
suspend fun waitClose()