Mike Posted May 6, 2013 Share Posted May 6, 2013 Well, I tried but it didn't worked so i tried again with making some core changes to Phaser. First:In Mouse class in onMouseDown there is: this._game.input.onDown.dispatch(this._game.input.x, this._game.input.y, this.timeDown); As this is the line that this line to work: myGame.input.onDown.add(click, this); One thing I tried was: myGame.input.onDown.add(press, this); function press(paramsArr: any[]) { var __this: Phaser.Keyboard = this; __this.justPressed(Phaser.Keyboard.Q); console.log(__this); if (this.isDown(Phaser.Keyboard.R)) { console.log(paramsArr); if (currentLevel < 3) { currentLevel += 1; } else { currentLevel = 0; } populateLevel(currentLevel); } } But still even with that, if you hold the "R" key it will keep calling the press function multiple times... So, i checked the Keyboard onKeyDown() method and I added this line: this._game.input.onDown.dispatch(event.keyCode, this._keys[event.keyCode]); and then changed the press function like this: function press(pressedKeyCode) { if (pressedKeyCode == Phaser.Keyboard.R) { console.log(pressedKeyCode); if (currentLevel < 3) { currentLevel += 1; } else { currentLevel = 0; } populateLevel(currentLevel); } } and it works but... still holding the key down fire press multiple times... So any ideas how to make this work as expected will be nice... Also in the other Breakout Topic, I asked about justPressed - cause i don;t think it works properly... Also there is big chance of me don't getting how things works, but still this topic needs discussion Link to comment Share on other sites More sharing options...
ilMareGames Posted May 9, 2013 Share Posted May 9, 2013 I just started testing Phaser today, I found you can use: _game.input.mouse.onMouseDown = function (evt: MouseEvent) { // mouse down }this should work also with an external function, but I haven't tested it yet Link to comment Share on other sites More sharing options...
Recommended Posts