I'm using a LevelManager to load Tiled maps in my libGDX game, which stores:
Sizeof map in Tiles
Sizeof map in Pixels
Sizeof an individual tile
When the map is loaded, it creates a new World and stores it in the static
WORLD, later populating it with static bodies based on objects found in the map's Collision layer.
My reasoning for using static is down to the fact that logically, only one map will be playable at any one time, however I've got it in my head that only constants and singletons should be static, so this feels strange for me. Is there a better, more efficient way of handling this?
Should I have one World per Level, or a global World independent of what TiledMap is active?
In other words, should I initialize
WORLD once and leave it as is, making it final, or continue what I am doing and initialize it as a new World whenever a new TiledMap is loaded?
How do I correctly dispose of all bodies within the World, essentially clearing it?
I'm going to have to do this every time I load a new map, regardless of whether or not
WORLD is global.