1. Home
  2. Docs
  3. LDtk interface
  4. Interface overview
  5. Enumerations (enums)

Enumerations (enums)

Enumerations (Enums) are special value types for Entities. They could be for example the list of possible Enemy types, or a list of Item identifiers.


  • enum “EnemyType” with values: “Zombie”, “Skeleton”, “Ghost”…
  • enum “ItemType” with values: “Ammo”, “HealthPotion”, “Key”…

Enum types

Local enums

Local enums are created and filled directly from the LDtk enum panel.

Imported enums

You can import enums directly from external files and LDtk will keep them synced as you update your files.

From text files

The text files should be formatted like this:

MyEnumA : valueA1, valueA2, valueA3
MyEnumB: valueB1, valueB2

From JSON files

The JSON file should be formatted like below. Note that 3 different formats are accepted for values:

  • comma separated values in a String,
  • space separated values in a String,
  • array of String
  "MyEnumA": "a1,a2,a3",
  "MyEnumB": "b1 b2 b3",
  "MyEnumC": ["c1", "c2", "c3"]

From Haxe source code

For Haxe users, you can directly import a HX source file to use all (non-parametered) enums declared inside. LDtk will keep the enums synced and they will even be accessible later in your code through the Haxe API, with all the cool type-safe consequences you can imagine.

For example, if you have the following MyTypes.hx file, you can import it to LDtk enums. Status and EnemyGrade will then be available as entity field types.

package whatever;

enum Status {

enum EnemyGrade {

Note that abstract enums are not supported, as, per definition, abstract enums only exist at compilation time and not at runtime.