How do I detect if four smaller sprites are adjacent to one another to then turn into a larger one?

0 favourites
  • 5 posts
From the Asset Store
Footsteps SFX Four
$2 USD
60% off
Footsteps SFX Four contains 400 sounds of steps and jumps on different surfaces.
  • Hi there, I'm just experimenting with c3 a bit here & was wondering if anyone knew a simple way to achieve the detection of four sprites adjacent to each other ,or squares in this case, stacked in the form of a larger square & to then destroy those 4 sprites & replace it with the larger version in the same place that the original 4 were.

    I've created an illustration bellow to better convey my meaning as I am finding hard to put into words.

  • you could use a tilemap and check the tiles that surround another tile for other squares. If the right combination existed you could replace them with the new tiles for the bigger square or remove them and add an actual sprite at their position.

    If you didn't want to use tilemaps you could use the Bbox coordinates and check for similar, or you could use the is overlapping at offset.

  • Thanks for your response. I have tested out the overlap at offset but I am clearly doing something wrong & or not understanding something fundamental with it. I've attached a link to the file.

    drive.google.com/file/d/14kLj60QNdxYsfqNBkk-o0W0OT6dEDu4k/view

  • Have a look at the modified version of your file. 1drv.ms/u/s!AkmrWgxeuxlKhIcr596sbSuJg3Rawg

    I've set it up so that the small has instance boolean variables that indicate if it is overlapping to the right, below, and below&right. Then I've put the test for the overlaps into a function that is called when the sprite has arrived at its moveto location.

    You only ever need to check for the offset at those three positions because if four squares are together that condition will always exist.

    You can change when the function is called to suit whatever your game is about

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah ha! Works a treat, I'll have to study it somewhat to get a grasp on how the code functions but I think I have an idea from the quick skim I gave it.

    Thank you so much for your help, very kind!

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