-
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
-
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
-
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
-
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
-
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
-
Thanks for your advice! I'll keep in mind.
Mihai
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|