Jump to content

Input .onDown and mouse, keyboard, touch


Mike
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

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