Mike Posted April 15, 2013 Share Posted April 15, 2013 I was a bit surprised, that the framework catch, them as I often press F5, or F12 So my request is if can be added some kind of global setting, to preserver the "F" keys default behavior andwe can choose if we want it or not Maybe there is some deeper thoughts, so I'll be glad to hear Rich opinion Link to comment Share on other sites More sharing options...
rich Posted April 15, 2013 Share Posted April 15, 2013 I disabled that in the version I pushed up a couple of hours ago, as it was bugging me The problem is if you don't capture arrow keys, the page will scroll. So what I need to do is capture JUST select keys, or put it under devs control which are caught or not. But anyway it's fixed in the version now on git. Chris 1 Link to comment Share on other sites More sharing options...
Mike Posted April 23, 2013 Author Share Posted April 23, 2013 So using the laters 9.0.2 and this time anoyed by the up, down, and space default behavior i used: var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update); function init() { myGame.world.setSize(2240, 2240); myGame.loader.addImageFile('grid', 'src/Tests/assets/tests/debug-grid-1920x1920.png'); myGame.loader.addImageFile('car', 'src/Tests/assets/sprites/car90.png'); myGame.input.keyboard.addKeyCapture(32); myGame.input.keyboard.addKeyCapture(38); myGame.input.keyboard.addKeyCapture(40); myGame.loader.load(); } This doesn't look quite nice and i propose something like: myGame.input.keyboard.addKeysCapture({32,38,40}); or { 32: true, 38: true, 40: true } or just as array... Anyway i've made a custo build of phaser... again for testing only with: module Phaser { export class Keyboard { constructor(game: Game) { this._game = game; this.start(); this._capture = { 32: true, 38: true, 40: true }; } Link to comment Share on other sites More sharing options...
rich Posted April 23, 2013 Share Posted April 23, 2013 Done. You can now pass either an array or a single value to addKeyCapture in 0.9.3. Link to comment Share on other sites More sharing options...
Mike Posted April 24, 2013 Author Share Posted April 24, 2013 Hi, again and 10x for adding it, but i test it and saw this problem: if (typeof keycode == 'array') and this doesn't work: myGame.input.keyboard.addKeyCapture([32, 38, 40]); so the case should be: if (typeof keycode == 'object') //i think this is the better check...orif(keycode instanceof Array) and this way it will work as intended. Link to comment Share on other sites More sharing options...
rich Posted April 24, 2013 Share Posted April 24, 2013 Well spotted. Fixed. Link to comment Share on other sites More sharing options...
Mike Posted September 14, 2013 Author Share Posted September 14, 2013 Using the old thread cause it's related but at the moment v1.0:var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });var arCapturedKeys = [ Phaser.Keyboard.SPACEBAR, ,Phaser.Keyboard.UP ,Phaser.Keyboard.DOWN ,Phaser.Keyboard.LEFT ,Phaser.Keyboard.RIGHT ];game.input.keyboard.addKeyCapture(arCapturedKeys);At this moment game.input is null and result in Uncaught TypeError: Cannot read property 'keyboard' of null I couldn't find info why is this so ... any tips where to look for fixing it ? Link to comment Share on other sites More sharing options...
Alvin Posted September 14, 2013 Share Posted September 14, 2013 Hi, If you copied all you code, then I think your problem comes from the "game.input.keyboard.addKeyCapture()" instruction, which should be put inside your "create" function. Link to comment Share on other sites More sharing options...
Mike Posted September 14, 2013 Author Share Posted September 14, 2013 Yep, shame on me. The right spot for such things is the "create" function as you said. Link to comment Share on other sites More sharing options...
rich Posted September 14, 2013 Share Posted September 14, 2013 Sorry yes I'll do a post in the forum now explaining about the functions, what order they are executed in and what they should contain. Link to comment Share on other sites More sharing options...
Recommended Posts