ttk Posted August 9, 2015 Share Posted August 9, 2015 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? Link to comment Share on other sites More sharing options...
ttk Posted August 9, 2015 Author Share Posted August 9, 2015 Solved using:myButton.onInputOver.add(function(button,pointer){ button.input._pointerData[pointer.id].isDown = true; button.isDown = true;},this); Link to comment Share on other sites More sharing options...
Recommended Posts