melonJS
    Preparing search index...

    Class LDtkProject

    An LDtk project, as loaded from a .ldtk file: its levels and worlds, and the definitions they are read with. loader.getLDtk(name) returns it.

    Index
    entityDefs: Map<number, LDtkEntityDef> = ...

    the entity definitions, by their uid

    enums: Map<string, LDtkEnumDef> = ...

    the enums, by their identifier

    images: Map<string, string>

    the name each image the project names is kept under by the loader, by its path in the project: the file's name, unless another file of that name was loaded already

    the project file's content

    layerDefs: Map<number, LDtkLayerDef> = ...

    the layer definitions, by their uid

    levels: LDtkLevelInfo[] = []

    every level of the project, in LDtk's order

    name: string

    the name the project was loaded under

    tilesets: Map<number, LDtkTilesetDef> = ...

    the tilesets, by their uid

    worlds: LDtkWorldInfo[] = []

    the project's worlds: one, unless the project was set up for several

    • An entity of the project, by its unique id: what an EntityRef field points at (a teleport's destination, the door a lever opens), found whether its level is loaded or not.

      Parameters

      • reference: string | LDtkEntityReference | null | undefined

        the entity's iid, or the value of an EntityRef field

      Returns LDtkFoundObject | undefined

      the entity, its level and where it is, or undefined

      const target = project.findObject(teleport.fields.destination);
      ldtkWorld.loadLevel(target.level.identifier);
      player.pos.set(target.x, target.y);
    • The entities the project's table of content lists: those whose definition has "Add to table of content" checked in LDtk. They are known without a level being loaded, which is what tells a game where to start in a world loaded a few levels at a time.

      Parameters

      • Optionalidentifier: string

        the entities' identifier in LDtk; every listed entity by default

      Returns LDtkListedObject[]

      the entities, in LDtk's order

      const [start] = loader.getLDtk("world").getTableOfContent("PlayerStart");
      level.load("world", { levels: [start.level.identifier] });
    • the text typed for a tile in LDtk's tileset view ("custom data")

      Parameters

      • tileset: string

        the tileset's identifier in LDtk

      • tileId: number

        the tile's id in the tileset

      Returns string | undefined

      the text, or undefined for a tile with none

    • the values of a tileset's enum a tile is tagged with in LDtk

      Parameters

      • tileset: string

        the tileset's identifier in LDtk

      • tileId: number

        the tile's id in the tileset

      Returns string[]

      the names of the enum values the tile carries