Jump to content

2 possibe bugs with Phaser.Button


Recommended Posts

the first one is easy to describe:


this is how i create the button:

buttondown = game.add.button(88, 360, 'buttonvertical', null, this, 0, 1, 0, 1);

if i would do it this way: (let's say the frames in my spritesheet are ordered differently)

buttondown = game.add.button(88, 360, 'buttonvertical', null, this, 1, 0, 1, 0);

then the upFrame will not work!  if i chose any other framenumber as upFrame it works (for example in another spritesheet with 8 frames i can use all frames from 1 to 8 as upFrame but not 0 - it will not make the switch and stay in the downFrame state.




and now the second one:


again.. this is how i create my buttons:

buttondown = game.add.button(88, 360, 'buttonvertical', null, this, 0, 1, 0, 1);buttondown.anchor.setTo(0.5, 0.5);buttondown.fixedToCamera = true;buttondown.events.onInputOver.add(function(){duck=true;});buttondown.events.onInputOut.add(function(){duck=false;});buttondown.events.onInputDown.add(function(){duck=true;});buttondown.events.onInputUp.add(function(){duck=false;});

on a pc with the mouse there is no problem at all but on my tablet you can easily get every button to freeze in the onInputOver state.  just tap on one button and then swipe to another button and raise your finger there...  the button you just swiped to and raised your finger above it is left in an "over" state (visually not a big problem but logically - you keep running for example or can't stop jumping)..  

IF this is intended (because you swiped over but never swiped out so it's your fault) it is a very unfortunate behavior for a virtual gamepad because you do this all the time..

(btw. this "bug" was found by my 4 year old betatester and son :) )


so what i do now is catch this and work around:

if (game.input.currentPointers == 0 && !game.input.activePointer.isMouse){ fire=false; right=false; left=false; duck=false; jump=false;}

you can test both here: (with the line above and the working frame numbers)



and here: (without the line above and the button B is configured the other way 'round - so it's default state is darker - if you move your finger out it works and goes back to the darker state, if you just tap and issue an UP event.. it suddenly doesn't work and it is transparent even if not touched)



cheers valueerror






Link to comment
Share on other sites

maybe this can help..  i don't know yet but it looks like it was made to address these problems ..  what do you say rich ? 




When the Button is touched / clicked and then released you can force it to enter a state of "out" instead of "up".


EDIT : nope..  just tried it..  buttons still get stuck.

Link to comment
Share on other sites

  • 2 weeks later...

Ok the 2nd one doesn't happen any more for me under 2.0, but the first one was still a problem for sure. I've tightened up how the upFrame is checked for, and that should resolve it. Please use dev branch build to see (literally just pushed new one up).

Link to comment
Share on other sites

  • 1 month later...

in 2.0.3 bug nr #2 is still there.. if i remove my "workaround" line the buttons get stuck and my player keeps walking (or jumping or whatever button is stuck)  

if (game.input.currentPointers == 0 && !game.input.activePointer.isMouse){ fire=false; left=false; right=false;  duck=false; jump=false; climb =false;}



with the workaround the button still gets stuck of course.. it just sets my variables to false so no action will be triggered..

unfortunately this isn't really a good workaround because when a button gets stuck it is blocked for onInputOver only onInputDown can revive it  :unsure:   so this makes it no fun to use my virtual gamepad 

Link to comment
Share on other sites


  • Recently Browsing   0 members

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