Tiled use multiple layers

  • Hi,

    I have followed a basic tutorial and have a single tiled layer coming in from my map.tmx file. I would like to use more than one layer that exists within my map.tmx file though and I am not having much success. In the below example the buildings layer displays correctly but I do not see the floor. No errors show in the console.

     _map = new TiledMap(AssetPaths.map1__tmx);
     _floor = new FlxTilemap();
    	_floor.loadMapFromArray(cast(_map.getLayer("floor"), TiledTileLayer).tileArray, _map.width, _map.height, AssetPaths.floor__png, _map.tileWidth, _map.tileHeight, FlxTilemapAutoTiling.OFF, 1, 1, 3);
    	_floor.setTileProperties(1, FlxObject.NONE);
    	_floor.setTileProperties(2, FlxObject.ANY);
    	_buildings = new FlxTilemap();
    	_buildings.loadMapFromArray(cast(_map.getLayer("buildings"), TiledTileLayer).tileArray, _map.width, _map.height, AssetPaths.buildings__png, _map.tileWidth, _map.tileHeight, FlxTilemapAutoTiling.OFF, 1, 1, 3);
    	_buildings.setTileProperties(1, FlxObject.NONE);
    	_buildings.setTileProperties(2, FlxObject.ANY);

  • My Kelin Kelilin game is using Tiled as well. The method I use is different but it can show layer as many as I want. My method uses tmx file as from Tiled, since the file itself is already an XML.

    public function addTiledLayer(LayerName:String, TilesetPath:String):Void
    	var flxtilemap:FlxTilemap = new FlxTilemap();
    	var tiledTileLayer:TiledTileLayer;
    	tiledTileLayer = cast(_map.getLayer(LayerName), TiledTileLayer);
    	flxtilemap.loadMapFromCSV(tiledTileLayer.csvData, TilesetPath, tmxTiledMap.tileWidth, tmxTiledMap.tileHeight, null, 1);

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.