Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

napen123/Tiled.Net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiled.Net

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.

About Tiled.Net

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.

Usage

  • Add the using statement
using Tiled;

Reading a Map File

  • Create a new TiledMap object
var map = new TiledMap("my-map.tmx");

Accessing Layers

var layer = map.Layers[0] as TiledTileLayer;
// or
var layer = map["My Layer"] as TiledTileLayer;
...
var layerName = layer.Name;
...

Creating a Map File

  • 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");