Can you use multiple images for tilemap loaded from CSV?



  • I'm loading a tilemap from a .csv file and I would like to know if there is a way to use multiple images to represent different values in the tilemap. I am using FlxBaseTilemap.loadMapFromCSV(). The function has an argument, FlxTilemapGraphicAsset, which it says contains all the tiles (the programmer) wants to use. But the type of the argument only contains a single image.

    As far as I can tell from examples, I could make an image that is a grid of the tiles I want to use, and use that. But I would really like a way to use multiple images from my code if possible.

    Thanks.


  • administrators

    FlxTilemap doesn't really have a built-in way to do that, but one of the accepted graphic types is a BitmapData. You could always programatically combine multiple images into a single BitmapData with the entire grid, using copyPixels() or similar.

    Another accepted FlxTilemapGraphicAsset type is FlxFramesCollection. You could probably use FlxTileFrames.combineTileSets(), which pretty much handles that BitmapData combination logic for you.

    In both cases you need the BitmapData for the individual images, which you can get with openfl.Assets.getBitmapData(path).


Log in to reply
 

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