Create an object only if it is not overlapping?

0 favourites
  • 9 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I have scenario where I have to create objects (of different size and shapes) randomly on X-axis with Y = 0 at every X seconds. However, while creating I have to ensure that the object does not get created on other objects (i.e. not overlapping).

    Please note that the objects once created start scrolling down the Y axis! Once the object leaves the layout, they are destroyed and new objects are created from the pool with Y = 0.

    Any suitable suggestion are welcome :)

  • Add that object into a family.

    If object overlaps family, destroy it.

  • Like Maverick said create the spawned objects into a family.

    You can also save a bit of memory by inverting the "is overlapping" event so that the object won't spawn at all. This will work better if "on destroyed" is scoring points etc.

  • Add that object into a family.

    If object overlaps family, destroy it.

    SVG's cannot be added to the family?

  • Like Maverick said create the spawned objects into a family.

    You can also save a bit of memory by inverting the "is overlapping" event so that the object won't spawn at all. This will work better if "on destroyed" is scoring points etc.

    But how can I test is overlapping without creating the object first?

  • > Add that object into a family.

    > If object overlaps family, destroy it.

    SVG's cannot be added to the family?

    I don't know why you said it can't

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • > Like Maverick said create the spawned objects into a family.

    >

    > You can also save a bit of memory by inverting the "is overlapping" event so that the object won't spawn at all. This will work better if "on destroyed" is scoring points etc.

    But how can I test is overlapping without creating the object first?

    Consider you have 4 slots of object spawning.

    Pick random slot that not being chosen(isChosen = false).

    After picked, set isChosen = true.

    Then the next ones will pick the slots that has isChosen = false only.

  • > > Add that object into a family.

    > > If object overlaps family, destroy it.

    >

    > SVG's cannot be added to the family?

    I don't know why you said it can't

    My bad I was trying to add two different object type in the same family. Even if I create a family how can I test if it is overlapping anything in the layout before creating the object?

  • > > Like Maverick said create the spawned objects into a family.

    > >

    > > You can also save a bit of memory by inverting the "is overlapping" event so that the object won't spawn at all. This will work better if "on destroyed" is scoring points etc.

    >

    > But how can I test is overlapping without creating the object first?

    Consider you have 4 slots of object spawning.

    Pick random slot that not being chosen(isChosen = false).

    After picked, set isChosen = true.

    Then the next ones will pick the slots that has isChosen = false only.

    I have flying objects in the layout and what is happening if I create an object randomly at X with Y = 0, then sometimes the object gets created on those flying objects. I guess with this approach the issue won't be resolved.

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