Spawning Issue: Spawns twice at same position

Discussion and feedback on Construct 2

Post » Thu Dec 19, 2013 12:06 pm

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:



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?
adventurist2013-12-19 12:15:33
Image
B
12
S
3
Posts: 37
Reputation: 839

Post » Thu Dec 19, 2013 2:49 pm

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.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Thu Dec 19, 2013 4:30 pm

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. :)
Image
B
12
S
3
Posts: 37
Reputation: 839


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests