Could someone please tell me the best way to determine whether a user has clicked the mouse when the pointer is on a certain image? In this case the image is a circle.
Thanks in advance
Thanks in advance
' Mouse over image Graphics 640,480,0,SOFTSYNC ' create a circle test image Local image=CreateImage(64,64,1,DYNAMICIMAGE|MASKEDIMAGE) Cls ; DrawOval 0,0,64,64 ; GrabImage image,0,0 ' create a single pixel dummy image dummyCursorImage=CreateImage(1,1,1,DYNAMICIMAGE|MASKEDIMAGE) Plot 0,0 ; GrabImage dummyCursorImage,0,0 Repeat Cls mx=MouseX() ; my=MouseY() ' draw the circle image DrawImage image,200,100 ' test for collision against dummy image result=ImagesCollide(image,200,100,0 , dummyCursorImage,mx,my,0) DrawText "Collision = "+Mid$("NO YES",result*4,3) , 10,10 Flip FlushMem Until KeyHit(KEY_ESCAPE) End
CollideImage arrBalls[0].imgBall,500,600,0,0,1 If MouseDown(1) And CollideImage(arrBalls[0].imgBall,MouseX(),MouseY(),0,1,0)
Function MouseCollision( X, Y, Width, Height, Value:Int ) Select Value Case 1 'Mouse Down If MouseX()>=x And MouseY()>=y And MouseX()<=x+width And MouseY()<=y+height And MouseDown(1) Return True End If Case 2 'Mouse Over If MouseX()>=X And MouseY()>=Y And MouseX()<=X+Width And MouseY()<=Y+Height Return True End If End Select End Function