Many tutorials I've seen put the loading of assets via AssetManager in a dedicated screen which displays some progress bar or image while the loading happens in background. Each "real" screen then gets the resources it needs from the asset manager, typically in the constructor, eg
public class GameScreen extends ScreenAdapter {
private MyGame game;
private Texture t1;
private Sound s1;
public GameScreen(MyGame game) {
this.game = game;
AssetManager am = game.getAssetManager();
t1 = am.get("....", Texture.class);
s1 = am.get("....", Sound.class);
}
// use t1 and s1
Now another source I've seen takes this concept a bit further and also does the actual get()s in the asset loading class, so screens don't have to do them themselves, eg
// in the Loader class
public AssetManager am = new AssetManager();
public Texture t1;
public Sound s1;
...
am.load(...);
am.load(...);
am.load(...);
// finishLoading() or update()....
...
t1 = am.get(...);
s1 = am.get(...);
...
// in the screen class
t1 = game.am.t1;
s1 = game.am.s1;
...
// use t1 and s1
Now my question is: is this good practice? What's the expensive part of loading assets, the AssetManager's .load()
s or also the .get()
s? (I thought it was only the .load()
s.) Is removing the get()
s from the screens really a performance gain?