SkillAgentSearch skills...

Ktx

Kotlin extensions for the libGDX game framework

Install / Use

/learn @libktx/Ktx

README

GitHub Build Kotlin libGDX Maven Central

KTX

Kotlin extensions for libGDX.

Table of contents

Introduction

KTX is a Kotlin game framework extending libGDX. It aims to make libGDX as Kotlin-friendly as possible without completely rewriting the API. It provides modular utilities and extensions for selected parts of libGDX with poor Kotlin support.

Examples of Kotlin language features used to improve usability, performance, and readability of libGDX include:

  • Operator overloads for collections and mathematical operations.
  • Extension methods expanding and improving the original libGDX APIs without the use of inheritance.
  • Inline methods with reduced runtime overhead for various listeners, builders, and loggers.
  • Nullable types which improve typing information of selected interfaces and functions.
  • Default parameters reducing boilerplate code and providing sensible defaults for various operations.
  • Type-safe builders for GUI, interface styling, ECS, and physics engine setup.
  • Default interface methods simplifying their implementation.
  • Coroutines context providing concurrency utilities and non-blocking asset loading.
  • Reified types simplifying usage of methods normally consuming Class parameters.

See the Choosing KTX article for pros and cons of this framework.

Modules

KTX was designed to be modular from day one. In fact, some of its libraries consist of just a single Kotlin file. You can include the selected KTX modules based on the needs of your application.

| Module | Description | |:--------------------------------------:|-----------------------------------------------------------------------------------------------------------------------------------| | ktx-actors | Scene2D GUI extensions for stages, actors, actions, and event listeners. | | ktx-ai | Type-safe Kotlin builders and utilities for gdxAI. | | ktx-app | ApplicationListener implementations and general application utilities. | | ktx-artemis | Artemis-odb entity-component-system utilities. | | ktx-ashley | Ashley entity-component-system utilities. | | ktx-assets | Resources management utilities. | | ktx-assets-async | Non-blocking asset loading using coroutines. | | ktx-async | Coroutines context based on libGDX threading model. | | ktx-box2d | Box2D physics engine utilities. | | ktx-collections | Extensions for libGDX custom collections. | | ktx-freetype | FreeType fonts loading utilities. | | ktx-freetype-async | Non-blocking FreeType fonts loading using coroutines. | | ktx-graphics | Utilities related to rendering tools and graphics. | | ktx-i18n | Internationalization API utilities. | | ktx-inject | A dependency injection system with low overhead and no reflection usage. | | ktx-json | Utilities for libGDX JSON serialization API. | | ktx-log | Minimal runtime overhead cross-platform logging using inlined functions. | | ktx-math | Operator functions for libGDX math API and general math utilities. | | ktx-preferences | Improved API for accessing and saving preferences. | | ktx-reflect | Utilities for libGDX reflection API. | | ktx-scene2d | Type-safe Kotlin builders for Scene2D GUI. | | ktx-script | Kotlin scripting engine for desktop applications. | | ktx-style | Type-safe Kotlin builders for Scene2D widget styles extending Skin API. | | ktx-tiled | Utilities for Tiled maps. | | ktx-vis | Type-safe Kotlin builders for VisUI. | | ktx-vis-style | Type-safe Kotlin builders for VisUI widget styles. |

Installation

New projects

New projects with support for KTX can be generated with the gdx-liftoff tool. In contrary to the official gdx-setup tool, gdx-liftoff provides greater support for libGDX extensions and a wider set of platforms, as well as custom project templates. You can download the latest release of the tool here.

Click on the sections below for instructions on how to set up a new KTX project with gdx-liftoff.

<details><summary><b>General</b></summary><dl><dd>

Fill the basic information about your project such as its name, root package or main class name. Provide an empty folder to generate the project into. If you want to target the Android platform, define the path to the Android SDK.

The following sections describe each tab of the setup tool available below the basic project info.


</dd></dl></details> <details><summary><b>Platforms</b></summary><dl><dd>

KTX supports the following platforms:

  • Core: mandatory shared module.
  • Desktop: the default desktop platform based on LWJGL3.
  • Android: native Android mobile platform.
  • iOS: mobile platform using RoboVM to support iOS.
  • HTML (TeaVM): unofficial experimental web platform using TeaVM.
  • Headless: a desktop platform without a graphical interface.
  • Server: a separate server application without libGDX APIs.
  • Shared: a module for sharing code between the Server and Core.

The following platforms are unsupported or untested:

  • HTML: the default web platform. Supports only Java projects.
  • Desktop (Legacy): legacy desktop platform built upon LWJGL2. Might not work with modern JVMs.
  • iOS Multi-OS Engine: an alternative iOS platform. Untested.

</dd></dl></details> <details><summary><b>Languages</b></summary><dl><dd>

You can select the Kotlin language support to ensure it is correctly set up in the generated project. If a Kotlin project template is selected, it will automatically add the necessary Kotlin libraries and plugins.


</dd></dl></details> <details><summary><b>Extensions</b></summary><dl><dd>

This section includes the official libGDX extensions. Each of these should be compatible with Kotlin projects. However, some extensions might be unavailable on specific platforms. In particular, the TeaVM backend might be unable to compile libraries relying on native code or reflection.


</dd></dl></details> <details><summary><b>Third-party extensions</b></summary><dl><dd>

This section contains all verified third-party extensions for libGDX. All KTX modules are listed in this tab.

To include a KTX module, scroll down to the KTX libraries list and click o

Related Skills

View on GitHub
GitHub Stars1.4k
CategoryDevelopment
Updated4d ago
Forks72

Languages

Kotlin

Security Score

100/100

Audited on Mar 20, 2026

No findings