Update: Stephen Belanger of Nerd Culture has made some great improvements to the following code, so I encourage you to check out the post about it on his blog.
Early in the development of my game, I used the free and open-source Tiled Map Editor to create levels. It was a big time-saver since it let me worry about more important things instead of investing effort into being able to place tiles down on a map. Later on I decided that the traditional approach to map construction wasn’t right for my project – but I was still glad I’d used Tiled.
Recently I realized that there aren’t very many easy ways for newbie XNA developers to get maps into their games, so I decided it was worth packaging up my Tiled map loader and sharing it with the world. So, I’ve created a simple example that shows how to load Tiled maps in your XNA game on Windows PCs and the XBox 360, and included the loader with it. It’s open-source and free for your use, no strings attached. I hope you find it helpful.
Download source code and binaries
Note that it doesn’t have support for isometric tiles or embedded tilesets, because I had no use for either feature. Tiled’s file format is relatively simple, so if you need those features, it should be simple to add them.
And of course, this wouldn’t be possible without the generous contributions of the developers of Tiled, Adam Turk and Bjørn Lindeijer. If you’d like to try it out, you can download it from their website (note: requires Java).



#1 by Gary on June 27, 2009 - 3:15 am
Quote
Thanks for this, was exactly what I needed. Managed to get a level of my own into XNA in about an hour thanks to your code
#2 by John on June 29, 2009 - 1:00 pm
Quote
Quick question, does your tile system need Java to use; or the one by Adam Turk and Bjørn Lindeijer?
#3 by Kael on July 1, 2009 - 2:49 pm
Quote
@John
Tiled itself requires Java, since it’s a Java application. However, your game won’t require any additional dependencies, since the loader is written entirely in C#/XNA. Same goes for the content pipeline – you only need Java to edit maps.
#4 by Soldat329x on July 8, 2009 - 3:06 pm
Quote
Hey, I’m getting this error:
“There are no importers which handle this file type. Specify the importer that handles this file type in your project.”
I’m not that fluent in XNA and am wondering if I did something wrong because it wont add .tmx files
Pingback: Nerd Culture » Tiled Maps for XNA – Full support for the Tiled Map XML specification!
#5 by Kael on July 14, 2009 - 5:26 pm
Quote
My loader isn’t designed to integrate with the content pipeline, so you’ll get that error if you try and build the map files using it. Set the ‘Build Action’ to ‘None’ for your tmx files in your content project to get rid of the error message.
#6 by EvilNando on July 28, 2009 - 6:34 am
Quote
Probably you have all of your framework all set up but maybe you would like to know that I have made a simple tile editor using XNA which outputs to XML
Pingback: Tiled Maps for XNA - Full support for the Tiled Map XML specification! | Stephen Belanger
#7 by Aman on November 5, 2009 - 11:05 pm
Quote
The development version is now made using Qt which means this is available for Linux xD So you guys can use it with Pygame ! WooHoo ! best tile editor ever
Pingback: Nick Gravelyn » Know when to be lazy
#8 by Tompa on May 18, 2010 - 4:48 am
Quote
Hello!
Thanks alot for this! its saved me alot of time and effort. I’m just wondering how to make collision with tiles, should i use tile properties for this? i’m all new to XNA