Can you set all tiles in a tilemap at the same time?



  • Essentially what I mean is have them all set with one command. It would be similar to setting a single tile to a particular ID, so instead you set it all at once, for instance provide a new array of ints that instantly changes the layout? So take for instance in a game where let's say you hit a switch and now all the empty areas have platform blocks, and all the platforms that were there were turned to empty space? (for instance think of the switch blocks in super mario world which let you walk over open gaps) -- where it would do it instantly (to your eyes).

    Right now the way I would do it is run through each element in an array, and SetTilebyID to that value.

    But was hoping there was a way to do it in one line instead.

    SetAllTilesByArray( MyNewArray );

    or something.

    Any way to do this?



  • I wonder if customTileRemap would be useful to you...except that applyCustomRemap() is private. It looks like the current design calls for a full map reload whenever you want to use that, or if you do it manually by loading in an array, it's also a full map reload.

    I guess it depends on why you want to do this in one line. If it's about performance you can hack the engine a bit. If it's about conciseness, I guess you want either loadMapFromArray() or your own function that just loops over the array you give it and uses setTileByIndex().



  • Thanks, it looks like I would have to just loop through all the tiles and settilebyid -- I mean it's simple enough, i just figured it might be faster/better if there was a way already built in.

    I'm not sure about customTileRemap -- it looked like something funky and wasn't even really sure how to use it properly.

    Thanks for replying.


Log in to reply
 

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