Jump to content

Phaser buttons working the wrong way


defic
 Share

Recommended Posts

When phaser button is pressed and the input is released outside of the button, the button is still considered as pressed in phaser. The traditional way to handle this would be that the button is only consiredered as pressed if the touch begins and ends in the area of button.

 

This is the way user can cancel pressing the button if he/she so desires by moving the finger/mouse somewhere outside of the button area, but at the moment this is not possible. 

 

This is the way I am currently using buttons. Is there another way to do this, so it would work like i would want it to?

this.button = this.game.add.button(0,0, 'level_button', function(){            console.log("button is pressed");},this);

I am using 2.20 RC2 at the moment, but it has worked like this since I started with phaser (2.0.7). You can see the same behaviour in phaser examples, f.e. in this: http://examples.phaser.io/_site/view_full.html?d=buttons&f=action+on+click.js&t=action%20on%20click

 

Link to comment
Share on other sites

Your onInputUp callback receives 3 parameters: the Button, the Pointer that activated it and a boolean which is `true` if the Pointer is still over the Button or `false` if not. From these things you can determine exactly what to do.. i.e. perform the button action or just cancel.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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