Patterns with Clones
There is one more wonderful tool in Scratch to help you make use of patterns you identify—the clone tools. You can find 3 cloning blocks in the "Control" portion of Scratch's code selector.
Suppose you wanted to create several sprites that all did the same thing (sounds like a pattern, no?). But you want them to each behave independently. For example, perhaps you want to create a winter holiday card where snowflakes fall gently down from the top of the screen. You could create dozens of snowflakes, but then you would need to code each one to do the same thing individually. Do you see a pattern emerging? Let's use clones to take advantage of the pattern.
Decomposition:
First, let's break down what you would need in order to accomplish this task:
- A snowflake
- When the flag is clicked, create a clone of the snowflake every .5 second or so.
- Position this new snowflake at some random horizontal position at the top of the screen.
- Make the snow flake gently "fall" to the bottom of the screen.
- If the snowflake touches the bottom of the screen, delete it.
There is a lot more we could do with this code, but let's keep it simple for now. Watch the video below to learn how to create this project in Scratch.