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
24
S
4
G
1
Posts: 177
Reputation: 1,827

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://www.dropbox.com/s/bitbk9af918us ... .capx?dl=1
/examples33/overlap_pixels_poly.capx
Last edited by R0J0hound on Mon Sep 11, 2017 10:08 pm, edited 1 time in total.
B
94
S
33
G
118
Posts: 5,392
Reputation: 75,845

Post » Sun Sep 10, 2017 8:09 pm

Heya @R0J0hound. Any chance you could reshare this capx? :) Thanks bud!
B
56
S
16
G
7
Posts: 148
Reputation: 7,202

Post » Mon Sep 11, 2017 10:09 pm

@basspenguin
link updated
B
94
S
33
G
118
Posts: 5,392
Reputation: 75,845

Post » Tue Sep 12, 2017 4:29 am

Thanks!
B
56
S
16
G
7
Posts: 148
Reputation: 7,202


Return to How do I....?

Who is online

Users browsing this forum: SnipG and 8 guests