Cloning Sprites
Imagine you want lots of raindrops, or many enemies, or a whole flock of birds. You could copy a sprite many times by hand, but that would be slow and messy. Scratch has a much cleverer way called cloning. A clone is a live copy of a sprite that Scratch makes while your project is running. Clone blocks live in the orange Control category.
The three cloning blocks
- create clone of myself — makes a fresh copy of the sprite (you can also clone another sprite by choosing its name).
- when I start as a clone — a hat block that runs whenever a new clone is born. This is where you tell each clone what to do.
- delete this clone — removes the clone when its job is done.
How cloning works
When you run create clone of myself, a new clone appears in the exact same spot, with the same costume and settings as the original. Right away, any when I start as a clone script begins running for that clone only. Each clone runs its own copy of that script, so all your raindrops can fall at the same time without you writing separate code for each one.
Cleaning up clones
Clones use memory, and Scratch allows up to 300 at once. If you make clones without removing them, your project can slow down or stop making new ones. That is why delete this clone is so important, for example when a raindrop reaches the bottom of the stage or an enemy is hit.
A simple pattern
A very common setup is: the original sprite stays hidden and, inside a loop, keeps running create clone of myself. Each clone then has when I start as a clone that shows itself, moves, and finally runs delete this clone. This gives you a steady stream of moving objects from just a few blocks.
Cloning is a fantastic tool for games full of bullets, stars, snowflakes, or enemies. With a handful of blocks you can fill the whole screen with action.