utkiupe Posted February 1, 2016 Share Posted February 1, 2016 Hi guys, I am having some troubles with clics on touch devices. Firstly, and that is important, we need the user to be able to scroll on the page even when touching the canvas. As this is not the default behavior of Phaser, we have created 2 functions to enable and disable this behavior. These 2 function simply change the game.input.touch.preventDefault property (so false is to enable the scrolling when touching the canvas, and true to disable it). The problem is, and I have noticed it recently, that when you set game.input.touch.preventDefault to false, now the function executed on the clic for the buttons are called twice, one for the touch event, and one for the clic. You can easily reproduce it. Take this simple example http://phaser.io/examples/v2/basics/02-click-on-an-image and on line 33 for example you add game.input.touch.preventDefault = false; When you test on a mobile or tablet, the textfield shows that you have 2 clics for each clic... So, my only problem is that it does not occur all the time on my games. And I don't really know why actually. That's why I am asking if someone knows how to solve this with some fancy parameter I am maybe missing somewhere. I have a little workaround though, why is simply setting game.input.touch.preventDefault to true on the "onInputDown" event, and add another function for "onInputUp" where I set back game.input.touch.preventDefault to false.So maybe that's the only thing to do, but maybe not. Any ideas ? Link to comment Share on other sites More sharing options...
Recommended Posts