A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [F8] Doublt Tap System?

  1. #1

    [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.

  2. #2
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    Quote 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.

  3. #3
    Thanks that would help alot. Even though it has enough keys I want to use it for dashing.

  4. #4
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    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:
    1 2 3
    4 5 6
    7 8 9
    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.

  5. #5
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    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.

  6. #6
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    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.

  7. #7
    An array, ofr most of my combos I was using a string. Thanks.

  8. #8
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Quote 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.

  9. #9
    Patron Saint of Beatings WilloughbyJackson's Avatar
    Join Date
    Nov 2000
    Location
    Ro-cha-cha-cha, New York
    Posts
    1,988
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center