How do I Calculate overlap area of an object?

Get help using Construct 2

Post » Sun Jun 12, 2016 3:59 pm

Hello guys!

I have an object that must be filled with spawned objects from the user. The user must have accurated aim because he has few spawnable objects to shoot. I need to calculate how much of area will be occupied / overlap byt these objects.

First I thought about calculating the amount of objects touching the final target. But if the user aims the same spot it would be calculated in a wrong way. The final objective is to fill the whole area and not just "touching" it.

Any ideas?

Thanks!
B
23
S
4
G
1
Posts: 173
Reputation: 1,794

Post » Mon Jun 13, 2016 6:11 am

One way to do it is to check if every point on the one object is overlapping an instance of a second object. Think loops with a couple "overlapping point" conditions. This can be slow checking every frame or even every time an object is placed on top so if you use an array to store the polygon area you can progressively do it by smaller area checks. Keep in mind this is based on collision polygons so something visually covered may not calculate as being so.

https://dl.dropboxusercontent.com/u/542 ... _poly.capx
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests