How do I avoid clicking on objects covered by other objects?

Get help using Construct 2

Post » Wed Sep 21, 2016 6:26 pm

I have an event that detects clicking on an object in my project. But that object sometimes gets covered by some other object, but the clicking event still works.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Wed Sep 21, 2016 8:01 pm

This function helps alot with alot of things.

Shy of knowing what you want to click on, are they in fixed positions?, edit the sprite hit box individually.
You can have various sprites count as the same object with "family" (set this up in the family file, on the right with projects/(layouts but not layouts)

Add a family. And on click, use family not sprite, just have the sprites all belong to the same family for the same effect on each

If the problem is something moves over it. Just have on click and is not overlapping sprite.. (sorry)
If I'd be interested to know other ways to resolve this
B
9
S
3
Posts: 113
Reputation: 1,009

Post » Wed Sep 21, 2016 8:38 pm

thats easy, just start your touch event with a condition like this:

Image
Image

Image
B
38
S
14
G
7
Posts: 408
Reputation: 8,338

Post » Wed Sep 21, 2016 8:51 pm

IJCT, it works, but in my case, the object is not covering the one bellow. So you can click it on one part of it, but not on the covered one.

I've tried using overlapping at offset, but it does not work.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Post » Wed Sep 21, 2016 9:49 pm

Unless there is someone who can come up with a better way of resolving the issue, you'll need to use Families in order to completely resolve this. (Families are available on the personal and business licenses of Construct 2.)

https://www.scirra.com/manual/14/using-a-license

Here's an example from another thread on how to resolve a 'clicking-overlapping-sprites' issue.

viewtopic.php?f=147&t=79856&p=1067723&hilit=overlapping#p1067723

There's a way to resolve simple overlapping issues without having to use the Families, but that method will need a lot of extra work if you plan to use it for randomly spawning enemies.

I have created this example for another thread, but again it's only good, if the number of your sprites that needs overlapping attention is not set to rise.

https://www.dropbox.com/s/qte9ubnfou1um ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Wed Sep 21, 2016 9:50 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Sep 21, 2016 10:08 pm

Thank you very much for the update, 99Instances2Go. I've learned something new from you today. I'll find the old thread and update that with this information as well. :D
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Wed Sep 21, 2016 10:49 pm

Well, i had it almost. Used same logic, and that is not needed with familys.

Updated.

https://www.dropbox.com/s/9jynn0vdss9rp ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Sep 22, 2016 1:05 am

Yes, I like the updated one better. Thank you again, 99Instances2Go. :D
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Thu Sep 22, 2016 1:07 pm

In my case, it's just a window that appears and the sprite I'm using to shade the background. The window is at Z 6, while the shadow is at 5.
The problem is that I want to make it able to close the window by clicking the background, but I can also close it by clicking the window.
My first project:
Image
B
20
S
8
G
1
Posts: 172
Reputation: 2,463

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests