How do I stop Tap and Touch propagation

Get help using Construct 2

Post » Thu Aug 13, 2015 3:04 pm

I am working on a game for the Underground contest - it has a map, which you can tap, which has sprites on it, you can tap these, and has various gui items you can also tap.

Problem is, when I tap one of the sprites, it also registers a tap on the tilemap underneath it - how do I stop the tap from propagating down the objects ?
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Thu Aug 13, 2015 6:19 pm

@paulscottrobson
I ran into this problem, and could not find a way to have it not register the tap on objects below the one on top.

So, the only option is to manually not process the tap on the other objects. One way, is put the events that process taps on the tilemap in a group and then disable the group when you open the map - then as long as the map is visible, the tilemap under it will ignore taps. (obviously, you have to remember to re-activate the group when you close the map).

If you don't want to totally disable the entire tilemap, then you could have some kind of global variable like TapProcessed. Then have the first sprite set that to true. Other objects would check that to see if they should ignore the tap or not. Reset it to false on Touch End.

Another way that worked really well for me was to spawn an invisible sprite at the touch point, that follows the touch (by using TouchID). Then checking that sprite for collisions with objects. I had to do this to properly handle multiple touch points. Using this method, you can turn off collision checking for any objects you don't wanted the touch to apply to. It got a little complicated, but worked really well. I was thinking of cleaning up the code and making a tutorial for it some day.
B
94
S
33
G
20
Posts: 438
Reputation: 17,615

Post » Thu Aug 13, 2015 9:10 pm

Thanks - I've got it working now, used your invisible sprite idea :)
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983, marcoscodas, Yahoo [Bot] and 12 guests