What is TMX?

The TMX (Tile Map XML) is an XML file format to describe a tile based map. The Tiled Map Editor application is used to allow creations of tiled maps. It can describe maps with any tile size, any amount of layers, any number of tile sets and it allows custom properties to be set on most elements. Beside tile layers, it can also contain groups of objects that can be placed freely.

What is TMX Map Loader XNA?

TMX Map Loader XNA is a full XNA content pipeline library that allows you to load and process the data from the TMX source asset file and output the data as an intermediate format at design time (output to an .xnb file). The .xnb file is a resource file loaded at run-time to allow us to reconstruct the maps from the editor to in-game.

Features
  • Fully compliant with the TMX Map Format (https://github.com/bjorn/tiled/wiki/TMX-Map-Format)
  • GZip and ZLib compression is supported for storing tile layer data. Other non-compressed tile layer data such as CSV and XML is also supported.
  • Fully working XNA content pipeline that will allow you to import TMX files into your games straight away.
  • Support the drawing of polygons and polylines on the run-time side of the game code.

How to use TMXMapLoaderXNA.

These are the 3 simple steps you need to follow to get your TMX map files into the game.

1. Create the Maps in Tiled Map Editor (http://www.mapeditor.org/). When finished, save the file. In this case, I made a slight modification of the “desert.tmx” file.

Tiled_thumb2_thumb

2. Next, copy the TMX map file and all the relevant images that is referenced in your tile set you want to use in your game into the folder of your Content project. The Content project is the project you add all your resource file you want to use in your game. Next add the copied TMX file into the Content project in Visual Studio (shown below).

image_thumb1_thumb

3. Finally, Build the TMXMapLoaderXNA solution and run the TMXMapEditorText project.

http://www.youtube.com/watch?v=GJA8kqypySQ&feature=plcp

Found a bug/issue?

Please submit any issues or bugs via the Issue Tracker in the TMX Map Loader XNA CodePlex website.

Alternatively, contact me directly through my website http://www.windowsphonedevelopments.com/ and go to the Contact section.

Acknowledgements

Special thanks to:

  • The Tiled Map Editor crew. A great open source application used to creating and editing tiled maps.
  • ICSharpCode for the use of the SharpZipLib used for decompressing the GZip and ZLib tile layer data.
  • Adam Bruenderman for the use of the Camera2D class.
  • Stephen Styrchak for the XNA Content Pipeline Debugging extension. A very useful tool that allowed me to debug the TMX Content Pipeline.

Contact Me

As always contact me with any questions or issues you may have. Also it would be great to hear feedback for new feature requests and further improvements.

Please subscribe to my website for the latest news and information of my development work. www.windowsphonedevelopments.com

Note: My development work mainly focuses on Windows phone development, however with this project being developed using the XNA Framework, deploying this solution on XBox360 or PC is easily achievable and should be pretty straightforward.

Please rate my project if you find it useful. Thank you

Last edited Apr 1, 2016 at 9:37 AM by lozzali, version 9