How do I stop Tap and Touch propagation

0 favourites
  • 3 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • 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 ?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks - I've got it working now, used your invisible sprite idea

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