I am trying to use the TMX Tile Map Editor to create a tiled map for my RPG game. Thus far it is going great, however I am having difficulties trying to decipher certain parts of my tmx file (exported as an XML file).
In particular, the map has multiple layers, so I am trying to figure out how I can assign each layer into a new part of an array.
Here is the XML file:
<map version="1.0" orientation="orthogonal" width="5" height="5" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="TileA2" tilewidth="32" tileheight="32">
<image source="./tileset/TileA2.png" width="512" height="384"/>
</tileset>
<layer name="Tile Layer 1" width="5" height="5">
<properties>
<property name="collidable" value="false"/>
</properties>
<data>
<tile gid="17"/>
<tile gid="17"/>
<tile gid="17"/>
<tile gid="17"/>
<tile gid="17"/>
</data>
</layer>
<layer name="Collision" width="5" height="5">
<properties>
<property name="collidable" value="true"/>
</properties>
<data>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="19"/>
<tile gid="0"/>
<tile gid="0"/>
</data>
</layer>
</map>
So basically what I would like is for the first layer to be one index of a matrix, while the 2nd layer is anotehr index (Layer[0] = Tile Layer 1; Layer[1] = collidable), this way I can create standards for my mapping system (all tiles on Layer[1] prevent walking, Layer[2] are NPCs, etc).
The code I am using to read the XML file is as follows:
xml = new XML(e.target.data);
tileLength = xml.layer.data.tile.length();
trace (xml.layer.properties.property.attribute("value"));
spriteWidth = xml.attribute("width");
spriteHeight = xml.attribute("height");
tileWidth = xml.attribute("tilewidth");
tileHeight = xml.attribute("tileheight");
spriteSource = xml.tileset.image.attribute("source");
Now my trace is displaying falsetrue. I would like to figure out a way to make it run as though it were a for statement. For the first layer assign the values this way, for the 2nd layer assign the values this way, etc, with the only true difference between them being that their matrix index is different.