Sign in to follow this  
nExt

What is function check any key press in Phaser

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..

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.