I changed it, and now I get 1 block on the screen. I don’t get a trace statement however… which is odd, because if I remove
for each(dataElement in dataList)
{
trace("HI");
_tiles.setTile(int(dataElement.@x) / 120, int(dataElement.@y) / 120, int(dataElement.@tx) / 120);
}
then I get no block on the screen either…
Hmm, wonder why I get one block only. The XML file contains a lot of
< tile gid="2"/>
lines and
< tile gid="1"/>
lines.
The tiles with the number 1 are the grond, and I want the
for each(dataElement in dataList)
{
trace("HI");
_tiles.setTile(int(dataElement.@x) / 120, int(dataElement.@y) / 120, int(dataElement.@tx) / 120);
}
to generate the ground tiles. What is missing?
Thank you all so much for helping me. I love you guys. This is the most friendly and well done forum I’ve ever seen.
EDIT: I tried changing it to this
dataList = xmlData.layer.(@name == "Tiles").data.tile.(@tile gid == "1")
But (as I suspected), the space between “tile” and “gid” messes things up. And I’m not so sure it would work if it was called “tilegid” in the first place either
EDIT 2: I realized that it already says “data.tile”, so it already references the tiles. So I tried changing it to this:
dataList = xmlData.layer.(@name == "Tiles").data.(@tile == "1");
and… well… this
dataList = xmlData.layer.(@name == "Tiles").data.(@gid == "1");
But it didn’t work Trying to figure it out for myself, because I’d like to LEARN. But wow, this stuff is confusing. Trying to come up with the solution on my own in this case (XML, it’s new to me) is like trying to “realize” how math works without anyone telling you!
EDIT 3:
Progress! Looked at the previous code, and changed it to this:
dataList = xmlData.layer.(@name == "Tiles").data.tile.(@gid == "1");
at least I get no errors now, but only one block is still displayed! Hmm.
I*m starting to think that the XML parser doesn’t translate the block positions from the XML file, as it doesn’t contain any X and Y values. It’s like 2D arrays, you don’t really see the positions in numbers, it’s just laid out in a way that is visually understandable. Question might be how to change the XML parser to translate the XML file’s block positions! Or maybe it’s this line:
_tiles.setTile(int(dataElement.@x) / 120, int(dataElement.@y) / 120, int(dataElement.@tx) / 120);
Since it is like the tutorial, and as you said Zach, it follows the ogmo way. I guess I gotta change that line to something else… This is a tough one.
I tried checking the Tiled documentation @ http://gamedevelopment.tutsplus.com/tutorials/parsing-tiled-tmx-format-maps-in-your-own-game-engine--gamedev-3104 , but that is a TON of code! Is all that really necessary? I tried adding it into my project but it was so confusing. I don’t really know where to put everything.
I remember trying Ogmo, but the XML file isn’t saved the same way as in your tutorial. I’m so lost