My approach is always like this:-
Create my own manager class that receive instance if AssetsManager and load all game assets when game is initially loaded
public class Assets implements Disposable{
public static final Assets instance = new Assets();
private AssetManager manager;
// Individual assets
public PlayerAssets playerAssets;
private Assets(){}
public void init(AssetManager manager){
this.manager = manager;
manager.load(..);
manager.finishLoading();
TextureAtlas atlas = manager.get(..);
playerAssets = new PlayerAssets(atlas);
}
public void dispose(){
manager.dispose();
}
/** Sample Inner class for catching loaded game assets */
public PlayerAssets{
public final AtlasRegion legs;
PlayerAssets(TextureAtlas atlas){
legs = atlas.find(..);
}
}
}
On your game class you load all game assets.
public class MyGame extends Game {
@Override
public void create(){
Assets.instance.init(new AssetManager()); // loading your resources
setScreen(new GameScreen());
}
}
Update from the comment below
Disposing your assets. You might want to create an abstract class for all your screen as follows
public abstract class AbstractScreen implements Screen{
protected Game game;
public AbstractScreen(Game game){
this.game = game;
}
}
. . . . . .
public void dispose(){
Assets.instance.dispose();
}
Then all of your Screens will extend this class. eg
public class MenuScreen extends AbstractScreen {
public MenuScreen(Game game){
super(game);
}
}
Calling screen instance dispose method will dispose all of the resources,
you can override it for places where you might prefer different behaviour
eg
@everride
public void dispose(){
// super.dispose();
// Release other screen resources
}
Where to call screen dispose is definitely up to you.
Also you might want to show loading screen when you load the assets to avoid blank screen due to loading delays
If you override dispose as above disposing a screen wont dispose the assets