# [Solved] Overlapping entirely.

Get help using Construct 2

### » Mon Aug 13, 2012 10:23 am

Hello !

How to make a condition when a sprite is overlapping entirely another one.

Example :

Thanks !Joskin2012-08-13 11:40:03
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

### » Mon Aug 13, 2012 11:03 am

You can't as far as I know. You could fake it, but theres no one condition to do it..
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

### » Mon Aug 13, 2012 11:10 am

Example capx

The idea is that the red Sprite2 is smaller than the black Sprite.
Each tick that red is overlapping black, test that the left and right boundaries of Red are in between the Black left and right boundaries and do the same for the top and bottom boundaries.

The code in the capx works because the origin point is in the middle of the texture and so Sprite.X - (Sprite.width / 2) gives the left boundary position, Sprite.X + (Sprite.width / 2) gives the right, etc...

Note: the parenthesis in the formula are not mathematically necessary but help visualising the priority of the operations.
New to Construct ? Where to start

Please attach a capx to any help request or bug report !
Moderator
B
243
S
85
G
39
Posts: 6,932
Reputation: 56,898

### » Mon Aug 13, 2012 11:39 am

Thank you Kyatric, this is exactly what i needed !
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

### » Mon Aug 13, 2012 4:05 pm

B
53
S
28
G
18
Posts: 1,520
Reputation: 24,905

### » Mon Aug 13, 2012 4:13 pm

That is clever..
B
36
S
10
G
6
Posts: 948
Reputation: 11,101

### » Tue Aug 14, 2012 9:15 am

"Is there a way to check if an object is in its entirety inside another object?"

That's why, I searched with the keyword "entirely", you know, search engine are not perfect.

B
39
S
15
G
5
Posts: 295
Reputation: 6,089

### » Mon Mar 11, 2013 2:18 am

So far Untested but ...

you could try(experiment!) using the invert function and play with that...So like a combination of both overlap and inverted overlap

so something like...

is red cube x,y, = black cube x,y ->
is red cube overlapping ->
is red cube width,height <= to Black Cube width,height ->

as a pre check set of conditions

and then compare it to the next statement

is red cube x,y, = black cube x,y ->
is red cube NOT overlapping -> (use the invert function)

of course this doesnt take into consideration any Alpha transparencies areas that the object may have..

That I know of

Its always worth experimenting...You may find out something new and undocumented.....!!! bonus points if you share!!!
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
27
S
10
G
8
Posts: 288
Reputation: 7,135