a small Hit function for the community
Function hit(ax,bx,ay,by) 'function call with handover of the queried coordinates
Local flag:Int 'Internal flag to long pressed touch: local flag
Local x: Int 'internal variable value for TouchX
Local y :Int 'internal variable value for Touchy
Local z :Bool 'variable for return
If TouchDown(0) = True And flag=0 'touch and flag is not set
x=TouchX(0) 'x variable is set to the current value TouchX
y=TouchY(0) 'y variable is set to the current value Touchy
If x >ax And x<bx 'x coordinates are compared with output value over the touch area
If y >ay And y<by 'the same for Y coordinates
z=True 'set within the range hit True
flag=1 'control flag is set
End If
End If
Else z=False ' no Hit
End If
If TouchDown(0)= False And flag=1 Then flag =0 'The End of the touch. Flag is reset
Return z ' Return of earnings hit
End Function
a small example of the application
If hit(280,680,360,380)=1
GameModus=1
Level =1
timer1.Start
timer.Start
End If
|