Empty tilemap



  • My googlefu is failing me, but is there any way to create an empty, custom-sized FlxTilemap without having to load data?

    For now, this is the only thing that ended up working

    tilemap.loadMapFromArray(new Vector<Int>(50*50).toArray(), 50, 50, AssetPaths.tile32xSprites__png, 32, 32);
    (creating a vector of 50x50 length, then converting it to array)

    Adding an empty CSV or array and setting the size with setSize(x, y) will strangely not work.
    If anyone could confirm testing this code; in both cases, only the first three tiles will be set to tile 3 (instead of 50x50 tiles set to tile 3, or 3 tiles set to tile 1)

    tilemap.loadMapFromArray([1, 1, 1], 50, 50, AssetPaths.tile32xSprites__png, 32, 32); 
    //tilemap.loadMapFromCSV("1, 1, 1", AssetPaths.tile32xSprites__png, 32, 32);
    tilemap.setSize(50, 50);
    for (i in 0...50)
    {
    	for (j in 0...50)
    	{
    		tilemap.setTile(i, j, 3, true);
    	}
    }
    


  • Apparently, you have to provide all the tiles to loadMapFrom*(). If you are generating the map procedurally, you can set the array elements first (not zeros, but real tile values) and then pass your array to loadMapFromArray(). If you are making drawable or destroyable world, then I believe you have no other choice.



  • Thanks. Looks like the vector trick will have to do for now. Still, I have to color every tile, so I might end up going with tinted FlxSprites drawn to a bitmap or something. I'll experiment.


Log in to reply
 

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