How do I avoid clicking on underneath object

Get help using Construct 2

Post » Mon Jul 14, 2014 7:13 pm

There is one thing that always gets me confused.
why can I click on a object even though is underneath another one?

I might be missing something here but it should be very simple.

Here is the capx file.
https://www.dropbox.com/s/66w9kv2b0snwcjq/clickon.capx
B
124
S
51
G
24
Posts: 401
Reputation: 22,617

Post » Mon Jul 14, 2014 7:33 pm

You could Just add is visible to the condition or set variable when you want it enabled.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Mon Jul 14, 2014 9:13 pm

I don't understand your answer. Here is my question again:

How come I can click on the blue image if it is underneath the green one?

Since the blue is on top, if I try to click on the green over the blue it shouldn't work.
It feels like the click go though all the objects and trigger any action associated with all of them
B
124
S
51
G
24
Posts: 401
Reputation: 22,617

Post » Mon Jul 14, 2014 9:29 pm

CD2 doesn't care about who's on top. You need to apply more logic to isolate this case yourself.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Mon Jul 14, 2014 9:33 pm

I know how to do it using IF but I don't think it should be like that at all.
I doesn't make any sense. The object on top should block the click on the object in the bottom.
Even if I need to change a object's property would make more sense than it is now.
B
124
S
51
G
24
Posts: 401
Reputation: 22,617

Post » Mon Jul 14, 2014 9:35 pm

The more flexible the system the more logic you need to get specific results.

I updated your capx
clickon.capx


There are so many ways to validate the click, some easy some hard. This is just one example that takes into account the relative position and zindex of the green sprite. I usually use variables to enable what i want clickable. But based on your example i chose to do this.
help1.png


In any case that's just the nature of programming. sometimes you have to do the heavy lifting.
You do not have the required permissions to view the files attached to this post.
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Mon Jul 14, 2014 9:43 pm

@troublesum

Thank for it!

I know how to do it, I just don't think it makes sense we need to do it like that for such a simple thing.
B
124
S
51
G
24
Posts: 401
Reputation: 22,617

Post » Mon Jul 14, 2014 10:09 pm

It does and it doesn't make sense at the same time , it all depends on how you see things.

Other would like to hit it for his own reason , some other again , would like not to hit it , since its under something else , and logic (human logic) says not to.

Other than that , thats why it has the visible command , or destroy etc , in order to please both situation.
Hire or Offer a project

Portfolio

Scirra new Shop
B
34
S
5
G
1
Posts: 118
Reputation: 2,663


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests