defic Posted November 12, 2014 Share Posted November 12, 2014 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 More sharing options...
rich Posted November 12, 2014 Share Posted November 12, 2014 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 More sharing options...
defic Posted November 13, 2014 Author Share Posted November 13, 2014 Thanks a lot rich, that resolved it Link to comment Share on other sites More sharing options...
Recommended Posts