Kotlin extensions for the libGDX game framework
A release with minor API changes in ktx-scene2d
and ktx-collections
, as well as new features in ktx-app
, ktx-ashley
, ktxc-collections
, and ktx-freetype-async
. Includes new utilities for platform-specific code in ktx-app
.
ktx-app
) Added Platform
object that exposes various utilities for platform-specific code.
Platform.currentPlatform
returns current ApplicationType
or throws GdxRuntimeException
if unable to determine.Platform.version
returns the current version of the platform (e.g., Android API version, iOS major OS version).Platform.isAndroid
checks if the current platform is Android.Platform.isDesktop
checks if the current platform is desktop with graphical application.Platform.isHeadless
checks if the current platform is desktop without graphical application.Platform.isiOS
checks if the current platform is iOS.Platform.isMobile
checks if the current platform is Android or iOS.Platform.isWeb
checks if the current platform is HTML/WebGL.Platform.runOnAndroid
executes an action if the current platform is Android. Returns action result or null.Platform.runOnDesktop
executes an action if the current platform is desktop. Returns action result or null.Platform.runOnHeadless
executes an action if the current platform is headless desktop. Returns action result or null.Platform.runOniOS
executes an action if the current platform is iOS. Returns action result or null.Platform.runOnMobile
executes an action if the current platform is Android or iOS. Returns action result or null.Platform.runOnWeb
executes an action if the current platform is HTML/WebGL. Returns action result or null.runOnVersion
executes an action if the current platform version is within minimum and maximum values.ktx-ashley
) Mapper
abstract class designed for companion object
s of Component
s. Allows to easily obtain instances of a ComponentMapper
corresponding to the enclosing Component
class.ktx-assets-async
) AssetStorage.loadSync(String)
now supports optional loading parameters.ktx-collections
) isEmpty
and isNotEmpty
extension methods of libGDX collections now support Kotlin contracts. If they return true
, the collection is implied not to be null.ktx-collections
) As IdentityMap
now extends ObjectMap
, some redundant utilities specific to IdentityMap
were removed. From the user point of view, all additional functionalities are covered by the ObjectMap
utilities.ktx-freetype-async
) AssetStorage.loadFreeTypeFontAsync
was added, mimicking loadAsync
behavior.ktx-freetype-async
) AssetStorage.loadFreeTypeFontSync
was added, mimicking loadSync
behavior.ktx-freetype-async
) AsyncAssetManager.loadFreeTypeFontAsync
was added, returning a Deferred<BitmapFont>
instance.ktx-scene2d
) Scene2DSkin.defaultSkin
now throws IllegalStateException
when accessed before overriding.The first release to include the ktx-reflect
module with new reflection utilities. Includes notable new features in ktx-collections
, ktx-inject
, and ktx-assets-async
.
ktx-assets-async
) AssetStorage
now supports loading PolygonRegion
assets out of the box if the default loaders are registered.ktx-assets-async
) AsyncAssetManager
is a new AssetManager
extension with basic support for Kotlin coroutines.
AsyncAssetManager.loadAsync
allows to schedule an asset for loading, returning a Deferred
asset reference.AsyncAssetManager.getDefaultParameters
allows to create a default instance of AssetLoaderParameters
for a selected asset.AsyncAssetManager.setLoaderParameterSupplier
has to be called for each custom asset loader in order to enable asynchronous loading without explicitly passing loader parameters.ktx-collections
) Factory methods for LibGDX arrays of primitives:
gdxBooleanArrayOf
gdxByteArrayOf
gdxCharArrayOf
gdxShortArrayOf
gdxIntArrayOf
gdxLongArrayOf
gdxFloatArrayOf
ktx-inject
) New reflection-based Context
methods with automatic dependency injection:
newInstanceOf
: constructs an instance of the selected class. Injects constructor dependencies from the Context
.bind<Type>
: registers a provider that creates a new instance of selected class via reflection each time it is requested.bindSingleton<Type>
: creates, registers, and returns a singleton of selected class using reflection.ktx-reflect
) Added a new module with reflection utilities.
Reflection
annotation, which requires opt-in, allows marking functionalities that rely on reflection.ReflectedClass
is an inlined wrapper for Class
that allows to easily use LibGDX reflection API.
ClassReflection
methods exposed as ReflectedClass
read-only properties:
simpleName
isMemberClass
isStatic
isArray
isPrimitive
isEnum
isAnnotation
isInterface
isAbstract
componentType
constructors
methods
declaredMethods
fields
declaredFields
annotations
declaredAnnotations
interfaces
enumConstants
ClassReflection
methods exposed as ReflectedClass
methods with improved Kotlin class handling:
isInstance
isAssignableFrom
newInstance
getConstructor
getDeclaredConstructor
getMethod
getDeclaredMethod
getField
getDeclaredField
isAnnotationPresent
getAnnotation
getDeclaredAnnotation
ReflectedClass
utilities:
constructor
property allows to extract the only class constructor if it is available.newArrayInstance
method allows to create a type array of the given size using ArrayReflection
.KClass
constructor allows creating ReflectedClass
from a KClass
.reflect<Type>()
function allows to wrap a selected class with ReflectedClass
.reflect(KClass<Type>)
function allows to wrap a selected KClass
with ReflectedClass
.reflect(Class<Type>)
function allows to wrap a selected Class
with ReflectedClass
.reflect(String)
function allows to find a selected class by qualified name and wrap it with ReflectedClass
.Annotation.get
extension method with a reified type allowing to get an instance of the annotation.A maintenance release with improved support for the new LibGDX 1.10.0 features. Includes a minor refactoring of the ktx-log
module.
1.8
, since Java 1.6
target was deprecated and is incompatible with the latest coroutines library. Note that source compatibility level is still set to 1.7
.ktx-assets
) Added discard
lambda parameter to the pool
factory method that is invoked after an object is rejected from the created Pool
.ktx-scene2d
) Added support for ParticleEffectActor
in Scene2D DSL via particleEffect
factory method.ktx-log
) Added DEBUG
, INFO
and ERROR
constants with default logger tags.ktx-log
) Default tags are no longer wrapped in square brackets. This caused a change of the logs structure.ktx-log
) Logger.tag
variable was renamed to Logger.name
.ktx-log
) Log prefix variables from Logger
were removed. Message tags are now configurable directly through the constructor.ktx-log
) Logger name is no longer a part of the message tag. Instead, it is now prepended to the message. This causes a change of the logs structure.ktx-log
) Added Logger.buildMessage
method that allows to modify logged message structure. This method can be overridden when extending the Logger
class, simplifying the usage of custom message formats.Maintenance release with support for LibGDX 1.10.0.
A maintenance release with notable dependency updates and a minor VisUI module bug fix.
ktx-tiled
) Added isEmpty
and isNotEmpty
extension function for MapLayers
and MapObjects
collections.ktx-tiled
) Added forEachLayer
extension function for TiledMap
to iterate over an exact type of MapLayer
instances of a specific map.ktx-vis
) visScrollPane
and visSplitPane
now define the correct types for this
in the init
lambdas, adding support for Scene2D and VisUI DSL.The first release to support LibGDX 1.9.14. Includes notable debugging extension for ktx-assets-async
.
ktx-app
) clearScreen
now accepts additional clearDepth
boolean parameter that controls whether the GL_DEPTH_BUFFER_BIT
is added to the mask.ktx-assets-async
) Added AssetStorageSnapshot
class that stores a copy of AssetStorage
state for debugging purposes. Supports formatted string output with prettyFormat
.ktx-assets-async
) AssetStorage
now includes takeSnapshot
and takeSnapshotAsync
methods that allow to copy and inspect the internal state of the storage for debugging purposes.ktx-collections
) Added getOrPut
extension function for LibGDX map collections including ObjectMap
, IdentityMap
, ArrayMap
and IntMap
.The first release to support LibGDX 1.9.13. Maintenance release with some notable dependencies updates.
ktx-style
) Added Skin.register
extension method that allows to register widget styles with the DSL.ktx-vis
) Added flowGroup
factory method that allows to construct FlowGroup
actors.ktx-vis
) horizontalFlowGroup
and verticalFlowGroup
are now deprecated. Use flowGroup
instead.The first KTX release with support for LibGDX 1.9.2.
A release that features relatively minor additions, but major changes in terms of internal project architecture and documentation generation. The project was updated to the latest Gradle version with Kotlin DSL, and the latest Dokka version with an overhauled auto generated UI.
ktx-collections
) Added GdxIdentityMap
and GdxArrayMap
aliases for LibGDX IdentityMap
and ArrayMap
collections.ktx-collections
) Added set
operator extension method to ArrayMap
to support square brackets assignment.ktx-graphics
) Added optional Camera
and projection matrix parameters to ShapeRenderer.use
.ktx-scene2d
) Added image
builders for NinePatch
, TextureRegion
, Texture
and Drawable
.The first release to officially support LibGDX 1.9.11. No major changes otherwise.
ktx-scene2d
) Added a generic container
factory method that supports adding a custom actor.