How do I stop touch conditions to overlap with each other?

0 favourites
  • 12 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • What I intend to make:

    On object 1 tapped -> Trigger event nr. 1

    On object 2 tapped -> Trigger event nr. 2

    What my issue is:

    If object 1 is overlaping object 2, both events get triggered. How do i solve this?

  • add a new condition

    if you right click on the events you will see an "invert" option.

    on object 1 tapped

    is not overlaping object 2 >>>> action

    else >>>>> action

    on object 2 tapped

    is not overlaping object 1 >>>> action

  • What I intend to make:

    On object 1 tapped -> Trigger event nr. 1

    On object 2 tapped -> Trigger event nr. 2

    What my issue is:

    If object 1 is overlaping object 2, both events get triggered. How do i solve this?

    If both objects are overlapping how do you filter wich one to pick?? wich conditions do you use to filter it??

    if you can post a capx will be easier to check

  • Turaco see if this can help you, it picks the top object

    https://www.dropbox.com/s/0guz0az3phrzuue/PickTopInstance.capx?dl=0

  • Turaco You could do something like this, using the Zindex for each sprite:

    https://www.dropbox.com/s/s9a857gm34hgv ... .capx?dl=0

    It starts to get a bit complex if you have multiple sprites - you may have to shift the overlap check into a function and pass the UIDs.

  • tarek2 - much simpler than mine, good call!

  • tarek2 - much simpler than mine, good call!

    Thanks

  • Well it's not a solution because if they're not overlapping it will just pick the one with higher Z which isn't necessary the one I'm clicking on.

    What I did was create a global variable "Touch_Enabled". After I click on something - > Touch_Enabled set to 0, wait 0.1 seconds -> Touch_Enabled set to 1.

    My problem wasn't the overlapping actually. "Tap on object" already picks it only if its on top. The problem was when I click on Object 1 and it destroys my Object 1 = it triggers the Object 2 underneath it. Weird but whatever

  • Weird but whatever

    Variables, use Instance variables and simply create a specific loop for events in whatever order.

    Or if you have preference use greater than and sort of 'order' your objects from highest to lowest.

    Variables fix all.

    A capx would be handy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > Weird but whatever

    >

    Variables, use Instance variables and simply create a specific loop for events in whatever order.

    Or if you have preference use greater than and sort of 'order' your objects from highest to lowest.

    Variables fix all.

    A capx would be handy.

    It wouldn't solve it. As I said before, even if I add "If Object 1 is overlapping Object 2 - inverted" it doesn't fix it. Because the event triggers after Object 1 is deleted on click, meaning the Object 2 is selected in the same tick

  • Variables

    overlap- True if theres an overlap, false if not.

    So, can you not say that when overlapping set var overlap to true, select object 1?

    Or instead of select object 1 just use a random or whatever you wish.

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