|
-
[F8] Double Tap System?
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.
Last edited by Chaos_Blader; 06-26-2006 at 08:40 AM.
-
Feeling adventurous?
 Originally Posted by Chaos_Blader
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!
But if you really need/want it i can give it a go if nobody else does before you reply
I don't have a photograph, but you can have my footprints. They're upstairs in my socks.
-
Thanks that would help alot. Even though it has enough keys I want to use it for dashing.
-
Patron Saint of Beatings
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.
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.
-
Feeling adventurous?
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).
I don't have a photograph, but you can have my footprints. They're upstairs in my socks.
-
Senior Member
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.
-
Senior Member
 Originally Posted by WilloughbyJackson
I also have a timer which adds an "X" in every 500 millisecond or something like that...
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.
-
Patron Saint of Beatings
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|