-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onKeyDown stop working for a key when another one is pressed #710
Comments
No comment on this? Nobody uses keyboard in video games nowadays? |
This event fires when a key is being pressed down, and the corresponding keycode is parsed in as a parameter. for example, WASD moves a character in 4 directions, When W is keydown, you can record that state in your game logic. then in your character update, check if W is being held down, if so, move up. if W and D is being held down, move up right |
That is what I do, and it works (as I explained in the last sentence of the first message), but it is a by-pass. It should work properly in Cocos2D-html5.
The difference between Cocos2D-html5 and the other branches: keyboard matters now. |
PS: I will to provide you with a fix if I have time to work on it |
This problem can be easily reproduced on the Hello World sample.
Add "this.setKeyboardEnabled(true);" in the init method of a layer.
Add the following method to that layer:
onKeyDown:function(e){
console.log(e);
}
When a key is pressed, the console will show that key in the console at each update (it works for a combination of keys as well). If you keep pressing a key then press another one, only the last one will be shown in the console.
In most of platform games we need to be able to move and press a jump/shoot button at the same time. It can be easily by-passed (keep in memory that a button is pressed and release it on onKeyUp), but it is painful and doesn't seem to be a natural behavior.
The text was updated successfully, but these errors were encountered: