GameMaker GUI Sprite Based Menus

JeanSwamp

Member
Hello,

I'm trying to figure out how to make a Pause Menu, heavy sprite based. This is an example of what I'm looking for:

https://gfycat.com/WelldocumentedBarrenAndeancat


I suppose it needs to be Drawn to GUI since this would be a pause menu and I want to switch between menus in a similar way the example does or so.

Could someone with experience in doing something close to this point me out in the right direction?

Thanks
 

Morendral

Member
Draw to the gui layer and then use commands to get the mouse in the gui layer. It's in the documentation
 

JeanSwamp

Member
Yeah, that was not my point sorry. Also I want to use gamepad or keys to move, but thats not my biggest concern.

Mostly is how to keep those buttoms at the bottom and be switching different sprites according to the menu. About the menu scrolling in I supose is some lerp?
 

samspade

Member
I would say your question has two parts. First, moving objects. Second selecting objects. Both of these have to be done on the GUI layer.

For moving objects, you just want to do it like normal except relative to the GUI layer. The type of movement you see in the gif is some type of easeing or tweening - which is effectively a lerp with slightly different parameters. You can find free assets for it on the marketplace and tutorials on YouTube (try tweening coding math or ease in ease out code workshop). Have an onscreen point and an offscreen point and tween between them when you want (on create, on activate, etc.). Remember all movement is relative to the GUI layer, not the room layer.

For selecting, if you want to do it with a mouse or touch, then Morendral is right, you just translate the mouse to the GUI layer use device_mouse_x_to_gui. If you want to do it with a keyboard or gamepad that's obviously a little different. How I do it is like this:
  • Add all button instance IDs to an array (or if you want to be fancy a grid)
  • cycle through the array with keypresses (just find a menu system tutorial on YouTube that uses the keyboard to see what I mean or look at my free asset linked below)
  • When you 'select' something in the array run that button's script using with or some similar thing - pseudo code example:
Code:
if (select) {
    with (button_array[selected_button]) {
        script_execute(script);
    }
}
I know that's a little brief, but really your question contains like six or seven parts, some of which take a lot of explaining, so hopefully this is enough. If you have a specific question about something above though I can try to answer it.

Also, I'm currently working on a button pack. While it won't help with the first part (moving objects) it should do the second. Feel free to add comments or suggestions as I work on it:

https://forum.yoyogames.com/index.php?threads/button-pack.53632/
 

JeanSwamp

Member
Tomorrow I’m offwork and might try to start building this.

One question I have is, how do you switch all the menu for each submenu? Im guessing making each menu frame an object with its stuff on it, and call the drawning just when needed?
 
Top