• 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!

About GUI

Fabseven

Member
Hello there,

As a windev programmer i wanted to make simple button objet.
So i created a obj_button with a spr_button (something rectangular with a text inside)
I used mouse_over , mouse_pressed and others event to make it a real button but it only work on the draw level not on the gui level.

I mean : if i use the draw gui event then i have to draw the objet myself with draw_sprite and others and the mouse_over and mouse_pressed wont work because the position of the gui <> position of the object.

Is there no ways to make a simple button in the gui event?
 

Yambam

Member
You can do something like this if you have chosen a sprite (in the left pressed event):
Code:
if position_meeting(device_mouse_x_to_gui(),device_mouse_y_to_gui(),self) /* Do something */
Or if you don't have a sprite, don't worry! There's a function which checks if a point is "inside" a rectangle more easily than using a bunch of (>=, &&, and <) operators.
Code:
var mx = device_mouse_x_to_gui();
var my = device_mouse_y_to_gui();
if point_in_rectangle(mx,my,x1,y1,x2,y2) /* Do something */
 
Top