How Do I Create A Loading Screen For My Game Project

edited May 2018 in How To...

Hello,

I am working on a game project. Currently I am trying to set up an introductory cut scene using some audio files and pictures. When finished I am hoping it will look something like a slide show.

I have loaded into my program an audio file roughly 1 minute in length and 9 pictures that will take up a 1600x900 screen. When I click run in the IDE there is about a 2 second delay before the program runs. My question is, how would I create a loading screen to give the player some feedback that the game is just loading the different assets?

If anyone knows of any examples or tutorials that I could read through that would be very helpful. I feel like I need to understand more about how this process works before I can get to coding. Thank you for the help.

Tagged:

Answers

  • Answer ✓

    Right now, this is the process your sketch follows:

    1) setup loads your images.
    2) setup loads your sounds.
    3) draw shows your user images
    4) Goto step 3.
    

    For most things, this works. But not for you, because you are loading a bunch of things in steps 1 and 2, and this takes a while. So long, in fact, that the user is waiting two whole seconds before they get to see the first frame at step 3.

    If it were just images, you could get away with taking the easy route and just use requestImage(): https://processing.org/reference/requestImage_.html

    But to do it right, you will need to deal with thread(). It is not easy to list a bunch of steps that demonstrates how it works. Instead, imagine you have two lists of steps, and they are happening at the same time.

    The first list is:

    1) setup starts the second list. 2) draw shows your user images.

    The second list is:

    1) load images. 2) load sounds.

    The second list starts almost immediately because the first list starts it. The second list does not block the first list from going immediately on to step 2 to show your user something.

    Maybe an example will help:

    int counter;
    int doneAt = 1000;
    
    void setup(){
      size(400,400);
      thread("slowCounter");
    }
    
    void slowCounter(){
      while(counter < doneAt){
        counter++;
        delay(1000);
      }
    }
    
    void draw(){
      background(0);
      fill(255);
      text(counter, 20, 20);
    }
    

    Right. Let's say you want to display the number 1000 to your user. This does it, but it takes 1000 seconds to get there. But the user isn't waiting 1000 seconds without seeing anything. Instead, they get to see how much progress has been made.

    Compare that to this:

    int counter;
    int doneAt = 1000;
    
    void setup(){
      size(400,400);
      while(counter < doneAt){
        counter++;
        delay(1000);
      }
    }
    
    void draw(){
      background(0);
      fill(255);
      text(counter, 20, 20);
    }
    

    Now the user is waiting in the dark for 1000 seconds without seeing anything.

    This is the same problem you are having.

  • Thank you TfGuy44, this is exactly what I needed

Sign In or Register to comment.