Skip to content

C# library for parsing and importing TMX and TSX files generated by Tiled, a tile map generation tool

License

Notifications You must be signed in to change notification settings

JQE/TiledSharp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TiledSharp

A .NET C# library for importing Tiled TMX tile maps

About TiledSharp

TiledSharp is a .NET C# library for importing TMX tilemaps and TSX tilesets generated by Tiled, a tile map generation tool. The data is saved as a TmxMap object, whose structure closely resembles the original TMX file.

As a generic TMX and TSX parser, TiledSharp does not render the maps or depend on any external framework beyond .NET, such as Windows, XNA/MonoGame, or PSM. However, it can be used as an interface between TMX data and external games.

For an example of an XNA Map renderer using TiledSharp, see my Tesserae project.

Usage

To import a TMX file into your C# application:

  • Include a reference to TiledSharp. You can either incorporare it directory into your own project, or you can pre-compile it and include the DLL.

  • Import the TiledSharp namespace (optional):

    using TiledSharp;
  • Create a Map object using the constructor:

    var map = new TmxMap("someMap.tmx");

    TiledSharp supports both resource names and file paths, and should work as expected in most situations. For more details, please consult the wiki.

  • Access the TMX data using the Map fields. Principal classes can be accessed by either name or index:

    var map = new TmxMap("someMap.tmx");
    var version = map.Version;
    var myTileset = map.Tilesets["myTileset"];
    var myLayer = map.Layers[2];
    var hiddenChest = map.ObjectGroups["Chests"].Objects["hiddenChest"];

Map data fields correspond closely to the TMX file structure. For a complete listing, see the TiledSharp Data Hierarchy.

Although TiledSharp can manage elements with the same name, it is not recommended. For more information, see the TmxList specification.

Tiled 0.9.0 Status Report

To the best of my knowledge, all new 0.9.0 features have been implemented:

  • Map: backgroundcolor
  • Imagelayer
  • Object: visible, rotation, tile flip
  • Ellipse
  • Tileset: TileOffset
  • Tileset: Terraintype, Terrain
  • Image: format and data (base64 embedded image) (untested)

I am still in the process of testing most of these new features.

The following new T# features have been added or changed:

  • TmxList elements now return their type, rather than their interface
  • TmxObject.Width and Height are no longer nullable
  • Colors are now stored under a platform-neutral TmxColor class

The following new T# features may need to be added or redesigned:

  • Fix the TmxList name collision problems
  • cleaner ToString field output
  • Develop test cases and automated testing

Notes

TiledSharp parses XML files produced by Tiled, an open-source (GPL) tile map editor developed and maintained by Thorbjørn Lindeijer.

Zlib decompression in TiledSharp uses the Zlib implementation of DotNetZip v1.9.1.8.

Licensing

TiledSharp is distributed under the Apache 2.0 License.

Support code from DotNetZip is distributed under the Microsoft Public License.

Contact

Marshall Ward <tiledsharp@marshallward.org>

About

C# library for parsing and importing TMX and TSX files generated by Tiled, a tile map generation tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published