How do I expand an object only on sides that have not collided with another?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have some simple logic that creates a square shaped sprite when the user touches the screen, this box expands evenly on all sides while the user holds the press.

    I want the expansion to halt on any side that collides with another object.

    For example, in the image below...

    The user presses and holds, the initial box is created and starts to expand.

    The user continues to hold the box expands evenly on all 4 sides.

    The user continues to hold, but the right hand side connects with another object so the expansion of the right side stops and the expansion continues on the left, top and bottom sides.

    What would be the best way to implement this type of expansion?

  • This is not exactly the kind of process you want, but it could help.

    https://drive.google.com/file/d/1lcvW1ng4FMXC8ExSjnH4QIA8V7rbS2tH/view?usp=sharing

  • Hadn't done this before so I tried a few things. Super bloated and a bit glitchy when contacted on 3 sides but: onedrive.live.com/redir

    There's got to be an easier way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mrcgkh Thanks for the reply... I took a look at the solution and it implements functionality that I had working where the boxes expand until they collide with another object, the continued expansion on non impacted sides is the issue I am looking to solve. However, the destruction and creation of objects based upon the touch events are something I will take into consideration in my final solution.

  • calminthenight This solution looks like it may do exactly what I was looking for. Initial tests don't seem to be presenting the glitches you mentioned. The code will take me a little time to dig into and fully understand, but it looks very promising. Thanks for the quick response.

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