How do I add a loading screen to a game?

Jim Scott

Member
Hi!
I'm new to videogame development and I was wondering if it's possible to add a loading screen for my game. It's basically a loading screen between the main menu and the first level, because its kinda weird to just press the start game button and then instantly start the game; that would be fine for a mobile game, but I'm making a PC game. A fade out-in could be useful for this too.

Btw I'm using Game Maker Studio Professional 1.4
 

Kyon

Member
Hi!
I'm new to videogame development and I was wondering if it's possible to add a loading screen for my game. It's basically a loading screen between the main menu and the first level, because its kinda weird to just press the start game button and then instantly start the game; that would be fine for a mobile game, but I'm making a PC game. A fade out-in could be useful for this too.

Btw I'm using Game Maker Studio Professional 1.4
What I do is start every room with a black screen that fades out.
You do this by having a object, that's in every room (your control object)
and in the GUI Draw event you have:
Code:
if startalpha>0{
        draw_set_alpha(startalpha);
        draw_rectangle_color(-1,-1,display_get_gui_width()+1,display_get_gui_height()+1,c_black,c_black,c_black,c_black,false);
        draw_set_alpha(1);
    }
This is that you create a black rectangle over your screen, with an alpha value of variable "startalpha".
Lets go to the CREATE event;
Code:
startalpha=1; //We start the game with an alpha value of 1, which is fully visible
hasstart=false; //Another variable that checks if the room has started.
Now in the STEP event;
Code:
if hasstart=false{
if startalpha>0{startalpha-=.02;}else{hasstart=true;}
}
This checks if the room just started. If so, if the alpha value of that black square that's over the screen is higher than 0, lower it to 0, so make it transparent.
Now, if you're going to a next room, like, from menu to the game, what you have to do is get 'startalpha' up to 1 again, and then change rooms.
So:
Code:
if startalpha<1{startalpha+=.02;}else{room=NEXTROOM;}
This last code should be put somewhere instead of where your room-change was.
So like, the end of a level, or after your pressed "start" on your menuscreen.
(be sure to not put this on a keyboard_check_pressed event or anything, since this code has be looped for a while for it to work. If you want it, just make another variable that switches to true when you press a key, and put above code under "if VAR = true{ //here } )




Hope this helps.

Kyon.



(DO. NOT. MAKE. FAKE. LOADING. SCREENS.)
 
Top