Tiled Maps for XNA – Full support for the Tiled Map XML specification!

So yesterday I came across a very basic loader for Tiled Maps (*.tmx) made with the Tiled Map Editor. It only supported the basics–Tileset loading and Layer rendering–so I took it upon myself to complete the loader by adding support for the rest of the features that were left out;

-added ProhibitDtd = false, so you don’t need to remove the doctype line after each time you edit the map.
-changed everything to use SortedLists for named referencing–so much easier
-added objectgroups
-added movable and resizable objects
-added object images
-added meta property support to maps, layers, object groups and objects
-added support for non-binary encoded layer data
-added layer and object group transparency

I created a simple demo to show off some of the features. You should see a partially transparent object with a resized image of Ness (Earthbound) on top of a partially transparent layer of grass with the words “Tile Maps Rule” written in rock with a pulsating opacity. Use the arrow keys to move Ness around. All objects and object groups can have their X and Y coordinates set dynamically, so you can do cool stuff like parallax clouds drifting overhead.

Download the Tiled Maps Loader

Popularity: unranked [?]

  • Digg
  • StumbleUpon
  • Technorati
  • Reddit
  • Furl
  • del.icio.us
  • Google Bookmarks
  • Slashdot
  • Facebook
  • MySpace
  • LinkedIn
You can leave a response, or trackback from your own site.
  • I didn't really do much in the way of performance testing, so it's probably not very optimized. Nick Gravelyn expanded on the concept here;
    http://blog.nickgravelyn.com/2010/03/know-when-to-be-lazy/

    Admittedly, I haven't really taken a close look at what he did. Apparently he rewrote it all to use a custom pipeline--what I made was parsing the XML at runtime, which could probably get slow on larger maps.
  • michi
    ok now i got it.

    hmm, maybe i make a transparentcy extension.

    so that the color which is defined in the editor as trancparent
  • That's referring to the opacity setting that can be set on each layer or object group using the slider above the layer list.
  • michi
    hmm

    what about this new feature: "-added layer and object group transparency" ?

    hmm in the map file there is a node e.g. "trans=ff00ff" in the same line where the tileset source is.
    .-= michi´s last blog ..GMX Lottozahlen =-.
  • That's part of the tileset file, not the map file. I don't have any support for tileset files yet. I might do that later.
  • michi
    Hello

    I didn't get the transparency working...are you sure you implemented it?

    Ich made a map with one layer und in the tileset i can see that there are some transparents tiles, so i choose the right color while i imported the tileset

    but when i use this map in your example, than the tiles are purple and not trancparency

    can you help me?

    thx
blog comments powered by Disqus