nExt Posted April 24, 2014 Share Posted April 24, 2014 Hello all, i see var space_key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);and set event for itspace_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 More sharing options...
marvster Posted April 24, 2014 Share Posted April 24, 2014 Have a look at onDownCall:http://docs.phaser.io/Phaser.Keyboard.html#onDownCallbackIt'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". Link to comment Share on other sites More sharing options...
nExt Posted April 24, 2014 Author Share Posted April 24, 2014 Have a look at onDownCall:http://docs.phaser.io/Phaser.Keyboard.html#onDownCallbackIt'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 More sharing options...
marvster Posted April 24, 2014 Share Posted April 24, 2014 [..],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. webcaetano and sifon 2 Link to comment Share on other sites More sharing options...
nExt Posted April 25, 2014 Author Share Posted April 25, 2014 [..],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 More sharing options...
Dread Knight Posted November 28, 2014 Share Posted November 28, 2014 Yeah, the docs sure feel like lacking some usage examples. sifon 1 Link to comment Share on other sites More sharing options...
Recommended Posts