1. Home
  2. Docs
  3. LEd documentation
  4. Project components
  5. Enumerations (enums)

Enumerations (enums)

Introduction

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.

Examples:

  • 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 LEd enum panel.

Extern enums

For Haxe users, you can directly import a HX source file to use all (non-parametered) enums declared inside. L-Ed 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 LEd enums. Status and EnemyGrade will then be available as entity field types.

package whatever;

enum Status {
  Visible;
  Hidden;
  Sleeping;
}

enum EnemyGrade {
  Normal;
  Elite;
  Boss;
}