Jump to content

Left mouse button always down?


Recommended Posts



I have a weird problem. Phaser does not seem to understand whether or not mouse left button is down.



So I've put this in the update function:





And when i check console, it shows that button 0 (left mouse button) is down regardless of whether it's actually down or not.



So a condition like this returns true regardless of whether left button is down or up. It only is false if some other button is down.


        if (this.game.input.activePointer.button === 0)
        console.log("button 0 down")


Basically that means that the left mouse button is unusable as a control, because its not triggered correctly.

Does anyone have any idea how to make mouse left button work normally (activated only if button is down)?

Is this a phaser fault or might something in my code cause this?


As far as i've understood, having no buttons down should return -1 (NO_BUTTON) in the console.log.


I'm using newest phaser version (2.2.1).

Link to comment
Share on other sites

Looks like i've found a solution to my problem.


I've added this.game.input.activePointer.isDown before the button check, so it checks (true/false) if any button is pressed currently before checking if the button id is 0.


if (this.game.input.activePointer.isDown && this.game.input.activePointer.button === 0)

{console.log("left mouse button is down")}

Link to comment
Share on other sites


  • Recently Browsing   0 members

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