MouseHit and ImageRectOverlap not working properly

Blitz3D Forums/Blitz3D Beginners Area/MouseHit and ImageRectOverlap not working properly

OwlEpicurus(Posted 2009) [#1]
In this function



The lines

If ImageRectOverlap(storebox,50+menuX,ImageHeight(menu)/3+menuY,MouseX(),MouseY(),10,10) And MouseHit(LMOUSEKEY)
		DebugLog "Check"
	EndIf


work, but

If ImageRectOverlap(optionsbox,150+menuX,ImageHeight(menu)/3+menuY,MouseX(),MouseY(),10,10) And MouseHit(LMOUSEKEY)
		DebugLog "Check"
	EndIf
	
	If ImageRectOverlap(exitbox,250+menuX,ImageHeight(menu)/3+menuY,MouseX(),MouseY(),10,10) And MouseHit(LMOUSEKEY)
		DebugLog "Check"
	EndIf


does not. I cannot tell what the difference is between the two parts, but there obviously must be something wrong. What is it?

*SCREENWIDTH is set equal to 800, and LMOUSEKEY equals 1. I can also post the CreateBox() function if it helps, though I do not think the problem is there.


big10p(Posted 2009) [#2]
It's probably because of the second MouseHit call. From the manual:
This command returns the number of times a specified mouse button has been hit since the last time you called the MouseHit() command.


If you need to check MouseHit more than once, store it in a variable and check that instead.


OwlEpicurus(Posted 2009) [#3]
Thanks!