• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Why doesn't game maker let me click my GUI?

J

JOSEPHPERKS

Guest
This has been driving me insane. I set up a button, that when pressed played a sound, and created an instance of another object. I then changed the button from just an object placed on the first instances layer to a draw_gui so it moves around with the camera. I have tried for hours but whatever I do, the button wont register the mouse clicking on it. I have tried coding it, using the drag and drop system, everything, I don't get any errors, it just literally will not register, What am I doing wrong?
 
B

brokenjava

Guest
if you are drawing it in the draw_gui the x,y position will seem strange. what you need to do is keep track of the lets call them gui_x and gui_y and also make sure you use the correct functions device_mouse_x_to_gui and device_mouse_y_to_gui. then use point_in_rectangle to see if you are clicking in the "hit box" area. You need to calculate all this your self. This is long,painfull, and not supported at all in GM. FIRST thing todo is read some great tuts by pixelated pope and then start the LONG AND TEDIOUS journey of gui discovery.
and also http://www.pentadact.com/2015-01-27-help-me-with-a-trigonometry-problem-for-heat-signature/ this will help alot. Good luck bashing your face against the wall i know i sure did. oh one more thing if you want the view to zoom move... https://yal.cc/gamemaker-click-n-drag-to-pan-view/
 
I

icuurd12b42

Guest
set the button object to have a sprite as a button

on left button pressed
show_message("Tada")

on draw
x = xstart+view_xview;
y = ystart+view_yview;
draw_self();

Drop it in the room with the room editor where you want the item to appear (enable the show view to see the view dimension in the room editor)
upload_2017-7-4_20-17-51.png

that's it, that the most basic UI button. no GUI draw event needed, no special mouse handling needed...
 
Top