Big TiledMap

Anything libgdx related goes here!

Big TiledMap

Postby diazndc » Mon Sep 02, 2019 1:12 am

I'm trying to archive a big map on my game, 2400x900 of 64x64 tiles using TiledMap and LibGDX.

What is the difference in performance of using a 100x50 tiledmap vs a 2400x900 map? Say they both have the same tile set images, I mean the images used for the 100x50 will be the same as the 2400x900, so why shouldn't I do it? If there's a hit on performance, why? resources are the same, and the tiles are only rendered when on screen.

So knowing this the only thing that I can think that can hit performance is:

    - The information stored in memory for each tile, there will be

    - `TiledMapRenderer` Looping to find the correct tile to draw.

If the answer is (1) when I call `tilemap.dispose()` do I free all this memory instantly or wait until gc do his thing?

If the answer is (2) I dont know how `TiledMapRenderer` works but can it be optimized using some sort of quadtree implementation?

If the answer is both please answer both.

Loading Screens

So, I've read of having to use loading screens, and split the map.

I was thinking to write a small program to split this big tiledmap and generate a few json files `map1.json` `map2.json` etc.

Then in the game I use those json files to create a new TiledMap(). So I can load the correct sections of the map in a loading screen, when needed.

Problem is that I don't know if I should `tilemap.dispose()` the old `tilemap` since I will be needing the tileset images again, So I guess my question are:

    1. When calling `dispose()` do I dispose images only(tilesets) or both images and memory from tiles?
    2. If `dispose()` only dispose images, then I guess garbage collector takes care of the memory stored from tiles, positions, properties etc etc. And I wont need to call `tilemap.dispose()` right?
Posts: 4
Joined: Mon Sep 02, 2019 1:02 am

Re: Big TiledMap

Postby shatterblast » Mon Sep 02, 2019 5:14 pm

1) You can relate your TiledMap to your AssetManager. Example code: ...

2) I wouldn't worry about optimization unless you either plan to include thousands of objects or for some reason want to add a mesh with high triangle count in a 3D environment. (Yes, it is very possible to mix in 3D if you want.) At that point, it becomes more of a matter towards reducing the number of your used objects or the triangle count. Both LibGDX with how it handles TiledMap and OpenGL with its math stuff come quite optimized.

If you want to split up your level design, that is one thing. In that case, a loading screen would make sense. However, I would suggest not trying to "split" the TiledMap. Do what pleases you, though. Someone may have better advice than me in that area.

As far as dispose() for TiledMap, please, reference 1) above. The idea involves using dispose() on your AssetManager as normal, because you would reference your TiledMap through it.
Posts: 653
Joined: Sun Jul 06, 2014 1:14 pm

Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest