-
Notifications
You must be signed in to change notification settings - Fork 87
TiledSharp Class Overview
This is an overview of the classes and data types used by TiledSharp.
Map is an abstraction of a TMX file and its associated data.
TiledList is a KeyedCollection which stores lists of the principal TiledSharp classes. TiledLists are accessible by either their names or by index. For example, if the tileset with name "trees"
is the third TMX tileset, then it can be accessed by either of the following instructions:
trees = map.tileset["trees"];
trees = map.tileset[2];
The Tiled map editor does not enforce unique names for layers, tilesets or objects. If two TiledList items have the same name, the second is appended with a counter. If the name "myLayer"
appears three times in the TMX file, then the TiledSharp names (or keys) are "myLayer"
, "myLayer 1"
, and "myLayer 2"
.
For a more specific example, consider a TMX file containing the following layers:
<layer name="water">
<layer name="bushes">
<layer name="trees">
<layer name="bushes">
<layer name="bushes">
then the layer data can be accessed by name or by index:
water = map.layer["water"];
bushes = map.layer["bushes"];
trees = map.layer["trees"];
bushes1 = map.layer["bushes 1"];
bushes2 = map.layer["bushes 2"];
or by index
water = map.layer[0];
bushes = map.layer[1];
trees = map.layer[2];
bushes1 = map.layer[3];
bushes2 = map.layer[4];