Mouse Click Query
#1
Posted 25 March 2012 - 01:18 AM
Thanks in advanced.
#2
Posted 25 March 2012 - 04:56 AM
Yea it's completely possible! As I always say, "You are only limited by your own imagination!"
// point_in_rectangle(x1,y1,x2,y2,x3,y3) // This script will check if point [x3,y3] is in the rectangle [x1,y1,x2,y2] // Returns: 'True' if point is in rectangle else 'False' return ((median(argument0,argument2,argument4)==argument4)*(median(argument1,argument3,argument5)==argument5))
You can use it like this:
if mouse_check_button_pressed(mb_left) and point_in_rectangle(x1,y1,x2,y2,mouse_x,mouse_y){
//DO THIS
}
Just ask if you need an explanation or if this wasn't what you were looking for.
Edited by blopit, 25 March 2012 - 04:57 AM.
#3
Posted 25 March 2012 - 09:46 AM
I tried using it but it aint working
I wanted to check if a mouse click is between a rectangle points and if so then snap to centre point of rectangle
#4
Posted 25 March 2012 - 11:55 AM
@witcher
You have to put the first code into a script and call it point_in_rectangle, then put the point_in_rectangle(x1,y1,x2,y2,mouse_x,mouse_y) in the step event, the x1,y1,x2,y2 are the co-ord of the rectangle, x3,y3 the mouse coord, simple.
#5
Posted 25 March 2012 - 12:24 PM
Works fine thanks dudeThat's pretty cool
I don't really program my own functions :L I guess I forget that it's possible, though looking at yours, the simplicity behind it is pretty awesome
Thank you very much :D
@witcher
You have to put the first code into a script and call it point_in_rectangle, then put the point_in_rectangle(x1,y1,x2,y2,mouse_x,mouse_y) in the step event, the x1,y1,x2,y2 are the co-ord of the rectangle, x3,y3 the mouse coord, simple.
Previously i had put the code in mouse left event
#6
Posted 25 March 2012 - 12:57 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











