Jump to content

touch on a sprite generates a clic and a touch event


utkiupe
 Share

Recommended Posts

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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