1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 GUI Sprite Based Menus

Discussion in 'Programming' started by JeanSwamp, Oct 9, 2018.

Tags:
  1. JeanSwamp

    JeanSwamp Member

    Joined:
    Jan 11, 2018
    Posts:
    131
    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
    [​IMG]

    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
     
  2. Morendral

    Morendral Member

    Joined:
    Jun 27, 2016
    Posts:
    387
    Draw to the gui layer and then use commands to get the mouse in the gui layer. It's in the documentation
     
  3. JeanSwamp

    JeanSwamp Member

    Joined:
    Jan 11, 2018
    Posts:
    131
    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?
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,110
    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/
     
  5. JeanSwamp

    JeanSwamp Member

    Joined:
    Jan 11, 2018
    Posts:
    131
    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?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice