A handy crate for parsing the Tiled JSON data in to a usable structure.
The crate includes a few small helper functions on Map
, TileSet
, and
TileLayer
. These functions are for common tasks such as generating a
cloumn/row location (tiles are stored in a 1D array), a located box on an
image for helping with tile-to-tilesheet image picking, and loading files
(or strings).
Examples
# use PathBuf;
use tiled_json_rs as tiled;
let map = load_from_file
.expect;
# use PathBuf;
# use tiled_json_rs as tiled;
# let map = load_from_file.unwrap;
for tileset in &map.tile_sets
# use PathBuf;
# use tiled_json_rs as tiled;
# let map = load_from_file.unwrap;
use Layer;
render_layers;
Info
Tiled can export maps as JSON files. To do so, simply select “File > Export As”
and select the JSON file type. You can export json from the command line with
the --export-map
option.
Notes:
- GID for tiles starts at 1 with 0 reserved for empty tile
- Local Id starts at 0 for
TileSet
, and only applies toTileSet
- Doc comments are only provided where clarification may be useful. In general things should be named well enough that intention is self-describing.