Hsaka Posted December 13, 2013 Share Posted December 13, 2013 Hello, I'm seeing an issue on android stock browser with my game where if I tap once on a sprite or button, the callback function gets triggered twice. Here's my code:var it = this.game.add.sprite(0, 0, 'backing');it.alpha = 0;it.inputEnabled = true;it.input.useHandCursor = true;it.events.onInputDown.add(this.hitzoneClick.bind(this, 0));The same thing happens with phaser buttons. Has anyone else experienced this?Phaser v1.1.3 Link to comment Share on other sites More sharing options...
rich Posted December 13, 2013 Share Posted December 13, 2013 It might be once from the mouse event and once from the touch event? (although that shouldn't happen as I ignore mouse events on Android, but you never know). What pointer is set to the Signal? (console.log it out and you'll see) as if it's 1 from mouse and 1 from touch you should see two different pointer IDs come in. Link to comment Share on other sites More sharing options...
Hsaka Posted December 13, 2013 Author Share Posted December 13, 2013 Hey rich, I tried your suggestion. Only 1 pointer id is printed. I also tried disabling the mouse entirely but I get the same results. I tried the "Click on an image" example in the stock browser to make sure that I wasn't doing something weird in my code and I confirmed that the alert also fired twice. Strangely enough, if I scroll a little bit downwards so that the image is halfway out of the screen and I tap on it, the alert is only fired once. Link to comment Share on other sites More sharing options...
rich Posted December 14, 2013 Share Posted December 14, 2013 My guess then is that it actually did send 2 touch events. Maybe have a look at the timestamp on the native event and compare? Link to comment Share on other sites More sharing options...
Hsaka Posted December 14, 2013 Author Share Posted December 14, 2013 You may be right. The timestamps reveal that the events occur within milliseconds of each other. Some further testing also showed that if I scroll to the bottom of the page and play, only one touch event is triggered. Anywhere else and 2 events are triggered. Is there a scaling mode that ensures that no scroll bar will be required on the page? Link to comment Share on other sites More sharing options...
rich Posted December 14, 2013 Share Posted December 14, 2013 You could use addOnce instead of add, that will ensure the function is only called once, but literally only once until you rebuild it. Link to comment Share on other sites More sharing options...
Hsaka Posted December 14, 2013 Author Share Posted December 14, 2013 Thanks rich, I did just that and it works pretty good now Link to comment Share on other sites More sharing options...
AshleyScirra Posted December 18, 2013 Share Posted December 18, 2013 It's a bug in the browser. Frameworks can work around it by suppressing touchstart events until the corresponding touchend event fires. (Then some browsers fire touchend twice too, so that needs suppressing as well.) Link to comment Share on other sites More sharing options...
rich Posted December 18, 2013 Share Posted December 18, 2013 Yay for another stock browser bug! (and an inconsistent one at that). Link to comment Share on other sites More sharing options...
ozdy Posted April 30, 2014 Share Posted April 30, 2014 I just bought my Samsung Galaxy Tab 3 8-inch and the stock browsers has that: * Firing 2 mouse down events on tap, however the second can have arbitrary delay (0.1-2 seconds) and x and y don't always match exactly (close but not exact)!* Holding down then releasing fires only 1 event, but during the holding the game freezes LOL Link to comment Share on other sites More sharing options...
MishaShapo Posted October 17, 2015 Share Posted October 17, 2015 Has this bug been addressed in a recent version of Phaser? Link to comment Share on other sites More sharing options...
mstx Posted April 28, 2016 Share Posted April 28, 2016 Quote Hi, it's still an issue on Android Chrome and default browser. To prevent this I had to disable inputEnabled property of the sprite after input but it's a very big issue. Isn't it a bug for Phaser? Link to comment Share on other sites More sharing options...
Recommended Posts