[][src]Crate ldtk_rust

This library parses JSON generated by LDtk (Level Designers ToolKit) for use in Rust. It is designed to be usable in any Rust program, including all game frameworks.

Most users will want to start by reviewing the top level Project struct and in particular the Project::new() method. Calling this method will load in all of your LDtk data. See the library's /examples subdirectory for more detailed examples.

Project::new(f: String) --- loads all the data
Project::load_project(f: String) --- loads only the project file
Level::new(f: String) --- loads a single external level file

Structs

Definitions

A structure containing all the definitions of this project

EntityDefinition
EntityInstance
EntityInstanceTile

Optional Tile used to display this entity (it could either be the default Entity tile, or some tile provided by a field value, like an Enum).

EnumDefinition
EnumValueDefinition
FieldDefinition

This section is mostly only intended for the LDtk editor app itself. You can safely ignore it.

FieldInstance
IntGridValueDefinition

IntGrid value definition

IntGridValueInstance

IntGrid value instance

LayerDefinition
LayerInstance
LdtkJsonDeprecated
Level

This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If "Separate level files" is disabled (default): full level data is embedded inside the main Project JSON file, - If "Separate level files" is enabled: level data is stored in separate standalone .ldtkl files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the layerInstances array (which will be null). The externalRelPath string points to the ldtkl file. A ldtkl file is just a JSON file containing exactly what is described below.

LevelBackgroundPosition

Position informations of the background image, if there is one.

NeighbourLevel

Nearby level info

Project

This file is a JSON schema of files created by LDtk level editor (https://ldtk.io).

TileInstance

This structure represents a single tile from a given Tileset.

TilesetDefinition

The Tileset definition is the most important part among project definitions. It contains some extra informations about each integrated tileset. If you only had to parse one definition section, that would be the one.

Enums

BgPos

An enum defining the way the background image (if any) is positioned on the level. See __bgPos for resulting position info. Possible values: Unscaled, Contain, Cover, CoverDirty

EditorDisplayMode

Possible values: Hidden, ValueOnly, NameAndValue, EntityTile, PointStar, PointPath, RadiusPx, RadiusGrid

EditorDisplayPos

Possible values: Above, Center, Beneath

LimitBehavior

Possible values: DiscardOldOnes, PreventAdding, MoveLastOne

RenderMode

Possible values: Rectangle, Ellipse, Tile, Cross

TileRenderMode

Possible values: Stretch, Crop

Type

Type of the layer as Haxe Enum Possible values: IntGrid, Entities, Tiles, AutoLayer

WorldLayout

An enum that describes how levels are organized in this project (ie. linearly or in a 2D space). Possible values: Free, GridVania, LinearHorizontal, LinearVertical