How to get a “loading screen” using libgdx?

I am wondering how to create a loading screen. If i use

while (!manager.update()) 

the game will never be displayed. Then I had an idea if I manually call the render method in a while loop. How:

 while (!manager.update()) render(); 

it will probably work. Then could I just create another thread and make it besides this thread? What is the best solution?

+5
source share
2 answers

You really should take a look at this wikipedia page , your visualization method should look something like this:

  public void render() { if(manager.update()) { // we are done loading, let move to another screen! } // display loading information float progress = manager.getProgress() ... left to the reader ... } 
+4
source

A very simple solution is to draw, not visualize. Let me clarify, you stop playing the game, show the loading screen at boot time, and then give it about 2 seconds to make the new screen as follows:

  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; 
+1
source

Source: https://habr.com/ru/post/1247964/


All Articles