Tilemap not showing up


(Simon Edström Kawaji) #1

I followed this guide: https://www.youtube.com/watch?v=SxO_qwDUVsE And everything seemed to work out, but the map image doesn’t actually show up even though it detects the “Tiles” part of the XML code from my ogmo map. The actual collision grid and loading entities fine in my “loadmap” method

so in my “loadmap” method have this code:

		//Add code for the tilesheet
		if (String(mapXML.Tileset).length > 0)
		{
			
			var tm:Tilemap = new Tilemap(TILESHEET, _mapGrid.width, _mapGrid.height, 16, 16);
			tm.loadFromString(mapXML.Tileset, ",", "\n");
			
			//Save the tilemap as the map image.
			_mapImage = tm;
		}

and this is my GameWorld function:

public function GameWorld(mapData:Class = null) { super();

		_mapData = mapData;
		
		if (mapData != null)
		{
			loadMap(_mapData);

		}
		
		// Create tiled background for movement reference.

		
		
		// Create an image based on the map's data and scale it accordingly, if no Tilemap exsists
		if (_mapImage == null) 
		{
			back = new Backdrop(A.BACKROUND, true, true);
			addGraphic(back, 10);
			//create our debug map
			var mi:Image = new Image(_mapGrid.data);
			mi.scale = 16;
			
			//set the map Image
			_mapImage = mi;
		}
		
		
		// Create a map entity to render and check collision with.
		map = new Entity(0, 0, _mapImage, _mapGrid);
		map.name = "map";
		map.type = "floor"; 
		map.layer = -1;
	}
	
	override public function begin():void
	{
		add(player);
		add(enemytest);
		add(map);
	}

(Zachary Lewis) #2

Are map and _mapImage declared? It might be better to add these two files to a gist and link it here.


(Simon Edström Kawaji) #3

Here is my GameWorld file and my level file. Thanks for making these tutorials too, they are really helping me out