Spawning Issue: Spawns twice at same position

0 favourites
  • 3 posts
  • Hi!

    I've got a problem with spawning a new object at the last objects position.

    Now it works spawning a new object, but sometimes it spawns an object twice.

    Let me show you my code:

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

    so basically I create a grid with randomly created objects with different colors.

    Then I check if a green box collides with another green box, and if it does, delete it and spawn a new one at its position.

    Sometimes, not all the time, it creates two at the same position, which I can tell when counting the objects and testing in debug mode.

    Does anyone know why it does this and how I can prevent it from happening?

  • I'd say you are abusing 'Trigger once'. Looks like you should be using 'On start of layout' for your 'For each' events, and set an instance variable indicating that green is dying and check that rather than Trigger once.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks!

    I changed it so the 'for each' events are triggered on 'start of layout', and I also changed so that once green is deleted, another events checks if it is, and then spawns another object. Works fine that way.

    Thanks for your help! I will not abuse the 'trigger once' again. :)

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