How do I setup touch conditions for overlapping sprites?

0 favourites
  • 9 posts
From the Asset Store
Surena Touch
$2.50 USD
A wrap from official Touch plugin to export touch/mouse input to other plugins.
  • [attachment=0:1nw0ronc][/attachment:1nw0ronc]

    Hi there,

    If I want to have two events setup to detect

    1) user touched the green box

    2) user touched anywhere in the red box that's not overlapping with the green box??

    [quote:1nw0ronc]On touched "green box" -> do action 1

    [quote:1nw0ronc]On touched "red box" -> do action 2

    action 2 is always triggered when the green box is touched. How do I tell Construct2 to not "click through"?

    Thanks

  • This is very tough since green and redbox are always overlapping.

    I have a solution, which might not be best practice.

    1. Change Action 2 event to

    On touched "red box"

    Not is in touch with "green box

  • Hi,

    I actually have the same problem.

    I tried your solution Rabenmutter but it is not working. My buttons simply just stop working .

    I really need a solution for this since i create for android and i want to make my custom "Messages" which always overlays on the objects behind it.

    Please some help! Thanks in advance!

  • Try this:

    Put both of them in a family.

    Give family instance variable "Sprite Name".

    On touched family

    Pick top

    --- If SpriteName == "green" -> Do action 1

    ---else -> Do action 2

  • Try this:

    Put both of them in a family.

    Give family instance variable "Sprite Name".

    On touched family

    Pick top

    --- If SpriteName == "green" -> Do action 1

    ---else -> Do action 2

    What do you mean by "Pick top" ?

  • Add Condition -> Choose Family -> Pick top/bottom (under Category Z Order)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is touching "Green"
        Trigger Once
        : Do action 1
    Else
    Is touching "Red"
        Trigger Once
        : Do action 2
    [/code:1ztfbgi4](a space before means its a sub event, the : means its the action)
  • Is touching "Red"
        Is not touching "Green" > Do action 2
        Else > Do action 1[/code:imt7tuqw]
    
    If you add the sub condition of not touching "Green" it would mean anywhere in the red area that isn't covered by green.
    
    Here is a demo: (Warning: This file may induce seizures.)
  • Thanks all. I got it working after reading all the replies. The key is to use Is touching instead of On touched.

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