Tilemap from 5.1.5 to 6.1.0

Hi everyone,

I was wondering what are the big changes in tilemap with the new versions of OpenFl. Everything was running smoothly with version 5.1.5, but with 6.1.0 or 6.1.2, my FPS drops if I have a little too many tiles.

Does someone have an idea and can point me in the right direction, so I can work on that?

Thank you! :slight_smile:

What target are you using?

We may have a minor regression in performance that we need to focus on – we added a TileArray API, that enables you to use Tilemap like a ByteArray and define all your tile values rather than using distinct Tile objects for each Tile. We’ve also been working on improving performance for Tilemap instances that do not change between frames, but that’s ongoing. How big of a difference are you seeing? Thanks!

Hi, thank you for your reply.

I’m targetting Neko and the difference is 10-15 FPS. I had 60 before and now, it would drop often when loading new maps (à la Super Metroid or Zelda a Link to the Past). Each map was loading every tile, so I thought that doing addTileAt and removeTile when the map is moving, so it would load only visible tiles, would help and it did. But I still loose like 3-5 FPS from time to time and before, I was always at 60. Every tile in every map is stocked in a Array<Array<Tile>>, so I can use them easily.

Maybe trying to use the TileArray would help? Is there an example on how to use it?

Thank you!

On C++ targets, the difference might not be noticeable.

The difference sort of looks like…

var tilemap = new Tilemap (tileset);

for (i in 0...10) {
    
    var tile = new Tile (0);
    tile.x = Math.random () * 800;
    tile.y = Math.random () * 600;
    tilemap.addTile (tile);

}

...

var tilemap = new Tilemap (tileset);
var tiles = tilemap.getTiles ();
tiles.length = 10;
var matrix = tile.matrix;

for (tile in tiles) {
    
    matrix.tx = Math.random () * 800;
    matrix.ty = Math.random () * 600;
    tile.matrix = matrix;

} 

tilemap.setTiles (tiles);

So each tile in TileArray, you can also set tiles.position then set the properties for that tile, then change to another position. It’s kind of like Tile, but all in one object

Thank you for the example!

I’m not sure I understand the matrix part, but appart of that, everything makes sense. Like you said, it’s all in one object. Do you think it would help my FPS if I use TileArray?

It’s possible! Neko is known to be slow (currently), so TileArray might require less CPU