Package-level declarations

Types

Link copied to clipboard
interface KtxApplicationAdapter : ApplicationListener, Disposable

Wrapping interface around com.badlogic.gdx.ApplicationListener. Provides no-op implementations of all methods, making them optional to implement.

Link copied to clipboard
open class KtxGame<ScreenType : Screen>(firstScreen: ScreenType? = null, clearScreen: Boolean = true) : KtxApplicationAdapter

An equivalent of com.badlogic.gdx.Game delegating game events to a Screen. On contrary to Game, KtxGame maintains a collection of screens mapped by their type and allows to change screens knowing only their type with setScreen. Thanks to this, its easier to cache screens without maintaining a singleton with all Screen instances manually. ScreenType generic type allows to users to use an extended specific base class (or interface) for all screens, without locking into Screen.

Link copied to clipboard
interface KtxInputAdapter : InputProcessor

Wrapping interface around com.badlogic.gdx.InputProcessor. Provides empty implementations of all methods, making them optional to implement.

Link copied to clipboard
interface KtxScreen : Screen, Disposable

Provides empty implementations of all Screen methods, making them optional to override.

Link copied to clipboard
object Platform

Contains utilities for platform-specific code. Allows to easily determine current application platform and its version. Can execute given actions only on specific platforms.

Functions

Link copied to clipboard
inline fun clearScreen(red: Float, green: Float, blue: Float, alpha: Float = 1.0f, clearDepth: Boolean = true)

Clears current screen with the selected color. Inlined to lower the total method count. Assumes alpha is 1f. Clears depth by default.

Link copied to clipboard
fun emptyScreen(): Screen

Provides a no-op implementation of Screen. A workaround of Screen nullability issues.

Link copied to clipboard
inline fun gdxError(message: Any? = null, cause: Throwable? = null): Nothing

Throws a GdxRuntimeException. The message will be converted to string and passed as the exception message. The cause is an optional exception cause. See also: error.

Link copied to clipboard
fun PerformanceCounter.prettyPrint(decimalFormat: String = "%.6fs")

Logs profiling information of this PerformanceCounter as an organized block. Uses passed decimalFormat to format floating point numbers.

Link copied to clipboard
inline fun profile(name: String = "Profiler", repeats: Int = 10, printResults: Boolean = true, operation: () -> Unit): PerformanceCounter

Profiles the given operation using a PerformanceCounter. The operation will be repeated repeats times to gather the performance data. PerformanceCounter.tick will be called after each operation. repeats will be used to set the window size of the PerformanceCounter. If printResults is set to true, a short summary will be printed by the application.

Link copied to clipboard
inline fun PerformanceCounter.profile(repeats: Int = if (time.mean != null) time.mean.windowSize else 10, printResults: Boolean = true, operation: () -> Unit)

Profiles the given operation using this PerformanceCounter. The operation will be repeated repeats times to gather the performance data. PerformanceCounter.tick will be called after each operation. By default, repeats is set to the window size passed to the PerformanceCounter constructor or 10 if the window size is set to 1. If printResults is set to true, a short summary will be printed by the application.