Using Tiled

Tiled is a free and easy to use map editor supporting different map types and new functionalities still being added.
If you haven't downloaded tiled yet you can download it from the Tiled website: www.mapeditor.org.
Once you've downloaded the file run it to install Tiled

In this section we're not going to much in detail about how to use Tiled - you can play around with it yourself - but I'll give you the tile map of Mam Bow 2's first level including two tile sets it uses. And we'll take a look at the .TMX file that contains all the map info.

Here are the download links for the tile map and the two tile sets it uses. Download these files and put them into the assets folder of the Android project.


The Tile Editor

If you've downloaded all the files and installed Tiled open up the Tiled map editor and either drag and drop level1.tmx from your asets folder in Eclipse into tiled or load the .tmx file by clicking on File -> Open and browse to the location where you put the downloaded files. If all went well you'll now see something resembling the image below.
At 1: On Tiled's canvas you should see part of the map. You can zoom in/out using ctrl +/- and use the scrollbar at the bottom of the screen to move through the map.
At 2: You´ll see the tilesets - level1_tiles and level1_boss that are being used in this tilemap.
At 3: You'll see an overview of the layers. Only one in this map, but you can add more. We'll use the layer's name later in our code

Before we start coding our map into our project let's have a brief look at the .tmx file.

The .tmx file basically holds information on which image files to use as tileset(s), what the names of these tilesets, the width and height of a tile and more (lines 4-6 and 8-10). On Line 2 information like map type (orthogonal), how many tiles it has (width and height) and the width and height (in pixels) of the tiles. And finally the code between the layer tags defines which tile goes where in a compressed format.
One thing to take not of is that if you'd ever create tile maps yourself and import a new tileset, the image file that is used for that tileset will be saved within the .tmx file with it relative path. So something like this:
source="../../../../Manbow2GDX/android/assets/maps/level1/level1_image.png"

Now the problem with this is that if you then drag and drop your tilemap files into your assets folder in Eclipse and try to run your code you'll get an error because the files can't be found at that relative path. So in that case you have to delete all the path information and only leave the filename just like on lines 5 + 9. Just something to keep in mind if you ever work with Tiled...

So far the Tiled introduction. Now let's add some code so that we can use the tilemap for our games' background. We'll do that in the next section...




-->