How do I prevent hidden objects or layers to react to clicks

Get help using Construct 2

Post » Mon Feb 02, 2015 7:11 am

Hi. I have some hidden objects and layers but they register touch and onclick events. So if an object is not visible it can still do something if you hit the spot or even if it is behind another object. Is it possible to disable this behavior so it does not get clicked if it is hidden behind another object or invisible?

Someone told me I should "disable collision" but this did not work. :(
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Mon Feb 02, 2015 8:05 am

Just add a extra condition on the event you dont want triggered.


condition
"Object" Is Visible

or if you need a whole layer I.e pause
Add the system event Layer is Visible

you can also add the condition is overlapping "otherobject" and invert it so it only works when not overlapping if that's what you need
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Mon Feb 02, 2015 8:40 am

Thank you very much! I thought about so much things but forgot to try the IsVisible condition. :)

I added a scrolling feature if you swipe or click and drag to scroll from top to bottom of the page (it moves all elements with dt*Touch.SpeedAt(0)). Some clickable objects are hidden behind the logo and navmenu on top. So I think I will try to set all objects with Y < X to invisible to prevent clicking on them and make them visible again if Y > X. Or does anyone have another idea how to do this?

You can see it here: http://galciv3.bl4cksh33p.de (good example is on "Datenbank" in menu on top and then on "Medien / Wallpaper". When you scroll down, the images behind the navbar are clicked when you click on another menu item. Maybe "is overlapping object" does work, too?

/Update: I added an inverted "is overlapping object" and it seems to work fine. The only "problem" is that images which are only partially shown are not clickable anymore because part of them is colliding/overlapping the tiled background on top (behind logo and navmenu).

I think its ok for now but if anyone has an idea how to check if an image is partially behind an object or completely, I would be glad to hear your ideas.
This works great for Sprites, but Textobjects have no "is overlapping" condition so I can't do it the same way for them. Any ideas?
B
53
S
16
G
6
Posts: 718
Reputation: 9,150

Post » Mon Feb 02, 2015 9:22 am

One more thing: the "is overlapping object" works fine in most cases (line 4) but in the example below (line 5) it does not work. It opens the URL even if it overlaps (is behind) the "Erfolge" sprite. Any ideas why? Clicking on the "MedienSprite" or "Erfolge" (both are overlapping) opens the webpage and jumps to a new layout at the same time.

Image

The "Erfolge" Sprites are on a global layer on another layout. Does collision check not work for this reason?
The TiledBackground is on the same layout and works fine.

And it seems hiding a layer does not hide the objects. (could be a feature or a bug, but I think it may be intended)
Image
The above code is executed even if the layer where the "Erfolge" sprite is on is hidden. So even if you cant see it the sprite it is "visible" as long as you dont hide them individually.
B
53
S
16
G
6
Posts: 718
Reputation: 9,150


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 2 guests