Hi.
I had some code which loaded tiles from an ogmo editor XML file and yeah, added it to the stage. Originally, the tileset only had 3 tiles.
I updated the tileset to a lot more, and changed the ogmo level.
Now, when I run the game, the level only loads 3 different tiles! (Another question at the bottom of this)
package
{
import flash.utils.ByteArray;
import net.flashpunk.Entity;
import net.flashpunk.graphics.Tilemap;
import net.flashpunk.masks.Grid;
import flash.geom.Point;
import net.flashpunk.FP;
public class Level extends Entity
{
private var _tiles:Tilemap;
private var _ground:Grid;
private var _wall:Grid;
public var LevelData:XML;
public function Level(xml:Class)
{
_tiles = new Tilemap(Assets.SPRITE_TILESET, 1920, 1080, 120, 120);
graphic = _tiles;
layer = 1;
_ground = new Grid(1920, 1080, 120, 120, 0, 0);
mask = _ground;
type = "ground";
loadLevel(xml);
}
private function loadLevel(xml:Class):void
{
var rawData:ByteArray = new xml;
var dataString:String = rawData.readUTFBytes(rawData.length);
LevelData = new XML(dataString);
var dataElement:XML;
var dataListTiles:XMLList;
var dataListSpawn:XMLList;
var dataListWeaponDrop:XMLList;
var dataListImpSpawn:XMLList;
dataListTiles = LevelData.OurTiles.tile;
dataListSpawn = LevelData.Entities.Spawn;
dataListWeaponDrop = LevelData.Entities.WeaponDrop;
dataListImpSpawn = LevelData.Entities.ImpSpawn;
for each(dataElement in dataListTiles)
{
_tiles.setTile(int(dataElement.@x), int(dataElement.@y), int(dataElement.@tx));
_ground.setTile(int(dataElement.@x), int(dataElement.@y), int(dataElement.@tx) == 0 || int(dataElement.@tx) == 2);
}
for each(dataElement in dataListSpawn)
{
FP.world.add(new Hero(new Point(int(dataElement.@x), int(dataElement.@y))));
}
for each(dataElement in dataListWeaponDrop)
{
FP.world.add(new WeaponDrop(new Point(int(dataElement.@x), int(dataElement.@y))));;
}
for each(dataElement in dataListImpSpawn)
{
FP.world.add(new Imp(new Point(int(dataElement.@x), int(dataElement.@y))));;
}
}
}
}
and the xml file:
<level width="1920" height="1080">
<OurTiles tileset="Tiles" exportMode="XMLCoords">
<tile x="0" y="0" tx="5" ty="4" />
<tile x="0" y="1" tx="5" ty="4" />
<tile x="0" y="2" tx="5" ty="4" />
<tile x="0" y="3" tx="5" ty="4" />
<tile x="0" y="4" tx="5" ty="4" />
<tile x="0" y="5" tx="5" ty="4" />
<tile x="0" y="6" tx="5" ty="4" />
<tile x="0" y="7" tx="5" ty="4" />
<tile x="0" y="8" tx="0" ty="0" />
<tile x="1" y="0" tx="5" ty="4" />
<tile x="1" y="1" tx="5" ty="4" />
<tile x="1" y="2" tx="5" ty="4" />
<tile x="1" y="3" tx="5" ty="4" />
<tile x="1" y="4" tx="5" ty="4" />
<tile x="1" y="5" tx="5" ty="4" />
<tile x="1" y="6" tx="5" ty="4" />
<tile x="1" y="7" tx="5" ty="4" />
<tile x="1" y="8" tx="1" ty="0" />
<tile x="2" y="0" tx="5" ty="4" />
<tile x="2" y="1" tx="5" ty="4" />
<tile x="2" y="2" tx="5" ty="4" />
<tile x="2" y="3" tx="5" ty="4" />
<tile x="2" y="4" tx="5" ty="4" />
<tile x="2" y="5" tx="5" ty="4" />
<tile x="2" y="6" tx="5" ty="4" />
<tile x="2" y="7" tx="5" ty="4" />
<tile x="2" y="8" tx="1" ty="5" />
<tile x="3" y="0" tx="5" ty="4" />
<tile x="3" y="1" tx="5" ty="4" />
<tile x="3" y="2" tx="5" ty="4" />
<tile x="3" y="3" tx="5" ty="4" />
<tile x="3" y="4" tx="5" ty="4" />
<tile x="3" y="5" tx="5" ty="4" />
<tile x="3" y="6" tx="5" ty="4" />
<tile x="3" y="7" tx="5" ty="4" />
<tile x="3" y="8" tx="7" ty="0" />
<tile x="4" y="0" tx="5" ty="4" />
<tile x="4" y="1" tx="5" ty="4" />
<tile x="4" y="2" tx="5" ty="4" />
<tile x="4" y="3" tx="5" ty="4" />
<tile x="4" y="4" tx="5" ty="4" />
<tile x="4" y="5" tx="5" ty="4" />
<tile x="4" y="6" tx="5" ty="4" />
<tile x="4" y="7" tx="5" ty="4" />
<tile x="4" y="8" tx="4" ty="4" />
<tile x="5" y="0" tx="5" ty="4" />
<tile x="5" y="1" tx="5" ty="4" />
<tile x="5" y="2" tx="5" ty="4" />
<tile x="5" y="3" tx="5" ty="4" />
<tile x="5" y="4" tx="5" ty="4" />
<tile x="5" y="5" tx="5" ty="4" />
<tile x="5" y="6" tx="5" ty="4" />
<tile x="5" y="7" tx="5" ty="4" />
<tile x="5" y="8" tx="4" ty="4" />
<tile x="6" y="0" tx="5" ty="4" />
<tile x="6" y="1" tx="5" ty="4" />
<tile x="6" y="2" tx="5" ty="4" />
<tile x="6" y="3" tx="5" ty="4" />
<tile x="6" y="4" tx="5" ty="4" />
<tile x="6" y="5" tx="5" ty="4" />
<tile x="6" y="6" tx="5" ty="4" />
<tile x="6" y="7" tx="5" ty="4" />
<tile x="6" y="8" tx="4" ty="4" />
<tile x="7" y="0" tx="5" ty="4" />
<tile x="7" y="1" tx="5" ty="4" />
<tile x="7" y="2" tx="5" ty="4" />
<tile x="7" y="3" tx="5" ty="4" />
<tile x="7" y="4" tx="5" ty="4" />
<tile x="7" y="5" tx="5" ty="4" />
<tile x="7" y="6" tx="5" ty="4" />
<tile x="7" y="7" tx="5" ty="4" />
<tile x="7" y="8" tx="4" ty="2" />
<tile x="8" y="0" tx="5" ty="4" />
<tile x="8" y="1" tx="5" ty="4" />
<tile x="8" y="2" tx="5" ty="4" />
<tile x="8" y="3" tx="5" ty="4" />
<tile x="8" y="4" tx="5" ty="4" />
<tile x="8" y="5" tx="5" ty="4" />
<tile x="8" y="6" tx="5" ty="4" />
<tile x="8" y="7" tx="5" ty="4" />
<tile x="8" y="8" tx="5" ty="0" />
<tile x="9" y="0" tx="5" ty="4" />
<tile x="9" y="1" tx="5" ty="4" />
<tile x="9" y="2" tx="5" ty="4" />
<tile x="9" y="3" tx="5" ty="4" />
<tile x="9" y="4" tx="5" ty="4" />
<tile x="9" y="5" tx="5" ty="4" />
<tile x="9" y="6" tx="5" ty="4" />
<tile x="9" y="7" tx="5" ty="4" />
<tile x="9" y="8" tx="1" ty="1" />
<tile x="10" y="0" tx="5" ty="4" />
<tile x="10" y="1" tx="5" ty="4" />
<tile x="10" y="2" tx="5" ty="4" />
<tile x="10" y="3" tx="5" ty="4" />
<tile x="10" y="4" tx="5" ty="4" />
<tile x="10" y="5" tx="5" ty="4" />
<tile x="10" y="6" tx="5" ty="4" />
<tile x="10" y="7" tx="5" ty="4" />
<tile x="10" y="8" tx="1" ty="0" />
<tile x="11" y="0" tx="5" ty="4" />
<tile x="11" y="1" tx="5" ty="4" />
<tile x="11" y="2" tx="5" ty="4" />
<tile x="11" y="3" tx="5" ty="4" />
<tile x="11" y="4" tx="5" ty="4" />
<tile x="11" y="5" tx="5" ty="4" />
<tile x="11" y="6" tx="5" ty="4" />
<tile x="11" y="7" tx="5" ty="4" />
<tile x="11" y="8" tx="1" ty="0" />
<tile x="12" y="0" tx="5" ty="4" />
<tile x="12" y="1" tx="5" ty="4" />
<tile x="12" y="2" tx="5" ty="4" />
<tile x="12" y="3" tx="5" ty="4" />
<tile x="12" y="4" tx="5" ty="4" />
<tile x="12" y="5" tx="5" ty="4" />
<tile x="12" y="6" tx="5" ty="4" />
<tile x="12" y="7" tx="5" ty="4" />
<tile x="12" y="8" tx="7" ty="1" />
<tile x="13" y="0" tx="5" ty="4" />
<tile x="13" y="1" tx="5" ty="4" />
<tile x="13" y="2" tx="5" ty="4" />
<tile x="13" y="3" tx="5" ty="4" />
<tile x="13" y="4" tx="5" ty="4" />
<tile x="13" y="5" tx="5" ty="4" />
<tile x="13" y="6" tx="5" ty="4" />
<tile x="13" y="7" tx="5" ty="4" />
<tile x="13" y="8" tx="4" ty="4" />
<tile x="14" y="0" tx="5" ty="4" />
<tile x="14" y="1" tx="5" ty="4" />
<tile x="14" y="2" tx="5" ty="4" />
<tile x="14" y="3" tx="5" ty="4" />
<tile x="14" y="4" tx="5" ty="4" />
<tile x="14" y="5" tx="5" ty="4" />
<tile x="14" y="6" tx="5" ty="4" />
<tile x="14" y="7" tx="4" ty="4" />
<tile x="14" y="8" tx="4" ty="4" />
<tile x="15" y="0" tx="5" ty="4" />
<tile x="15" y="1" tx="5" ty="4" />
<tile x="15" y="2" tx="5" ty="4" />
<tile x="15" y="3" tx="5" ty="4" />
<tile x="15" y="4" tx="5" ty="4" />
<tile x="15" y="5" tx="5" ty="4" />
<tile x="15" y="6" tx="5" ty="4" />
<tile x="15" y="7" tx="4" ty="4" />
<tile x="15" y="8" tx="4" ty="4" />
</OurTiles>
<Entities>
<WeaponDrop id="0" x="1800" y="720" />
<ImpSpawn id="1" x="1320" y="720" />
<Spawn id="2" x="120" y="720" />
</Entities>
</level>```
As you can see, it only makes the tiles "5" or "1" or "0". I have 56 different tiles in that map!!! Yet it doesn't save properly.
**And also**, how do I make it so that
_ground.setTile(int(dataElement.@x), int(dataElement.@y), int(dataElement.@tx) == 0 || int(dataElement.@tx) == 2);
doesn't only add tiles with the name 0 and 2 to the collision group _ground? I wanna make it so that it adds every tile EXCEPT 32 (the background tile), so something like
_ground.setTile(int(dataElement.@x), int(dataElement.@y), int(dataElement.@tx) != 32);
EDIT: Sorry for the bashing, OGMO. You're actually great