Saturday 15 September 2012

actionscript 3 - How many pressed keys Flash can detect? using as3 -


I am developing a little game I use the following code to find out the keys pressed by the player: / P>

  Private Event on Kidadown (Event: Keyboard Event): Zero {// Marmon Keys (event.keyCode == 37} event .keycode == 65) {this.leftKeyPressed = true; } If (event.keyCode == 39} event.keyCode == 68) {this.rightKeyPressed = true; } If (event.keycode == 38} event.keyCode == 87) {this.upKeyPressed = true; } If (event.keyCode == 40} event.keyCode == 83) {this.downKeyPressed = true; } If (event.keyCode == this.shootKey) {this.shootKeyPressed = true; On}  

ONLINE event:

  Private tasks on-up (Event: keyboard events): zero {if (event.keyCode == 37} Event KeyCode == 65) {this.leftKeypress = false; } If (event.keyCode == 39} event.keyCode == 68) {this.rightKeyPressed = false; } If (event.keyCode == 38} event.keyCode == 87) {this.upKeyPressed = false; } If (event.keyCode == 40} event.keyCode == 83) {this.downKeyPressed = false; } If (event.keyCode == this.shootKey) {this.shootKeyPressed = false; } If (event.keyCode == changeColorKey) {trace ('color key release'); Trace (getTimer ()); This.changeColorKeyPressed = True; }}  

Actually the shootie player will hold down almost all the time. And the change ColourKey will be pressed frequently, but do not hold while doing the test, I noticed that onKeyUp events were not removed for the change, holding the shoot and the right arrow. Holding the up and down arrow keys instead of the right arrow is the same effect. If I capture the left arrow key then the events are removed. Why does this happen Is there anything wrong with my code?

The problem you are seeing is not related to your code, but the keyboard technology on your keyboard. The combination of numbers and combinations on the basis that you can press together may vary. I had given a lot of code for you a few years ago and I remember that the problem you mention is not the same with my current keyboard (It seems that it can support five simultaneously characters While the old one supports three).


No comments:

Post a Comment