![graphics programming – How do I deal with Game Screens in LibGDX? graphics programming – How do I deal with Game Screens in LibGDX?](https://thefuntrove.com/wp-content/uploads/https://cdn.sstatic.net/Sites/gamedev/Img/apple-touch-icon@2.png?v=9bca23db2259)
[ad_1]
Here is how I deal with the property with out reloading them for every screens. You ought to load your asset in your essential sport class like this
public class MyGame extends Game {
personal AssetManager assetManager;
@Override public void create() {
this.assetManager = new AssetManager();
this.assetManager.load("degree.tmx", TiledMap.class);
this.assetManager.load(...)
this.assetManager.load(...)
// power the asset supervisor to complete loading
this.assetManager.finishLoading()
// inject the asset supervisor to your display screen
this.setScreen(new LevelScreen(this.assetManager));
}
@Override
public void dispose() {
this.assetManager.dispose();
}
}
This approach if I have to reload the LevelScreen
I simply have to re inject the assetManager to the brand new display screen with out reloading any ressources.
To retrieve a useful resource from the asset supervisor, simply use
// this retrieve the tiled map from the asset supervisor with out reloading it
TiledMap levelMap = assetManager.get("degree.tmx");
[ad_2]