Double Tap
BlitzMax Forums/BlitzMax Programming/Double Tap
| ||
Anyone got a working double tap function? Seem to be getting stuck with the keydown() and keyhit() combination. Any help appreciated. |
| ||
Graphics 640,480,0,0 Global msg:String = "No double click" Global pause:Int While Not KeyDown(KEY_ESCAPE) Cls If Doubletap(KEY_MOUSELEFT) Then msg = "Double click" pause = MilliSecs() Else If MilliSecs() - pause > 1000 Then msg = "No Double Click" EndIf DrawText(msg,0,0) Flip Wend End Function DoubleTap:Int(key:Int, rate:Int = 1000) Global keys:Int[192] If KeyHit(key) Then If MilliSecs() - keys[key] <= rate Then keys[key] = MilliSecs() Return True Else keys[key] = MilliSecs() EndIf EndIf Return False End Function |
| ||
Wow! Thanks a lot perty. What a great community. I was getting stuck with a combo of KeyDown but your code sample helped clear it up. Thanks a lot. You'll get credit in my game, Perty. |
| ||
np :) |
| ||
@ Perturbatio Could you explain the keys[] array that you declare as Global within the function. In C++ you can declare variables as 'static' within a function so that they'll preserve their values between function calls. Is that what this is? |
| ||
yes. |
| ||
Thanks. |