Keypressed problem
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Keypressed problem

  1. #1
    Junior Member
    Join Date
    May 2000
    Posts
    7

    Post

    Hello,

    I'm developing a game controlled by keyboard and I have the following problem: if 2 keys are pressed simultaneously and then one of them released, I cannot detect which one is still pressed and which one is released.

    I mention that the algorithm already existent on this site regarding the detection of the released key doesn't work fine in such situations.

    Thanks in advance,
    Mihai

  2. #2
    Junior Member
    Join Date
    Apr 2000
    Posts
    21

    Post


    not sure if you're going to get around that one, maybe trim down the number of keys that would be pressed at the same time? one way to do this is toggle weapons, for example have two or more weapons you could switch, instead of having them all available, which would slim the chances of them pressing more than one key at a time.

    another work around is use the mouse click as well as key presses.

    ------------------
    kennethAustin
    kenneth.austin@knowledgenet.com

  3. #3
    Junior Member
    Join Date
    May 2000
    Posts
    7

    Post

    Thank you for your quick answer. My problem still exists, unfortunately, because I have to move an object only by using the arrow keys in 8 different directions (top, top-left, left, bottom-left, etc...)....
    Any suggestion is welcome.


    Mihai

  4. #4
    Junior Member
    Join Date
    Mar 2000
    Posts
    18

    Post

    I dont think you can get around this. If you have one key pressed and then press another one. It stops the previous check

    Maybe in the next Flash version, MM will add this.

    In platform games etc, just means you cant press LEFT/RIGHT and JUMP at the same time..gaaa!


    DD

  5. #5
    Junior Member
    Join Date
    Apr 2000
    Posts
    21

    Post


    mihai -

    i would use keyboard keys instead of arrow keys, as is done in many games. this way you could map 8 adjacent keys that would be pressed independent of each other.
    another option would be to use the left and right arrows to rotate your character and up and down to move up and back.

    ------------------
    kennethAustin
    kenneth.austin@knowledgenet.com

  6. #6
    Junior Member
    Join Date
    May 2000
    Posts
    7

    Smile

    Thanks for your advice! I'll keep in mind.

    Mihai

  7. #7

    Lightbulb

    Well, you could always create a list of boolean variables like

    key_left
    key_right
    key_space

    etc... and if the key is pressed, set the value to TRUE. Then, multiple keys can have the TRUE state.. and you can loop through and respond to the states of the keys..

    The trick is to get around the key_up :-)

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