Buttons GUI | GameMaker Studio 2 [ UI Series: Part 1 ]

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

Комментарии • 122

  • @andrzejvlasov1689
    @andrzejvlasov1689 3 года назад +26

    At 5:06 at newer versions of Game maker you should put in like this:
    function create_button(x,y,width,height,text,script){
    ...}
    instead of
    ////@arg x,
    ////@arg y...
    It made buttons work for me in game maker language.

    • @jam8munch811
      @jam8munch811 2 года назад +3

      I actually replaced the arguments completely in the function parentheses like so
      function create_button(_x,_y,_width,_height,_text,_script)
      {
      //create button
      var _button = instance_create_layer(_x,_y,"Instances",obj_button);
      //set values
      with (_button)
      {
      width = _width;
      height = _height;
      text = _text;
      script = _script;
      }
      As long as you reference the correct width, height, text and script from earlier it works fine ;)

    • @mitch.sorenstein
      @mitch.sorenstein Год назад

      @@jam8munch811 thanks bro

  • @developerbarry
    @developerbarry 2 года назад +9

    for those who get error in get_hover scripts, here's the code to fix it:
    function get_hover() {
    var _mouseX = device_mouse_x_to_gui(0);
    var _mouseY = device_mouse_y_to_gui(0);
    return point_in_rectangle(_mouseX, _mouseY, x, y, x + width, y + height);
    }

    • @AL-xr6yz
      @AL-xr6yz 2 года назад

      True life saver

    • @anhimator
      @anhimator 2 года назад

      thankyou!

    • @TheMonkey82
      @TheMonkey82 Год назад

      this does not seem to be working for me

  • @mademygames6525
    @mademygames6525 5 лет назад +21

    Your videos are the perfect example of how tutorials should be. fast, straight to the point and easy to read. good job. excellent channel!

  • @nilynhya9972
    @nilynhya9972 5 лет назад +8

    one of the few places on the internet that has up-to-date and well-exposed game maker tutorials. I couldn't follow my dream of creating games if it wasn't for you. thanks!

  • @CrokeyHigati
    @CrokeyHigati 5 лет назад +17

    Very good tutorial! Clear, easy to follow and doesn't waste any time.

  • @AngelsOfCydonia
    @AngelsOfCydonia 5 лет назад +6

    Just found this video and i love the process of how you explained everything with on screen details. 10/10

  • @eggbert333
    @eggbert333 3 года назад +1

    You have absolutely the best GM tutorials on youtube. Well done and thank you.

  • @zombievex4253
    @zombievex4253 2 года назад

    Tried to skip through this video, didn't work, so I watched the entire thing. You, sir, have earned a like, it's exactly what I needed

  • @iTzLiru
    @iTzLiru Год назад

    In the segment get_hover...
    device_mouse_x_to_gui(); and device_mouse_y_to_gui(); are functions in Game Maker Studio 2 that convert the position of the mouse on the device (such as a computer screen) to the position on the GUI (Graphical User Interface) of the game.
    The device_mouse_x_to_gui(0) function takes the x-coordinate of the mouse on the device and converts it to the x-coordinate on the GUI. Similarly, the device_mouse_y_to_gui(0) function takes the y-coordinate of the mouse on the device and converts it to the y-coordinate on the GUI.
    These functions are useful when designing GUI elements in the game that need to be interacted with using the mouse. By using these functions, the game can accurately determine where the user has clicked on the GUI and respond accordingly.
    It's worth noting that the parameter 0 passed to these functions specifies the index of the mouse device being used. If the game is designed to support multiple mice (such as in a local multiplayer game), a different index can be used for each device. However, if only one mouse is being used, the index is always 0.

  • @NeverduskX
    @NeverduskX 2 года назад

    Wonderfully paced. I appreciate the small polish effects, like getting brighter and moving slightly on hover. I've done similar things but definitely learned a few shortcuts.

  • @andrzejvlasov1689
    @andrzejvlasov1689 3 года назад

    Stuff stops working, after 4:50 ... aslo script thing is different color in my case.

  • @zachcollette5608
    @zachcollette5608 3 года назад

    Thank you man, I hadn't checked out your channel before, but I love the quick pace on this and how you get right to exactly how your stuff works.

  • @mirnalthapa1013
    @mirnalthapa1013 3 года назад +1

    for some reason i get error in get_hover script, says the think it no defined value or width and height

    • @Alasdare
      @Alasdare 3 года назад +1

      I'm running into the same problem right now. If you found a solution let me know, but I think its due to a change in language

  • @NeZversSounds
    @NeZversSounds 5 лет назад +4

    Oh, neat tricks I didn't think of. Thanks for the cool tutorial. ;)

  • @cloudythb
    @cloudythb 3 года назад

    You, sir, make the greatest GameMaker tutorials. Thanks a lot for all of them!

  • @SleepyyBox
    @SleepyyBox 4 года назад +2

    Awesome tutorial! Only question is how do I make the buttons do things?

    • @GameMakerStation
      @GameMakerStation  4 года назад +2

      Apply a script function to its script variable. That function will be executed when you click on the button.

    • @SleepyyBox
      @SleepyyBox 4 года назад

      @@GameMakerStation thank you! I subscribed :)

    • @SleepyyBox
      @SleepyyBox 4 года назад

      @@GameMakerStation I doesn't seem to work. I added the scipt I wanted to execute in my obutton step event

    • @TheMalitias
      @TheMalitias 3 года назад

      @@SleepyyBox Well, it's a bit late, but you didn't do what he said then. The scripts name has to go in the create_button function as a parameter.
      create_button(30,30,300,100,"my button",myScript);
      The myScript here is the name of the script that will be executed once you press the button, because the attribute "script" of the button references this script.
      It's a bit hard to understand if you're new to programming because it means you need to understand what function pointers are.
      Also the "step" event is the event that is called each and every frame of the game for as long as the object remains in the game world/room.
      If you just call the script there you almost certainly hardcode this object (your button) to only be able to call this script.
      The point of this tutorial was to make modular buttons, meaning a base object that is able to "morph" into whatever kind of button you want it to be while also not hardcoding the scripts that are run by a button to be exclusive to button presses.

  • @mareksieczko9943
    @mareksieczko9943 4 года назад +1

    Excellent video, just what I was looking for. Your tutorials have helped me a bunch!

  • @dimusikus
    @dimusikus 2 года назад

    всё очень просто, и к тому же выглядит очень профессионально и красиво.

  • @tomekipro1687
    @tomekipro1687 2 года назад

    there is the posibility to block button by sprite?

  • @MaknaEXMachina
    @MaknaEXMachina 4 года назад +1

    This is exactly what I needed! Fantastic tutorial, thanks a bunch!!

  • @randomfips8320
    @randomfips8320 4 года назад

    I'm not sure if it's very efficient to put var in a step event cuz you're creating and destroying a variable 30 or 60 times per second (or depending on your room speed), it's not a huge difference but when making a commercial game it's something to consider.

    • @GameMakerStation
      @GameMakerStation  4 года назад

      Don't worry, that's not going to slow your game down. Local variables in frame events are used a lot.

    • @randomfips8320
      @randomfips8320 3 года назад

      @@GameMakerStation really? I might have been mistaken, I'll look more into that thanks

  • @CainTheBoss
    @CainTheBoss 3 года назад

    This video was extremely helpful! Thanks for pinning the comment about how to fix the script now that gms2 script system has changed. I worked with this and combined it with Scribble to make it when i hover over buttons the text changes to be wavy and stuff.

  • @hn-kj6ny
    @hn-kj6ny 4 года назад

    At 8:28 try to place your mouse cursor at the exact bottom limit of one of the rectangles. There is a bug that will make the rectangle shake (go up and down indefinitely as long as the cursor is at the bottom limit. Any way to fix that ? ^^

    • @riddenstudios277
      @riddenstudios277 Год назад

      I know this is a bit old but:
      Most persons are not going to hit the bottom of the box to see what happens. If it concerns you that much you can try minimizing the "hover" area by adding a couple of pixels inward for all sides. Something like:
      point_in_rectangle( mx, my, x + 2, y + 2, x + width - 2, y + height - 2 );
      This might not solve the actual problem but will allow persons not to put there mouse on a border they can see. Trying to find a border that cannot be seen is harder to keep a mouse on. At least I would think so from my own experience.

  • @misticloud_real
    @misticloud_real 3 года назад

    General Kenobi
    Also very helpful tutorial, thanks

  • @synthesisgames
    @synthesisgames 2 года назад

    Can you pass a variable into the on_click script? If not, then these buttons are locked into certain scripts and can't be dynamic. I tried passing a variable into on_click(x,y) but then the click no longer functions and the script just runs whatever code is in it without clicking on the button.

  • @Panonthecake
    @Panonthecake 4 года назад +2

    Great video, but how does one make the buttons actually... Ya know, do stuff?

    • @GameMakerStation
      @GameMakerStation  4 года назад +1

      The create_button() function takes a script argument, so whenever you click on a button, that script will be run. You can do your stuff in that script. ;)

    • @panonthecake4707
      @panonthecake4707 4 года назад

      Thanks!

  • @bioyado
    @bioyado Год назад

    how do you create a play again button?

  • @Cloud7050
    @Cloud7050 3 года назад

    Lifesaver, and love your interesting accent

  • @davidsaez5161
    @davidsaez5161 3 года назад

    i loved it!! you are amazing bro! THANK YOU SO MUCH!

  • @drkimchi007
    @drkimchi007 4 года назад

    excellent; well explained, and the code is so elegant!

  • @porschiii
    @porschiii 3 года назад

    Short question: In the User Event 1 you destroy all the buttons. What can I do to only destroy one specific button?

    • @GameMakerStation
      @GameMakerStation  3 года назад

      Store the button's ID in a specific variable when you create it, and reference that variable in instance_destroy().

    • @porschiii
      @porschiii 3 года назад

      Yeah thank you! That worked fine for me :)

  • @MadEzio
    @MadEzio 3 года назад

    I am not able to use the menu with the Keyboard button. Please help me...

    • @GameMakerStation
      @GameMakerStation  3 года назад

      Please join the Discord server linked in the desc, you can get help there.

    • @MadEzio
      @MadEzio 3 года назад

      @@GameMakerStation I have already joined the discord channel. I will ask for help in the discord channel. Thanx for replying.

  • @aaronwise1089
    @aaronwise1089 4 года назад

    You can always use events and image_index and image_speed and alarm events, and they look fancier this way, for a real eye candy effect

  • @andrewashby70
    @andrewashby70 5 лет назад +1

    Pardon my ignorance, but does this work for gamemaker 1?

    • @GameMakerStation
      @GameMakerStation  5 лет назад +1

      It should! If you face any issues, let me know. You can find me in my Discord server (link is in the desc.).

    • @andrewashby70
      @andrewashby70 5 лет назад

      @@GameMakerStation brilliant! I'll be giving it a shot tonight!

    • @xeonviento9778
      @xeonviento9778 5 лет назад

      Yes it works for Gamemaker1. Just implemented it, really great tutorial!

  • @Limekys
    @Limekys 5 лет назад

    Oh ma gad! I start making ui and buttons today and you upload a tutorial about that! Good tutorial!

  • @TheOrigin79
    @TheOrigin79 4 года назад

    Awesome tutorial - thank you - that helped me alot!

  • @mythology100
    @mythology100 5 лет назад

    subscribed. This will help my youtube-updated project for sure.

  • @folkhero2046
    @folkhero2046 4 года назад

    Great tutorial, high quality, love the accent

  • @maulssdq6196
    @maulssdq6196 3 года назад

    is there a video for the second part?

    • @GameMakerStation
      @GameMakerStation  3 года назад

      ruclips.net/video/KjtAhp4rhP4/видео.html&ab_channel=GameMakerStation-Matharoo

  • @ventiladorbueno1846
    @ventiladorbueno1846 5 лет назад +1

    Thanks for your teaching, Thanks a lot !!!!!

  • @marcosalazar0052
    @marcosalazar0052 5 лет назад

    you will make a video of how connect 2 socket to one server, plix

    • @GameMakerStation
      @GameMakerStation  5 лет назад

      That should be simple to do. What have you tried?
      You can hit me up in my Discord server: discord.gg/TykHyqK

  • @springbertstudios7005
    @springbertstudios7005 2 года назад

    If you seen what I made with your tutorial you would know that I stopped at a certain point and started to use only custom code I feel quite proud of myself that I got it to work on a prototype level

  • @georgehennen
    @georgehennen 3 года назад

    I amm not sure why this doesn't work. Maybe the new engine updates. If anyone can help lemme know. HIs tutorials are always the best but game maker makes them outdated sometimes.

  • @bryceisbryce
    @bryceisbryce 4 года назад

    I dont see the buttons when I play it

  • @waxfreeointment2121
    @waxfreeointment2121 5 лет назад

    Great video, I am still on GM1.4 and instance_create_layer doesn't work. However, I love how you made the button in the beginning. Thank you!

  • @FlankoTanko
    @FlankoTanko 2 года назад +1

    Question: Could you PLEASE copy and paste the code somewhere in the video's description?

  • @pabingamesandpublishing2191
    @pabingamesandpublishing2191 3 года назад

    Hello GameMakerStation - Matharoo
    I am John from Pabin Games We found this very useful do we need to credit this in our game?

  • @KungFuChowder
    @KungFuChowder 4 года назад

    So I just followed this tutorial and spent like a half hour writing all this script only to get all kinds of errors that I cannot fix. :(

    • @GameMakerStation
      @GameMakerStation  4 года назад

      You can get help from the Discord server linked in the description.

    • @misterr3083
      @misterr3083 4 года назад

      I would recommend just going through it slowly. I just followed the tutorial and everything seemed to work fine. Let me know if you still have any problems.

    • @KungFuChowder
      @KungFuChowder 4 года назад

      I think it's a version issue. I've got the latest version and he's probably using an old.

    • @KungFuChowder
      @KungFuChowder 4 года назад

      I did manage to make a working GUI button system using point_in_rectangle and switch(rooms). Way easier.

  • @unoduotilutiluduo6409
    @unoduotilutiluduo6409 4 года назад

    I can't use in gms2 new update lol
    Help

    • @GameMakerStation
      @GameMakerStation  4 года назад +1

      If it's a script issue, check out this video: ruclips.net/video/KUgZEPqlNtE/видео.html&ab_channel=GameMakerStation-Matharoo

  • @barthaddock3151
    @barthaddock3151 4 года назад

    how would you make left & right click functionality with the same button?

    • @GameMakerStation
      @GameMakerStation  4 года назад

      Use mb_right to check for right-click input, and add another script argument in the button creation script, for the right click.

  • @mrorange159
    @mrorange159 4 года назад

    Great tutorial thank you :)

  • @alekseimundoblanco5834
    @alekseimundoblanco5834 4 года назад

    and part 2?

  • @mrorange159
    @mrorange159 3 года назад

    Hey I'm just wondering, are you self taught or did you go to college/university? Thanks for the content.

    • @GameMakerStation
      @GameMakerStation  3 года назад +1

      Completely self-taught :)

    • @mrorange159
      @mrorange159 3 года назад

      @@GameMakerStation that's great congratulations, I often refer to many tutorials like yours and stitch together and modify examples to get results but I am amazed that people can invent elements like this button system on their own so easily.

  • @banish4cost
    @banish4cost 3 года назад

    WOW , youre a teacher

  • @1nc0gnit07
    @1nc0gnit07 4 года назад

    When I loaded up my project, all of my buttons were jumbled together. The hovering animation worked, but I could use some advice to know how to fix the button positioning.
    Edit: Never mind, I figured it out thanks for the video!

  • @DM-pf4fy
    @DM-pf4fy 5 лет назад

    can't wait for part 2

  • @ty88
    @ty88 6 месяцев назад

    helo dAArreeee
    velcum ta pat wun
    uv mah UI tadorialssss

  • @gameplaykinkingele5470
    @gameplaykinkingele5470 3 года назад

    Its not working

    • @GameMakerStation
      @GameMakerStation  3 года назад

      Please join the Discord server linked in the description and post your issue there with code

  • @unoduotilutiluduo6409
    @unoduotilutiluduo6409 4 года назад

    U are the best sensei

  • @ddj3428
    @ddj3428 5 лет назад

    Short but useful

  • @Javabox04
    @Javabox04 2 года назад

    Thankss man

  • @devdiary7978
    @devdiary7978 5 лет назад +2

    Networking part 4 please

    • @GameMakerStation
      @GameMakerStation  5 лет назад +2

      Can't guarantee when you'll get it, but I'm pretty sure you will, somewhere down the line. ;) Would you want part 4 to be about shooting projectiles, or about chat?

  • @OwnedByChristian
    @OwnedByChristian 3 года назад

    Your accent is Nice to listen to lol

  • @fireball3588
    @fireball3588 3 года назад

    da button

  • @Kurokage130
    @Kurokage130 4 года назад

    Thanks!

  • @unoduotilutiluduo6409
    @unoduotilutiluduo6409 4 года назад

    I cant understand about script haha

    • @GameMakerStation
      @GameMakerStation  4 года назад +1

      They're functions now, in 2.3. ruclips.net/video/KUgZEPqlNtE/видео.html

  • @Edel99
    @Edel99 3 года назад

    You can do this in Godot in 10 seconds!

    • @sectorrrrr
      @sectorrrrr 3 года назад +1

      Nobody asked!

    • @Edel99
      @Edel99 3 года назад

      @@sectorrrrr hey! Did you hear!? GameMaker is now subscription only! How exciting! 😀

    • @sectorrrrr
      @sectorrrrr 3 года назад

      @@Edel99 GMS paid bad, Godot free good bla bla bla, please shut the fuck up and let people have their preferences.
      Plus that update has been out for months now, pretty sure anyone who's remotely interested in game dev knows it.

  • @Thulipa3
    @Thulipa3 Год назад

    dabudduun

  • @dashahamsterova1855
    @dashahamsterova1855 3 года назад

    It's not a tutorial, but a fast retalling of what you have done for something to work. It's not allow to understand why you designed it like this nor it allow to catch the idea of what data passed where. Tutorials should not be like this and not everyone is suited for "teaching".

  • @ty88
    @ty88 6 месяцев назад

    can you please speak normally?

  • @der_leel
    @der_leel 2 года назад

    Always copy & paste..... :( I don't reccomend this video...

  • @nikhilbaidya0346
    @nikhilbaidya0346 4 года назад

    ...speak normal!!...

  • @luigisopa
    @luigisopa 2 года назад

    very nice and concise tutorial! @Andrzej Vlasov and @jam8much helped in the comments for the new script.