I have a game which does not/cannot use a "Loading Screen". I'm having some trouble using AssetManager
to load assets on the fly after an Ad shows, or an IAP process happens - essentially whenever the OpenGL context changes.
I've followed the wiki article on AssetManager, but I'm still seeing black textures whenever I try to load a "new" texture.
I have a Singleton
custom GameAssetManager
which has some convenience methods which delegate to LibGDX's AssetManager
.
For example:
public Texture getTexture(String filename) {
if (assets.isLoaded(filename)) {
return assets.get(filename, Texture.class);
} else {
assets.load(filename, Texture.class);
assets.finishLoadingAsset(filename);
Texture texture = assets.get(filename, Texture.class);
sessionAssets.put(filename, texture);
return texture;
}
}
In my AndroidLauncher
, I override the onResume
method like so:
@Override
protected void onResume() {
super.onResume();
GameAssetManager.instance.resume();
}
The GameAssetManager.resume()
method just does this:
public void resume() {
assets = new AssetManager();
Texture.setAssetManager(assets);
}
I have a StoreItemButton
which is a Group
and which changes it's layout/ui-components when the item is purchased through Google's IAB library or an Ad shows.
After the Ad shows, or the IAB process completes AndroidLauncher.onResume
is called and when the button changes it's UI it or parts of it just turn black.
If I go through and pre-load all possible layouts - up to 4 per button (up to 30 buttons), and then just show/hide them based on the situation, it seems to work, but this is a lot of overhead and error prone for no good reason.
Any help here would be greatly appreciated.