[Solved] Overlapping entirely.

0 favourites
  • 8 posts
  • Hello !

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

    Example :

    <img src="http://i.imgur.com/PEF9o.png" border="0" />

    Thanks !

  • You can't as far as I know. You could fake it, but theres no one condition to do it..

  • 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.

  • Thank you Kyatric, this is exactly what i needed !

  • That is clever..

  • "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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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!!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)