Method TouchDetect:Bool(x:Int, y:Int, w:Int, h:Int)
For Local i:Int = 0 To 5
If TouchHit(i)
If TouchX(i) >= x - pressdistance
If TouchX(i) <= x + w + pressdistance
If TouchY(i) >= y - pressdistance
If TouchY(i) <= y + h + pressdistance
Return True
EndIf
EndIf
EndIf
EndIf
EndIf
Next
Return False
End
EDIT: made it seperate if statements so as not to make it one line, it made the thread look bad :)
There is a method you can call to detect where a touch has occured, I have an int called pressdistance that is basically a buffer zone around the button that would also count as a hit. I tend to keep it at around 32
It's probably not the neatest way to do it but I find it works fine here is an example of it being called
Method FDLGameCheck:Int()
If TouchDetect(3 * 32, 9 * 32, 32, 48) Then turncommand = gmUp
If TouchDetect(2 * 32 + 16, 8 * 32 + 16, 64, 16) Then turncommand = gmUp
If TouchDetect(5 * 32 - 16, 11 * 32, 48, 32) Then turncommand = gmRight
If TouchDetect(6 * 32, 10 * 32 + 16, 16, 64) Then turncommand = gmRight
If TouchDetect(3 * 32, 13 * 32 - 16, 32, 48) Then turncommand = gmDown
If TouchDetect(2 * 32 + 16, 14 * 32, 64, 16) Then turncommand = gmDown
If TouchDetect(1 * 32, 11 * 32, 48, 32) Then turncommand = gmLeft
If TouchDetect(16, 10 * 32 + 16, 16, 64) Then turncommand = gmLeft
Return 0
End
hope that helps
|