Search the Community
Showing results for tags 'Phaser.Button'.
-
I'm trying to build a button for mobile devices with the following characteristics: The button goes down when there is a pointer in a down state over itThe button goes up when there are no pointers in a down state over itvar myButton = game.add.button(x,y,'myButton');myButton.inputEnabled = true;myButton.onInputDown.add(goDown,myButton);myButton.onInputOver.add(goDown,myButton);myButton.onInputUp.add(goUp,myButton);myButton.onInputOut.add(goUp,myButton);function goUp(){ this.isDown = false;}function goDown(){ this.isDown = true;}Everything works fine except for when the button goes down because of `onInputOver` but doesn't go up when the pointer goes up (in a mobile device, when a pointer goes over, it is necessarily in a down state). Apparently Phaser looks for `onUp` events only from pointers who were pressed directly on the button. How can I get the result I'm looking for?
- 1 reply
-
- Phaser.Button
- Input
-
(and 2 more)
Tagged with:
-
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