mousehit()
Blitz3D Forums/Blitz3D Beginners Area/mousehit()
| ||
I am making a small game that requires you click certain options, I want to make it so I can click cetain lines of text and do something. I guess what I am really asking is how do you use X and Y coordinates with the mousehit() command? I have tried: If MouseHit(1), 400,365 Then But that doen't work :( |
| ||
try mousex() and mouseY() these return the current position of the mouse. |
| ||
So I would put something like: If MouseX(400), MouseY(300) Then But I don't think that's right. |
| ||
No, they return the mouse position to you. So something like ...if MouseX() = 400 And MouseY() = 300 ... would work. |
| ||
Here's a quick code example showing how you could put it together (just a guideline).point = CreateImage(1,1) ... If MouseHit(1) If ImagesOverlap(point, MouseX(), MouseY(), menu_item, 400, 300) Do_menu_item() Endif EndIf |
| ||
Or even simpler:if mousehit(1)=1 and mousex()=400 and mousey()=300 then print "whatever" endif |
| ||
JFK: The reason I gave that example is because is EXCEEDINGLY hard to get pixel perfect accuracy using MouseX and MouseY. That would require the user to very carefully move the mouse and click. |
| ||
Although he asked for this - I agree. To help the User he might add the following: movemouse 400,300 Print "Now click, hurry!" ;) |
| ||
Try this. |
| ||
I got the mouse button thing sorted out now, thenks you guys. |