I am looking for a solution to have a really big tilemap loaded at run time and get the best performance I possibly can.
As of now the performance is degrading slightly due to how big of a json file i am loading into phaser is causing lower end machines to crawl down to 15-20fps which is unplayable.
Has anyone come up with a clever way to load big tiled maps without performance degrading, and without introducing transitions from one map to another? (in other words rollovers via legend of zelda 1 on NES isn’t viable solution)
Another question: Does phaser render stuff outside of the current screen (or canvas) bounds? Or do we need to specify that in an option somewhere?
Phaser does not render anything outside of the current screen, but it might process those gameobejcts/tiles anyway (not the rendering phase). If you need speed, try creating a StaticTilemapLayer instead of a Dynamic one.
Only dynamic tilemaps are culled afaik. Static ones can’t be culled and for general game objects I think you need to do it manually (using visible or alpha). There is a method in camera to get a list of culled objects, but with such high amounts you would need to handle it in customized, optimized way.
Try dynamic layer, although that might still be too slow. Solution would be to load/unload the map in segments so there’s never too much to work with.
What requirements are those? Dynamic can do more than static, so unless I’m missing something there’s no possible valid requirement except performance, which is what we are trying to improve here.
It needs to be static because it needs to be static?
I could try loading it dynamically but the map is not going to change (Im speaking in terms that no sort of procedural generation is going to occur). I guess you could say it is “business level requirements that the map remains consistent and always renders the same”.
Changing from static to dynamic and fps on this crap work machine I’m using went from ~31-33 fps to ~58-60 (and i’m clamping fps to 60 manually).
INCREDIBLE. Thank you so much. Literally worked like a charm without changing anything but createStaticLayer to createDynamicLayer. Loading 1million tiles with this is awesome.
@Antriel was right, I forgot StaticTilemaps aren’t culled. But they are super fast for small maps for that very same reason. On the contrary, they are super slow for giant maps. Richard explained this very clearly in this devlog if you are curious: https://phaser.io/phaser3/devlog/122