Crate ldtk2[−][src]
A thin crate for people who just want to use ldtk files freely.
Why did I create this nonsense?
- LDtk-rs uses code generation, it does not get autocomplete support from rust-analyzer. Also, there are special license restrictions on using that crate.
- ldtk_rust uses
.except()
inside the crate, you can't handle errors.
Supported LDtk file versions
>=0.7.2
Usage
cargo add ldtk2
use std::error::Error; use std::path::Path; use std::convert::TryInto; fn main() -> Result<(), Box<dyn Error>> { use ldtk2::Ldtk; let map = Ldtk::from_path("tests/example.ldtk")?; // or let map: Ldtk = Path::new("tests/example.ldtk").try_into()?; // or let map = Ldtk::from_str(include_str!("../tests/example.ldtk"))?; // or let map: Ldtk = include_str!("../tests/example.ldtk").try_into()?; Ok(()) }
Structs
Coordinate | This file is a JSON schema of files created by LDtk level editor (https://ldtk.io). |
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 | |
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 |
LevelBackgroundPosition | Position informations of the background image, if there is one. |
NeighbourLevel | Nearby level info |
TileInstance | This structure represents a single tile from a given Tileset. |
TilesetDefinition | The |
Enums
BgPos | An enum defining the way the background image (if any) is positioned on the level. See
|
EditorDisplayMode | Possible values: |
EditorDisplayPos | Possible values: |
LimitBehavior | Possible values: |
RenderMode | Possible values: |
TileRenderMode | Possible values: |
Type | Type of the layer as Haxe Enum Possible values: |
WorldLayout | An enum that describes how levels are organized in this project (ie. linearly or in a 2D
space). Possible values: |
Type Definitions
Ldtk |