This is my way to deal with assets
I have Assets class which has assetsManager and only Strings of files path
public class Assets {
public static AssetManager manager = new AssetManager();
public static final String background = "bg.png";
public static final String menu = "menu/menu.atlas";
public static Texture getTexture(String name) {
return manager.get(name, Texture.class);
}
public static TextureAtlas getTextureAtlas(String name) {
return manager.get(name, TextureAtlas.class);
}
public static void dispose() {
manager.clear();
}
}
In Screen I load Assets
public class MenuScreen implements Screen {
public void show() {
//load assets
Assets.manager.load(Assets.background, Texture.class);
Assets.manager.load(Assets.menu, TextureAtlas.class);
Assets.manager.finishLoading();
}
}
when I use them I do this
Texture background = Assets.getTexture(Assets.background);
I call dispose in Game Class only
public class GameMain extends Game{
@Override
public void dispose() {
super.dispose();
Assets.dispose();
}
}
My question :
Is this a proper way to manage assets or am I doing anything wrong ?
Another question I have a stage (which have actors which use textureRegions)
In PlayScreen to dispose it(with its textures) I call stage.dispose() only
public class PlayScreen implements Screen{
@Override
public void dispose() {
stage.dispose();
}
}
Is this proper or not ?