Why is this glitching?

When I click on the Space key quickly, several times in a row to create clones, Snap will eventually glitch to the point where I need to stop and start again.

Does anyone know why this is? Am I doing something that Snap doesn't prefer or is this a bug?
Thanks!

In the
[scratchblocks]
when [space v] key pressed::control
[/scratchblocks]
script, there are no checks for whether the sprite running the script is a clone or not. This is problematic because clones can run the script too. The script makes a clone of itself, meaning that the same script is also in the clone. So when space is pressed when there are two clones on screen, both of them will run the script, making five (plus one, for the original laser). Then when space is pressed after, it will make 11. Then 23. Then 45. Then 90. Then 181. Then 362, e.t.c.
image
(why isn't the image showing up?)

The number on the top left corner is the amount of threads running this script. Meaning that there are 1564 clones on screen. This is from pressing space quickly for around 2 seconds.

To fix this make sure that the when space key pressed script won't run for clones. Like this:

[scratchblocks]
when [space v] key pressed::control
if <not (my [temporary? v]::sensing)> then
create a clone of [Laser v]::control
end
[/scratchblocks]

Oh. Geez. I just moved over from Scratch and didn't realize the added capabilities.
Very cool. Thanks!

Chrome says that the size is 1x1 if I open it in a new tab.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.