This doesnt seem hard but everytime I do it it doesnt work. How can make a double tap system so that when somone double taps a key, it activates an effect.
Printable View
This doesnt seem hard but everytime I do it it doesnt work. How can make a double tap system so that when somone double taps a key, it activates an effect.
I wouldnt go there. The keyboard has enough keys!Quote:
Originally Posted by Chaos_Blader
But if you really need/want it i can give it a go if nobody else does before you reply:)
Thanks that would help alot. Even though it has enough keys I want to use it for dashing.
Double taps (how I do them).
Basically, I have an array which is constantly being fed the keys being pressed.
If the first and last buttons are the same, and the middle is no button pressed (or the value 5), the dash occurs.
I always do my directional keys like this:
so that direction value starts at 5 and is changed depending upon what keys are pressed.Quote:
1 2 3
4 5 6
7 8 9
If up and left are pressed. dir = 5 - 3 - 1) = 1.
So the check is like this:
code:
keyArray.push(dir)
if (keyArray.length > 3){
keyArray.shift()
}
if (keyArray[2] == keyArray[0]){
if (keyArray[1] == 5){
//then run is activated
}
}
This is a VERY rough version of it since I don't have my dash code on me right now. I also have a timer which adds an "X" in every 500 millisecond or something like that, so the person can't just press Right Arrow, wait a bit and press Right arrow and expect to dash.
Thats a very clever solution! Smarter than what I would have tought of..
If you dont understand the code Chaos, try searching for Array in flash-help (f1).
A double tap would require that you use a timer to time how long between key presses of that same key and if it's in short enough a time, then do whatever the double tap is supposed to do. If the time was longer, then ignore it, and reset the timer for the next tap.
An array, ofr most of my combos I was using a string. Thanks.
It would have to be every 500 milliseconds after the last input, otherwise an 'X' could be thrown in immediately after a keypress, resulting in inconsistent double-tap detection.Quote:
Originally Posted by WilloughbyJackson
Yeah, it's true, the timer is reset everytime there is an input.
As I noted, I didn't have my code in front of me and was typing off the top of my head.