How can I prevent objects underneath being clickable?

1 favourites
  • 9 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I have searched for an answer to this but can't find anything similar.

    Basically, if you have a clickable object and it gets covered by another object on top of it how do you stop the bottom object from being clickable?

    Specifically, I am working on a puzzle type game with a slide in menu. The menu covers about a third of the screen but touching or clicking on the menu will still affect what's underneath it! I can disable the clickable parts when the menu slides out but it would be a whole lot easier if anything the menu covered were not available, or to put it another way, make the menu impenetrable.

    Any ideas will be gratefully received, thanks

  • There is a condition "Pick top/bottom".

  • Use Layers, then qualify your selection by deciding if the object you want to click is on that layer.

  • Thank you both for your suggestions, however . . . . . .

    1. From what I can make out "Pick top/bottom" only works on instances and I have lots of seperate objects to disable.

    2. I have the objects on different layers but that method is not quite what I need to accomplish.

    All of the objects still need to be clickable, just not when they are behind some thing else. I suppose what I need is some way of masking off the area when the menu is visible.

    I hope this makes the problem a little clearer.

    Thanks for your input anyway.

  • Make a variable, call it isUnder.

    When you place that object under another set the variable to 1.

    That way you can use the variable to keep from picking that object.

    object variable "isUnder"=0

    -on object clicked, do fo

    If the variable condition is not met, its not picked.

  • Thanks Newt for your suggestion, but I already have a variable which locks the objects under different conditions and I was looking for a far simpler solution that would prevent click through for all objects on all layouts in the game . . . . . and I think I've found the answer!

    All of the objects were already in a Group so I just added one line that says

    OnTouched Object (the object on top) -> Set Group (the objects underneath) Deactivated.

    I made sure that the collision polygon covered the whole area to mask off and it seems to work!

    Thanks again for your time to consider this problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • familyobjects.clickable = true


    familyobjects overlapping familyobjects

    familyobjects select bottom


    familyobjects.clickable = false


    onclick/touch familyobjects

    familyobjects is clickable

  • You could try having all the objects on the same family, then pick topmost from that family.

    Something like

    [Pick topmost from family]

    |-[if Object is clicked] - Something happens

  • Hi,

    My solution for this is to add the events into a GROUP.

    Let say, Object 1 is in Group1, Object 2 is in Group2 etc.

    If you want to make Object 1 unclickable, set Group1 as Disabled.

    Same thing on Group2. You only need to enable when needed.

    Hope this helps.

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