How to avoid issues when using launch block in loops

Using tell to launch a clone of another sprite is quite a useful technique (that @jens ) suggested to me for a project but I've been having issues with it.

I've finally worked out why and thought it could be useful information to others in future.

I've made a simple demo

which works fine with a wait 2 secs delay inside the loop

But if you reduce that down to 0.5 secs - it doesn't work in the way that's expected

and that's because of two issues.

The first one is that the loop is looping around faster than the the launched clone can deal with its speed.

So by the time a clone gets to say the number i - the for loop is already on its next pass and so it gets the wrong value

And even worse, the last clone is getting the number 4 - and that is down to the fact that, in Snap!, a for loop variable is increased until its gone past the last value.

Things change again if delay is 0 secs

and with no delay at all - even the sprite position goes wrong

There is a cure for all this though and that is to click on the launch block black arrow and expand it to give "with inputs"

or the more explicit method when you want to feed in more than one parameter

Anyway - hope this helps someone else - I'm off to apply it to my Missile Command project :slight_smile: