I use AssetManager
to load all assets in my game.
I have problem with displaying loading progress or instead progress I try to set only background colour using this code in my LoadingScreen render method.
Gdx.gl.glClearColor(0.431f, 0.792f, 0.808f, 0xff / 255.0f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Everiting loads well but, while loading I get black screen instead colour set in glClearColor. The same happend when implementing loading bar like this example
Here part of Assests
class
public class Assets implements Disposable, AssetErrorListener {
public static final Assets instance = new Assets();
.
.
public void init (AssetManager assetManager) {
this.assetManager = assetManager;
// set asset manager error handler
assetManager.setErrorListener(this);
// load texture atlas
assetManager.load(Constants.TEXTURE_ATLAS_OBJECTS, TextureAtlas.class);
.
.
TextureAtlas atlas = assetManager.get(Constants.TEXTURE_ATLAS_OBJECTS);
.
}
.
}
Here is simple code of my LoadingScreen
:
@Override
public void show() {
manager = new AssetManager();
Assets.instance.init(manager);
}
public void render(float deltaTime) {
Gdx.gl.glClearColor(0.431f, 0.792f, 0.808f, 0xff / 255.0f);//light blue
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (manager.update()) {
ScreenTransition transition = ScreenTransitionFade.init(0.5f);
game.setScreen(new HomeScreen(game), transition);
}
}
Here I expected light blue empty screen to show while loading assets, but I get black screen.
I guess some code blocks main thread but I don't know how to fix this.
Thanks for help