Game

open class Game<SceneType : Scene>(val context: Context, firstScene: SceneType? = null) : ContextListener

A ContextListener that handles commonly loading assets and preparing assets. Handles scene switching and caching.

Author

Colt Daily

See also

Parameters

context

the context instance

firstScene

the initial scene the was be used immediately by the context.

SceneType

the common base interface or class of all scenes.

Constructors

Link copied to clipboard
fun <SceneType : Scene> Game(context: Context, firstScene: SceneType? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
inline suspend fun <Type : SceneType> addScene(scene: Type)
open suspend fun <Type : SceneType> addScene(type: KClass<Type>, scene: Type)

Registers an instance of Scene.

Link copied to clipboard

Checks if the scene of the given type is registered.

Link copied to clipboard
inline fun <Type : SceneType> getScene(): Type
open fun <Type : SceneType> getScene(type: KClass<Type>): Type

Returns the cached instance of Scene of the selected type.

Link copied to clipboard
inline fun <Type : SceneType> removeScene(): Type?
open fun <Type : SceneType> removeScene(type: KClass<Type>): Type?

Removes the cached instance of Scene of the selected type. Note that this method does not dispose of the scene and will not affect shownScene.

Link copied to clipboard
inline suspend fun <Type : SceneType> setScene()
open suspend fun <Type : SceneType> setScene(type: KClass<Type>)

Replaces the current scene with the registered scene instance of the passed type.

Link copied to clipboard
open suspend override fun Context.start()

Handles resizing the current scene and disposing of the current scene. If this is overridden, ensure to call setSceneCallbacks to ensure the lifecycle events happen for a Scene.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val gl: GL
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Provides direct access to current Scene instance handling game events.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val vfs: Vfs