GMS 2 How to run a Main Menu?


I just see a lot of Youtube tutorials about it but in no one is it explained how to do that the main menu should be run first before the whole game does load the room and the objects in the room.
So how do I do that the main menu is executed before the actual game? As soon as you want to start the game, you should first start in the main menu before starting the actual game from there!
To do that, I also need to know how to build that up with code as soon as I hit "new game". then a room with its corresponding objects is executed?


Friendly Tyrant
Forum Staff
Make a room for the main menu, and in that room have your title object and your button objects and anything else you need to make it pretty and functional. Then in the "Play Game" button object (or whatever) just use a room_goto() call to go to the first playable room of the game.


you can set one up by making an array for menu choices like so:
menu[0] = "New Game"
menu[1] = "Load Game"
menu[2] = "Quit Game"
menu_choice = 0;
then make some keypress up and down events that sets the menu_choice value to +1 or -1, and have a keypress letter that does the "selecting" of said menu:
if menu_choice = 2
and as far as the Graphical User Interface goes, I made a menu graphic as a three image sprite, set the image_speed of the menu object to 0 in the create event first before anything else, and made a step event that set the image_index to whatever menu_choice was. like so:
if menu_choice = 0
image_index = 0;
the menu sprite itself is simple, you just have 3 images, each showing an arrow in front of each menu option. about as fancy as you want it.

thats your basic menu.
for each menu_choice action in the selector keypress event, you can plug in whatever you want.
goto_next_room(), game_end(), game_save(z_save).
edit: just be sure you arrange the images in your menu sprite to correspond to your menu_choice values.
but it shouldn't be too difficult to figure it out, since there's just three options with this example. you could go more in depth with more menu options like say... "options" for general gameplay settings, audio levels, screen size etc.
just add more "menu_choice" codes in the selector keypress event to do what you want, and dont forget to add more images to the menu sprite to show what you've "selected" as it were.
Last edited:


The Main Menu room needs to be the very first room in the resource tree (or second room if you're using a preloader room).


🍋 *lemon noises*
GMC Elder
Yeah, a menu is just a room that has menu elements instead of normal game objects. I usually have separate "setup" objects that create all data in a room before the main menu (the objects set up data and then go to the next room immediately), but that's not a big concern if you don't use a lot of big data structures and other resources that leak memory if you create them more than once - just put that in the title screen object's Create event for now. (I recommend NOT using the Game Start event because it's nice to be able to reorder rooms without breaking functionality, e.g. adding a "Made by Dwighty" splash screen right at the end and suddenly none of the level data exists when you reach the title screen anymore because the object that sets it up isn't present at the start of the game anymore...)

Protip: using the Left Mouse Pressed event, you can make objects that run code when you click on them in-game. This lets you build menus in a WYSIWYG style where you place buttons and other interface elements directly into a room the way you want the menu to appear in the game.


There are actually quite a few ways to make the main menu.
If you really want to make the menu right in the game room, and not in a separate one. You can still catch all objects on the “vith”, having previously given them all the parents and for example, simply and easily make them visible equal to false.
And then draw a black rectangle on top, and on top of the rectangle show all the buttons calculating their coordinates for the "draw interface" event, for example, in the center of the screen using x and calculate your y.
And put all the menu items in a list or array.
Such a menu will be the most manageable and it will be possible to call it right during the game.

So that it is always created first, it is enough to put the menu controller as the very first object or use the room with the start code window.