[r103]Prevent touch events from trigger twice

  • Touch object with "Use mouse input" set to "yes" triggers twice on my Samsung. Bug or feature?;)

    Tested on a Samsung Tab 2 10.1 with Android 4.0.4. in the pre-installed browser.

    Here's the capx:

    touchFiresTwiceOnAndroid.capx

    And here's a direct link to a published version:

    index.html (the textfield should increase by 1 on every touch of the square)

    I would really appreciate it if you guys could test it on your Samsung/Android device and post a feedback:) Or know what's causing this. Or have a solution/workaround:)

  • It's probably registering multiple touches with each tick. Try adding a second condition - On Touch End - to your event.

    I always use a combo of On Touch End and Is Touching Object to capture a single tap.

  • Yeah what Stevo said.

    I had a hard time fixing my Capx, because double clicks would <img src="smileys/smiley35.gif" border="0"> it up completely.

    I would also not count on "trigger once" to much.

    Very simple fix here:

    Event:                  Action:

    OnTouched

    If numTouched < 1       Add 1 to numTouched

    Will only trigger once :)

  • Stevo: I tried it, but it didn't solve the problem. My guess is that it's registrating a mouse click in addition to the touch event.. (Whaat?!)

    I'll test a little more and get back to you.

    Schoening: Yes, I guess that's the only way to make it work.

    Thanks both for your tips!

    I've done a little more testing and it turns out it's browser specific. Both Chrome and Firefox works as expected on the same Samsung tablet, leaving the pre-installed browser to blame.

    Motorola Xoom with Android 4.0.3 also triggers events twice.

    These tablets only triggers once:

    Samsung Galaxy Tab - Android 2.3.3

    Google Nexus - Android 4.1 (Chrome browser pre-installed)

    Asus Transformers - Android 4.0.3 - AppleWebKit/534.30 Safari/534.30

  • Sorry for necroposting, but I'm also having this problem. How did you fix it, gerris?

    To me, it only happens when I export with XDK to android.

  • What Schoening said, you have to have a flag to check if touched for the first time (Madonna style ;D)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I had similar issue. Taps on phone/tablets were registering as 2 taps but on my windows PC the mouse click registered correctly as 1.

    I added a second condition to my event "Is on mobile" which fixed it on mobile but disabled my mouse on my PC.

    I tried to add another event that tests if "On HTML5 website" platform but that messed it up on mobile again. Currently, while still in development I just disable the mouse event before exporting it. The above suggestions did not work at all for me, however it could have been my implementation of the solution rather than a faulty solution. Would like to hear what worked for you alvarop.

  • For what it's worth I only use "is touching" and "trigger once while true" instead of the on-touched trigger because this always seems to become buggy for some reason. I find that way of triggering is ultimately more reliable across different platforms and, as has already been said, if that still isn't enough then add a has been triggered Boolean to stop it double firing.

  • Colludium: Thanks for that suggestion.....it worked perfectly for the problem I was having.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)