How can I prevent objects underneath being clickable?

Get help using Construct 2

Post » Thu Feb 20, 2014 2:08 pm

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
B
4
Posts: 8
Reputation: 237

Post » Thu Feb 20, 2014 2:14 pm

There is a condition "Pick top/bottom".
B
157
S
66
G
42
Posts: 2,603
Reputation: 35,343

Post » Thu Feb 20, 2014 5:00 pm

Use Layers, then qualify your selection by deciding if the object you want to click is on that layer.
B
48
S
16
G
9
Posts: 1,098
Reputation: 11,197

Post » Thu Feb 20, 2014 7:44 pm

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.
B
4
Posts: 8
Reputation: 237

Post » Thu Feb 20, 2014 7:51 pm

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.
B
169
S
50
G
173
Posts: 8,319
Reputation: 110,282

Post » Fri Feb 21, 2014 10:59 am

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.
B
4
Posts: 8
Reputation: 237

Post » Fri Feb 21, 2014 12:12 pm

familyobjects.clickable = true

event:
familyobjects overlapping familyobjects
familyobjects select bottom
action:
familyobjects.clickable = false

event
onclick/touch familyobjects
familyobjects is clickable
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Feb 21, 2014 1:07 pm

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
B
124
S
43
G
41
Posts: 849
Reputation: 28,235

Post » Thu Mar 06, 2014 8:28 am

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.
B
23
S
6
G
3
Posts: 39
Reputation: 4,759


Return to How do I....?

Who is online

Users browsing this forum: KTML5, newt and 28 guests