How do I check if a sprite is overlapping other one entirely

Get help using Construct 2

Post » Wed May 13, 2015 8:48 pm

I need to execute an action (set position) only if a sprite is overlapping other sprite entirely. Both are the same size and have the same shape. I tried to change the collision polygon but not worked. Thanks.
B
74
S
13
G
3
Posts: 995
Reputation: 7,531

Post » Wed May 13, 2015 8:53 pm

If they are the same shape and size if their positions are they same then they would be exactly over top of each other. That is as long as their origin is located in the same place. So if their X and Y are equal then they are overtop of each other.
B
23
S
4
G
2
Posts: 364
Reputation: 2,392

Post » Wed May 13, 2015 9:13 pm

And if their origins are not the same using the boundingbox-coordinates could be used to check..

If one of the sprites is moving (which is almost certain) it must be said that there is hardly any chance of the coordinates to be exactly the same, so you might want to work with an expression checking if the sprite is within a distance of for example 5px of the other, and set it to the exact location if so..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu May 14, 2015 12:44 am

Check the distance between the two sprites is a good solution. Thanks @LittleStain.
B
74
S
13
G
3
Posts: 995
Reputation: 7,531


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests