I have been wondering how to create a loading screen. If I use
while (!manager.update())
the game will never render. Then I had an idea if I would call in the while loop manually the render method. Like:
while (!manager.update())
render();
it would probably work. Then I could also just create another thread and render in besides this thread? What is the best solution?
You really should take a look at this wiki page, your render method should be something like this:
public void render() {
if(manager.update()) {
// we are done loading, let's move to another screen!
}
// display loading information
float progress = manager.getProgress()
... left to the reader ...
}
A very simple solution is to draw over and not render. Let me elaborate, you will stop rendering the game, render a loading screen while it is loading, then give it about 2 seconds to render the new screen like so:
if(renderingGame){
//render all your stuff
if(loading){
renderingGame = false;
}else if(loading){
renderLoadingScreen();
}else(!loading){
elapsedTime += Gdx.graphics.getDelta();
}
if(elapsedTime > 3)
renderingGame = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With