Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Make multiple clones in one tick?
- SilasMann
- Scratcher
15 posts
Make multiple clones in one tick?
I want to clone Sprite2 four times.
I can do it at least two ways:
But the first one takes a few ticks to do and stops the rest of the script from executing until it's finished, while the second one is very inefficient and takes up a lot of space. What is a better way to do it?
I can do it at least two ways:
repeat (4)
create clone of [Sprite2 v]
end
(or)
create clone of [Sprite2 v]
create clone of [Sprite2 v]
create clone of [Sprite2 v]
create clone of [Sprite2 v]
But the first one takes a few ticks to do and stops the rest of the script from executing until it's finished, while the second one is very inefficient and takes up a lot of space. What is a better way to do it?
Last edited by SilasMann (Aug. 8, 2017 04:10:57)
- gtoal
- Scratcher
1000+ posts
Make multiple clones in one tick?
is the first one in a no-refresh block or at the top level>?
- SilasMann
- Scratcher
15 posts
Make multiple clones in one tick?
I'm not sure what you mean by top level, but it's not in a custom block. My code looks like this:
You can see my (embarassing) code I am referring to here: In the Player sprite, at the bottom of the huge ugly gamestart hat block.
when I receive [startCode v]
code [... v]
repeat (5)
create clone of [Sprite2 v]
end
stop [this script v]
You can see my (embarassing) code I am referring to here: In the Player sprite, at the bottom of the huge ugly gamestart hat block.
Last edited by SilasMann (Aug. 8, 2017 04:21:52)
- gtoal
- Scratcher
1000+ posts
Make multiple clones in one tick?
ok, well create a custom block that does what the ‘when i receive’ code does, and call that block instead of the lines of code directly. if you mark the custom block as ‘no screen refresh’ I think it may improve your clone creation time. It'll never be instant but it may be a bit faster. Be wary of race conditions when two clones are being created at nearly the same time - copy the clone ID immediately and then use local variables only.
- Discussion Forums
- » Help with Scripts
- » Make multiple clones in one tick?