Discuss Scratch

phoenix_unleash
Scratcher
4 posts

how to stop a clones from cloning?

hi, I just wan't to ask, In an aquarium game everytime you want to buy your fish,I usualy clone the fish, but If you clone the fish again the clone clones it self. Can anyone help?
Malicondi
Scratcher
1000+ posts

how to stop a clones from cloning?

If you're using broadcasts, the issue is because since all clones respond to broadcasts, they will also clone themselves. A simple fix to this would be to make a variable, for this sprite only, like this:
(clone?)
and we can use to to make sure only clones do the cloning, like this:
when green flag clicked
set [clone? v] to (0)
... // your other green flag stuff

when I start as a clone
set [clone? v] to (1)
... // other clone code

when i receive [buy fish v]
if <(clone?) = (0)> then
... // buying fish code here
This works because if you have a variable “for this sprite only” each clone and the mainsprite can have it set to different values, so each clone will have it as “1” and the main sprite will have it as “0”. Hope this helps!

post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.

coming soon :)


deck26
Scratcher
1000+ posts

how to stop a clones from cloning?

You can also use an uncloned sprite to create the clone of the sprite being cloned so a broadcast to that uncloned sprite is only ever run by one object.
phoenix_unleash
Scratcher
4 posts

how to stop a clones from cloning?

ok thanks

Powered by DjangoBB