A .NET library for reading Tiled maps.
Attention: This library is no longer being supported. Check out TiledSharp for another library that reads Tiled maps.
Tiled.Net provides a general way of reading and writing TMX (Tiled Map XML) files. Tiled.Net aims to be usable everywhere, rather than being tied to things like XNA/MonoGame and Unity.
Tiled.Net should be compatible with the official format, which can be viewed here.
- Add the using statement
using Tiled;
- Create a new TiledMap object
var map = new TiledMap("my-map.tmx");
var layer = map.Layers[0] as TiledTileLayer;
// or
var layer = map["My Layer"] as TiledTileLayer;
...
var layerName = layer.Name;
...
- Create a new TiledMap object and initialize any necessary properties
var map = new TiledMap
{
TileWidth = 16,
TileHeight = 16,
Layers = new List<TiledBaseLayer>
{
new TiledTileLayer
{
Name = "Foreground"
}
}
...
};
- Save the map to a file
// Save the map to be _readable_.
map.Save("my-map.tmx");
// Save the map to be _compact_.
map.SaveCompact("my-map.tmx");