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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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