Clones, Timers and Levels
💻 ScratchUse clones and timers to create enemies, effects and level pressure.
Clones are copies of a sprite that run their own scripts. They are perfect for falling objects, bullets and explosions.
- Create and delete clones.
- Give each clone its own behaviour.
- Use the timer to add pressure.
Create a Clone
The create clone of myself block makes a copy. A when I start as a clone hat block runs only for that copy.
when green flag clicked
forever
wait (1) seconds
create clone of [myself v]
end
when I start as a clone
go to x: (pick random -200 to 200) y: (180)
repeat until <(y position) < (-170)>
change y by (-4)
end
delete this cloneDelete Clones
Every clone should end with delete this clone. Scratch has a limit on clones, so leaked clones eventually stop the project from creating more.
Timers and Levels
Use the timer to measure elapsed time, or a countdown variable to create urgency. Increase the falling speed when the level rises.
Practice
- Create one clone every two seconds.
- Make each clone disappear when clicked.
- Increase falling speed after every ten points.
Hands-on exercise
Create a falling-object effect.
1. Every second, create a clone of the object.
2. Send each clone to a random x position at the top.
3. Move it down until it leaves the stage.
4. Delete the clone at the bottom.
Recap
Clones let one sprite act like many. Create them carefully, give each a job and always delete them when finished.
Example
when green flag clicked
forever
wait (1) seconds
create clone of [myself v]
end
when I start as a clone
go to x: (pick random -200 to 200) y: (180)
repeat until <(y position) < (-170)>
change y by (-4)
end
delete this clone
Exercises
1. Every second, create a clone of the object.
2. Send each clone to a random x position at the top.
3. Move it down until it leaves the stage.
4. Delete the clone at the bottom.
Expected Output
A new object falls from a random position every second and disappears at the bottom.
Lesson Nav
Scratch Course
0/9 lessons completed
- 1 Your First Scratch Project Concept
- 2 Motion and Looks Blocks Tutorial
- 3 Events and Repeat Loops Tutorial
- 4 Your First Scratch Game Project
- 5 Variables and Keeping Score Tutorial
- 6 Making Decisions with Conditions Tutorial
- 7 Sensing, Input and Operators Tutorial
- 8 Clones, Timers and Levels Tutorial
- 9 Project: Build a Story Game Project