0 Favourites

How do I (Tiled Background Destroy if Overlapping)

  • I need lots and lots of the same duplicated Tiled Background to randomly appear around my entire map. (Grass)

    However when the grass spawns on or overlaps itself, unlike the sprite I cannot delete the object. This is a big problem, I can destroy the Tiled Background but doing this destroys them all. Also I cannot find a way to target just that 1 instance of that Tiled Background.

    How can I check to see if the Tiled Background is overlapping another Tiled Background and then destroy that 1 Tiled Background.

    Of course I could use Sprites but having a 1000 sprites is laggy and simply not logical.

    Thank you for your help.

  • You'll want to utilize families.

    Put your tiled background into a family. Then you can use If tiledbackground overlaps family, destroy tiledbackground and it should only destroy tiledbackgrounds that are overlapping.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • oosyrag, thank you for your reply.

    Unfortunately it requires the non free edition of which I do fully intend to buy in a couple days. I will give this method a try and reply back here.

  • Free version workaround:

    Utilize a separate helper sprite with the same properties as your tiled background. Spawn the helper sprite as you would your grass - if it doesn't overlap a grass, place the actual grass tiled background object. If it is overlapping, then skip that step and move on to the next. Delete the helper sprite afterwards (or just move it to the next position).

  • Wow, that method right there is the way to go for free users. That's what I like best about Construct is how you can make almost anything work in many different ways.

    If sprite isn't overlapping tiled background then spawn and move on. If overlapping tiled background then don't spawn and move on. Could use this method for rocks and lakes too.

    I have a GlobalVariable set to 0. Every 1 second this number get's changed to a random number between 0-100. If it's <=5 then the group that spawns the grass is toggled once. But obviously I couldn't do this due to not knowing how to target a single instance of the silly tiled background.

    So thanks again, you have been of much help!

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