Let's learn about Cloning! http://wiki.scratch.mit.edu/wiki/Cloning
Cloning is a feature that allows a sprite to create a clone, or semi-duplicate, of itself, while the project is running. For example in a fish tank, you can create clones of a fish sprite to make it look like there are many fish swimming around in the tank. Clones of a sprite will be the same as the original, or parent sprite, but as a separate instance. Clones inherit the parent's scripts, costumes, sound...
Cloning versus Duplicating a sprite
You can duplicate a sprite using the duplicate tool (which looks like a stamp). This will make the new sprite appear in the new sprites area with all of the same costumes, scripts, and sounds. It's not the same as cloning. When cloning, you only have one sprite in the sprite area. If you need to change something about the fish, for example in what pattern the fish swims, then you have to change the script of only one sprite. If you duplicated the fish with the stamp tool 3 times, then you need to change the script in all 3 duplicate sprites, so it will take 3 times longer. It's fine to use the duplicate tool if you just need a few fish. But if you want lot's of fish, use clone!
Examples:
- https://scratch.mit.edu/projects/94628768/ - Eat the Fish game version1: uses the duplicate tool to create 3 copies of the fish
- https://scratch.mit.edu/projects/94650050/ - Eat the Fish game version2: uses cloning to create 7 clones of the fish.
- https://scratch.mit.edu/projects/67699066/ - Infected. This game keeps cloning and cloning every few seconds, so you end up with a lot of red dots moving on the screen, that the player needs to avoid.
Activity:
Try the "create clone", and "when I start as a clone" blocks. Don't remix, create a new game of your own. You can make an Eat the Fish game, or clone storm troopers or honeybees or whatever you can think of cloning.
Steps for making the Eat the Fish game using cloning:
- Get a background form the library that looks like a fish tank or ocean
- Get the shark from the sprite library. Code it to follow the mouse: Use go to mouse-pointer wrapped in a forever block.
- Get a fish from the sprite library. Clone it: When the Flag is clicked, create 7 clones. Then use the "when I start as a clone" block and code the fish to randomly swim around on the screen.
- Keep score. When the shark touches a fish, increment the score.