# How do I Calculate overlap area of an object?

Get help using Construct 2

### » 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

### » 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
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Sun Sep 10, 2017 8:09 pm

B
70
S
25
G
7
Posts: 163
Reputation: 8,484

### » Mon Sep 11, 2017 10:09 pm

@basspenguin
B
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Tue Sep 12, 2017 4:29 am

Thanks!
B
70
S
25
G
7
Posts: 163
Reputation: 8,484