Drowning in Tiles

05 Nov 2010

I have been spending the last week (on and off, as I had to make a drive over to Corvallis for the MECOP Fall Event), trying to integrate Tiled and TiledLib with my project. I learned a lot about the fantastic functionality of Tiled and how to actually go about using the program, which of course is going to become one of my main development environments when I need to start creating content for Ne+ (and really, I’d want to use Tiled for any 2D game moving forward), but I got hung up pretty badly once I started trying to load a map with XNA’s Content Pipeline and the TiledLib extension. I was getting an error about indexing past the end of an array in TiledLib’s map loading functions, so immediately I wondered what the deal was as I had tried out the demo and it worked perfectly.

So, I started taking a closer look at the demo - I was truly doing the absolute bare minimum in my project - declaring a map variable and then attempting to load the map file that I added to the content project, fully aware that the file was referencing a tile PNG with my one tile in it, but TiledLib was supposed to handle loading that for me. Eventually I just replaced the demo’s map with mine and saw my map load no problem in that project, but not in my own.

I debugged for a while, and saw that indeed, my project was not loading the PNG referenced in the map correctly. I pulled out garbage values where it was supposed to read the filename. Then I thought that maybe the file was getting processed incorrectly in my project, and then I remembered that there are settings for the importer and processor for every content item in your content project.

Sure enough, the importer and processor were blank. I set them to the TMX (map file extension) importer and processor, and bam, immediately the map appeared in the scene I’ve been testing. I still need to make my engine load up physics for the maps I load, and I think that with Tiled’s awesome ability to attach “properties” to tiles I’ll be able to decide whether or not the tiles are just for show, or should be “Collideable,” or anything else I can think of. I can also use Tiled to define player spawn points that don’t actually display on the screen, and other areas of interest. It’s a really cool program that provides nothing more than exactly what I’d want from it, and I can’t wait to start utilizing it more heavily.