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

GML Draw_rectangle coordinates not same as point in rectangle

R

RustyWaffles

Guest
Code:
if point_in_rectangle(mouse_x, mouse_y,105, 150, 295, 190){hover_ = true}else{hover_ = false}
draw_set_color(c_blue);
draw_roundrect(105, 150, 295, 190, hover_);
//draw_button(105, 150, 295, 190, true);
draw_set_color(c_white);
draw_set_halign(fa_center)
draw_set_valign(fa_center)
draw_text(200,170, "Skills")
I'm unsure why but the point_in_rectangle position and the draw_roundrect position are completely different,
I've played around with trying to fix it like setting them both to work with view_xview[0] and view_yview[0] as kind of a base line but that hasn't worked either.

Not touching
https://i.imgur.com/31htofJ.png

Touching
https://i.imgur.com/tQLkESb.png

All of this is being done in the draw_gui event as well. (wouldn't let me edit post to add this in)
 
Last edited by a moderator:

Simon Gust

Member
mouse_x and mouse_y are absolute values. So if your view is not at x=0 and y=0, the positions are going to be offset.
You can use display_mouse_get_x() and display_mouse_get_y().
 
Top