My understanding is that you initialize the AssetManager as a non-static object in your main class and load the sprites you need...
manager = new AssetManager();
manager.load("sprite_sheet.txt", TextureAtlas.class);
manager.finishLoading();
I then modified my abstract State class by adding AssetManager to the constructor...
State(GameStateManager gsm, AssetManager manager) {
this.gsm = gsm;
this.manager = manager;
Now say I have 5 blocks in my sprite sheet called block0, block1... block5 would it be appropriate to create a BlockTextures class like this?
private static TextureAtlas textureAtlas;
public BlockTextures(AssetManager manager) {
textureAtlas = manager.get("sprite_sheet.txt", TextureAtlas.class);
}
public static AtlasRegion get(int id) {
return textureAtlas.findRegion("block" + id);
}
public static void dispose() {
textureAtlas.dispose();
}
Where I call BlockTextures.dispose() in my Game.dispose() method?
public void dispose() {
BlockTextures.dispose();
}
While this code seems to work fine I feel like I am not using AssetManager correctly.