Crate ldtk_rust

Source
Expand description

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: Path) --- loads all the data
Project::load_project(f: Path) --- loads only the project file
Level::new(f: Path) --- loads a single external level file

Structs§

AutoLayerRuleDefinition
This complex section isn’t meant to be used by game devs at all, as these rules are completely resolved internally by the editor before any saving. You should just ignore this part.
AutoLayerRuleGroup
Definitions
If you’re writing your own LDtk importer, you should probably just ignore most stuff in the defs section, as it contains data that are mostly important to the editor. To keep you away from the defs section and avoid some unnecessary JSON parsing, important data from definitions is often duplicated in fields prefixed with a double underscore (eg. __identifier or __type). The 2 only definition types you might need here are Tilesets and Enums.
EntityDefinition
EntityInstance
EnumDefinition
EnumTagValue
In a tileset definition, enum based tag infos
EnumValueDefinition
FieldDefinition
This section is mostly only intended for the LDtk editor app itself. You can safely ignore it.
FieldInstance
FieldInstanceEntityReference
This object is used in Field Instances to describe an EntityRef value.
FieldInstanceGridPoint
This object is just a grid-based coordinate used in Field values.
ForcedRefs
This object is not actually used by LDtk. It ONLY exists to force explicit references to all types, to make sure QuickType finds them and integrate all of them. Otherwise, Quicktype will drop types that are not explicitely used.
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
Level background image position info
NeighbourLevel
Nearby level info
Project
This file is a JSON schema of files created by LDtk level editor (https://ldtk.io).
TileCustomMetadata
In a tileset definition, user defined meta-data of a tile.
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.
TilesetRectangle
This object represents a custom sub rectangle in a Tileset image.
World
IMPORTANT: this type is not used yet in current LDtk version. It’s only presented here as a preview of a planned feature. A World contains multiple levels, and it has its own layout settings.

Enums§

AllowedRefs
Possible values: Any, OnlySame, OnlyTags
BgPos
Checker
Checker mode Possible values: None, Horizontal, Vertical
EditorDisplayMode
Possible values: Hidden, ValueOnly, NameAndValue, EntityTile, Points, PointStar, PointPath, PointPathLoop, RadiusPx, RadiusGrid, ArrayCountWithLabel, ArrayCountNoLabel, RefLinkBetweenPivots, RefLinkBetweenCenters
EditorDisplayPos
Possible values: Above, Center, Beneath
EmbedAtlas
Flag
IdentifierStyle
Naming convention for Identifiers (first-letter uppercase, full uppercase etc.) Possible values: Capitalize, Uppercase, Lowercase, Free
ImageExportMode
“Image export” option when saving project. Possible values: None, OneImagePerLayer, OneImagePerLevel, LayersAndLevels
LimitBehavior
Possible values: DiscardOldOnes, PreventAdding, MoveLastOne
LimitScope
If TRUE, the maxCount is a “per world” limit, if FALSE, it’s a “per level”. Possible values: PerLayer, PerLevel, PerWorld
RenderMode
Possible values: Rectangle, Ellipse, Tile, Cross
TextLanguageMode
TileMode
Defines how tileIds array is used Possible values: Single, Stamp
TileRenderMode
An enum describing how the the Entity tile is rendered inside the Entity bounds. Possible values: Cover, FitInside, Repeat, Stretch, FullSizeCropped, FullSizeUncropped, NineSlice
Type
Type of the layer as Haxe Enum Possible values: IntGrid, Entities, Tiles, AutoLayer
WorldLayout