Jump to content

What is function check any key press in Phaser


nExt
 Share

Recommended Posts

Hello all,

 

i see 

 

var space_key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);

and set event for it

space_key.onDown.add(this.jump, this); 

 

 is add key "Spacebar" is press..

so i want check any key press and set all for event jump.. 

 

what is method check any key press..

Link to comment
Share on other sites

Have a look at onDownCall:

http://docs.phaser.io/Phaser.Keyboard.html#onDownCallback

It's invoked everytime a key is pressed, event.keyCode would tell you which one it would be, but if you don't care you can just use it as "any key".

Can you show me example.. i'm newbie.. i read this link.. but i don't see example call function ?.

i try using google search but it not example too.. 

please give me a example .. thank you alot!

Link to comment
Share on other sites

[..],create: function() {   //this is your create function   //here you define what happens if any key is pressed, default is null   this.game.input.keyboard.onDownCallback = function(e) {   //for demonstration, next line prints the keyCode to console   console.log(e.keyCode);   //here comes your stuff, you might check for certain key, or just trigger a function   }},[..]

I hope it might help you.

Link to comment
Share on other sites

[..],create: function() {   //this is your create function   //here you define what happens if any key is pressed, default is null   this.game.input.keyboard.onDownCallback = function(e) {   //for demonstration, next line prints the keyCode to console   console.log(e.keyCode);   //here comes your stuff, you might check for certain key, or just trigger a function   }},[..]

I hope it might help you.

 

ok.. thank for shared.. :)  :)  :)  :)  :)

 

i read document.. i show all function, method but not guide use it..

Link to comment
Share on other sites

  • 7 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...