Simple GUI Buttons in GameMaker Studio 2

Поділитися
Вставка
  • Опубліковано 19 гру 2024

КОМЕНТАРІ •

  • @SamSpadeGameDev
    @SamSpadeGameDev  4 роки тому +7

    Note: the GUI 'layer' isn't a real layer, it's just easier to refer to it that way. Instances would be on the same layers they always are its just that the gui draw events happen after all prior draw events and with their own resolution.

  • @mathieuDBilly
    @mathieuDBilly 22 дні тому

    4 years later, this little trick is still working
    Thank you so much

  • @juliansilvestri5044
    @juliansilvestri5044 3 роки тому +8

    As an amateur you have saved me. I was overthinking this and you couldn't have explained it better! Keep up the videos!

  • @simplebutamazing3613
    @simplebutamazing3613 2 роки тому +1

    Thank you! For those who were a bit confused like me, I was confused because I thought that by manually placing the object carrying the GUI code in one spot, it would prevent me from interacting with it if I moved to a different location in my game map because the object itself would be located in another area while the GUI stays on one spot in the layer. Luckily this is not the case, as you can interact with the new GUI button from any point in the room after moving! Thanks for the tutorial!

  • @mrnobody7600
    @mrnobody7600 4 роки тому +3

    Man I love you no homo I watched tons of videos and read a lot of guides but none of them worked and they were all so complicated.

  • @alexandergovorov6708
    @alexandergovorov6708 3 роки тому +2

    Dang it, I've figured out this trick myself and wanted to make a tutorial LoL
    Good job!

  • @GangeSatoya
    @GangeSatoya Рік тому

    Thanks to this video, I were able to implement GUI buttons on the actual Android device! Thank you so much!

  • @ottamonk
    @ottamonk 3 роки тому +1

    love your tutorials, everything s so well explained and planned step by step, gonna get big soon enough!

  • @karlstenator
    @karlstenator 3 роки тому +2

    Classic vid, how did I miss this one? UI buttons are a lot more fun now that we have nine slice for our sprites. 😃

  • @mountainshark2388
    @mountainshark2388 4 роки тому +3

    You explained it so perfectly, thank you very much!

  • @meganoob9281
    @meganoob9281 3 роки тому +2

    really simple explanation, thanks

  • @aleksandersanya1817
    @aleksandersanya1817 2 роки тому +1

    How frustrating it was to create a basic UI and then figure out it is completely broken if I move my viewport. But now I know what to do. Thanks!

  • @markv6684
    @markv6684 2 роки тому +2

    thank you, love youre videos

  • @clintos3740
    @clintos3740 3 роки тому +2

    Fantastic tutorial! But if you've got multiple rooms, having to add the buttons every time in every room doesn't seem to practical. Would there be any way to go around this?

    • @SamSpadeGameDev
      @SamSpadeGameDev  3 роки тому +1

      For small games (e.g. gamejams) I actually do just put them in every room, but for larger projects I generally have an initializing room before gameplay where I create objects that need to be persistent across multiple rooms but, for example, shouldn't be in the main menu. I would then have these buttons be marked as persistent and generally a child of some parent so that when you do something like go to a menu where they shouldn't show up you can either deactivate or destroy them.
      Another option would be to use placing them in the room merely as visual guide. You could then make note of their position and create them through code.
      For a similar but slightly different approach you could see this video: ua-cam.com/video/RbBgE3cUShc/v-deo.html

    • @clintos3740
      @clintos3740 3 роки тому +1

      @@SamSpadeGameDev Thanks a bunch, this actually makes sense! Definitely going to check that video out, cheers :)

  • @stravvman
    @stravvman 3 роки тому +3

    But how can I create objects "inside the GUI" with code?

    • @SamSpadeGameDev
      @SamSpadeGameDev  3 роки тому

      I'm not sure what "inside the GUI" means in this case. But to take a guess, you don't create anything inside the gui, you just create an instance of an object (by placing it in the room or using instance_create_*) and then use it on the gui layer.

    • @stravvman
      @stravvman 3 роки тому +1

      @@SamSpadeGameDev Yeah, I'm talking about instance_create. What kind of coordinates should you use? Room coordinates?

    • @SamSpadeGameDev
      @SamSpadeGameDev  3 роки тому

      It depends on how you want to interact with it. An instance's x and y are just numbers, but GameMaker does use them for certain things by default. For example, draw self uses them and the sprites origin point to determine where to draw the sprite. If draw self is used in the draw event, it will be drawn using the room's coordinates. If draw self is used in the draw gui event it will drawn using the gui's coordinates. GameMaker also uses the x and y and any mask assigned to the object determine things like collision or position meeting. The built in events that rely on a mask all use the x/y position in the room, that's why I'm using the step event and checking for a position based on the mouse's gui position.

  • @alexanderrudi2396
    @alexanderrudi2396 3 роки тому +2

    thanks, help me a lot.

  • @thedonmarlo
    @thedonmarlo 4 роки тому +1

    My player object uses mouse_x and mouse_y to move around, when I applied this code the button is completely unresponsive. I was able to change the size of the GUI layer but there's no response from the button object...

    • @thedonmarlo
      @thedonmarlo 4 роки тому

      I watch this tutorial over and over again and I can't get the button to show the message. I'm not sure what I'm doing wrong, I set my GUI to the same resolution as my game. It's right there in the middle of the screen, click it, no response.

    • @SamSpadeGameDev
      @SamSpadeGameDev  4 роки тому

      I'd be happy to look at it. A couple questions:
      - which version of GM (2.2, 2.3, etc.) are you using?
      - What device (windows, mac, android, etc.) are you testing on?
      - Even though it seems redundant, can you post both your code and the events the code is in?

    • @thedonmarlo
      @thedonmarlo 4 роки тому +1

      @@SamSpadeGameDev In my haste, before setting the GUI size, I changed position_meeting to place_meeting. After I set the size of the GUI, place_meeting was not effective and I forgot to change it back! Once I set it back to position_meeting it worked... hehe. In case anyone else has this issue (doubtful) !!! HA. Thank you for your time and tutorial

  • @memine5595
    @memine5595 Рік тому

    Is this the best way for gui buttons that keep proportions and position on mobile devices and computers.

  • @Javabox04
    @Javabox04 2 роки тому +1

    Thanks man!

  • @ushinattaGame
    @ushinattaGame 10 місяців тому

    Hi,
    My Wish is to show the GUI as a journal to write in. Like an inventory. its there on the key presses trigger, but now Always, i struggle to do that :(

    • @ushinattaGame
      @ushinattaGame 10 місяців тому

      Well, i figured it out. But very much needed the video for the rest, thanks a lot :)

  • @antononrails3984
    @antononrails3984 3 роки тому +2

    Life saver!

  • @upandcomingmoviestareditorprod
    @upandcomingmoviestareditorprod 2 роки тому

    how do I hide the text at the top?

    • @SamSpadeGameDev
      @SamSpadeGameDev  2 роки тому

      I'm not sure what you mean. Text at the top of UA-cam? GameMaker? Your own game? I might need a little more detail here.

    • @upandcomingmoviestareditorprod
      @upandcomingmoviestareditorprod 2 роки тому

      @@SamSpadeGameDev the X and Y of the mouse and stuff

  • @nomi_101
    @nomi_101 2 роки тому +1

    I did what you did. I have no idea what i did. But its doing the did

  • @Lackingworth
    @Lackingworth 10 місяців тому

    Become my teacher

  • @syffin8372
    @syffin8372 4 роки тому +3

    Great tutorial and helper me a lot but u mispronounced GUI every time lol. It’s pronounced (gee-you-eye) in case u were wondering. But other than that amazing tutorial!!!

    • @SamSpadeGameDev
      @SamSpadeGameDev  4 роки тому +2

      Thanks! GUI actually has two valid pronunciations (Gee-you-eye and Gooey) and it might depend on regions as to which is more common. Gooey is the more common pronunciation were I'm at.

    • @syffin8372
      @syffin8372 4 роки тому +2

      SamSpadeGameDev ok that’s fair. Still thanks a lot