A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Key configuration

  1. #1
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128

    Key configuration

    Hi.

    I am currently working on a project to make a stickman fight game (much like http://www.stickpage.com/xiao9play.shtml), however, I've came across a slight problem. I am hoping to make the user be able to:

    • walk left/right (LEFT/RIGHT
    • run left/right (SPACE + LEFT/RIGHT)
    • jump left/right/standing (UP + LEFT/RIGHT)
    • do multiple attacks on different key presses, incl. with combination of jump key (A/S/D/F) and (SPACE + A/S/D/F)

    However, when doing attacks, I would like some sort of script that can detect combinations within a certain time interval. Eg. say the attack combination was A then S, is there a way in which I can make it detect whether S was pressed within a certain time interval after A, if so, it will then do something else.

    Pseudo code:
    Code:
    If A is pressed Then
         Do Attack1
    End If
    
    If A then S pressed < 0.5 secs Then
         Do Attack2
    End If
    
    If A then S pressed > 0.5 secs Then
         Do Attack1
    End If
    Hopefully you can understand what my problem is and that you can be of some assistance.

    Regards,
    Tom

  2. #2
    See-n-reMember azwaldo's Avatar
    Join Date
    Mar 2003
    Location
    Sonoran Desert
    Posts
    745

    setInterval

    Quote Originally Posted by tomstaveley
    "...detect whether S was pressed within a certain time interval after A, if so, it will then do something else."
    setInterval is tailor made for this sort of thing...
    place actions in fxns that are called up to the 0.5 second deadline

    MM dictionary entry


    hth
    __azwaldo__

  3. #3
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    Thanks for the reply azwaldo, however, i can't seem to get it to work!
    Could you perhaps try applying it to my problem and then post the script to see where i am going wrong.

    Cheers, Tom

  4. #4
    See-n-reMember azwaldo's Avatar
    Join Date
    Mar 2003
    Location
    Sonoran Desert
    Posts
    745

    from scratch?

    what have you come up with so far ?
    zip up the .fla and attach it to next post, or attach a .txt file of your AS ?
    __azwaldo__

  5. #5
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    Sorry, I didn't make myself very clear...like just make it start on frame 1 (perhaps put 'no action' here), then if it wasn't pressed in time then goto frame 2 (here put 'wasn't pressed in time') then if it was pressed in time, goto frame 3 (here put 'was pressed in time').

    Again thanks for your support

  6. #6
    See-n-reMember azwaldo's Avatar
    Join Date
    Mar 2003
    Location
    Sonoran Desert
    Posts
    745
    still wondering, though:

    would you like an animation worked up from scratch? (probably not*)
    what have you come up with so far ?
    can you zip up an .fla or attach a .txt file with something?

    there would be many ways to approach the effect you are describing. but, the devil is often in the details


    * ever read the forum guidelines ?? particularly the third one

    .
    __azwaldo__

  7. #7
    Registered Deviant
    Join Date
    Sep 2004
    Location
    Cornelius, OR, USA
    Posts
    280
    Try this on for size
    Attached Files Attached Files
    If you can read this, you're in the right place.

  8. #8
    Snowboarder tomstaveley's Avatar
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    128
    Exactly what I needed wombat! thanks

    thanks also azwaldo for your interest!

    Regards, Tom

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