[r103]Prevent touch events from trigger twice

Get help using Construct 2

Post » Mon Sep 24, 2012 11:20 am

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:)
B
16
S
4
G
1
Posts: 23
Reputation: 2,523

Post » Mon Sep 24, 2012 6:01 pm

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.stevo3011032012-09-24 18:02:29
B
11
S
3
G
2
Posts: 23
Reputation: 1,453

Post » Mon Sep 24, 2012 6:06 pm

Yeah what Stevo said.

I had a hard time fixing my Capx, because double clicks would 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 :)
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Tue Sep 25, 2012 3:21 pm

@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.30gerris2012-09-25 15:29:30
B
16
S
4
G
1
Posts: 23
Reputation: 2,523

Post » Thu Jan 30, 2014 6:52 pm

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.
B
25
S
9
G
3
Posts: 487
Reputation: 3,825

Post » Thu Feb 13, 2014 9:19 am

What Schoening said, you have to have a flag to check if touched for the first time (Madonna style ;D)
B
16
S
4
G
1
Posts: 23
Reputation: 2,523

Post » Tue Feb 18, 2014 12:05 am

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.
B
4
S
2
Posts: 1
Reputation: 752

Post » Tue Feb 18, 2014 12:24 am

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.
...busy learning Unity - real lights etc!
(but c2 is easily the quickest way to make 2d html5 games)!
B
60
S
15
G
50
Posts: 2,085
Reputation: 33,190


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests