Clones

Use clones to multiply a sprite into items like bullets, enemies or stars.

LESSON COMPASS

What will you use this page for?

Core idea

A clone is a temporary copy of a sprite made while the project is running, so we can produce dozens of bullets, stars or enemies from a single sprite.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Forgetting to hide the original sprite In the bullet example, if you don't hide the original sprite with hide , you will see an extra bullet frozen at the starting point. Hide the original sprite and show only the clones. Forgetting to delete the clone If you leave out the delete this clone block, bullets pile up at…

Next connection

Simple Physics: Speed, Gravity and Collision

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration30–45 min
PrerequisiteBroadcasting Messages
ContentStandard lesson · 1,540 words
Last updated

One-sentence summary

A clone is a temporary copy of a sprite made while the project is running, so we can produce dozens of bullets, stars or enemies from a single sprite.

Why does it matter?

Imagine a space game. Your spaceship fires a bullet every time you press a key. But how do you make those bullets? Do you draw a separate sprite for each one? There might be ten bullets on the screen at once, or twenty. Drawing them all by hand takes a long time and becomes hard to manage.

This is where clones come in. With clones you draw a single "bullet" sprite, then produce copies of it while the project runs. Each copy moves on its own. This method is used for star showers, swarms of enemies, falling snow and many other scenes.

By the end of this lesson you will be able to:

What is a clone?

A clone is a temporary copy of a sprite, created while the project is running. The original sprite stays on the stage; the clones multiply from it and carry out their own tasks.

Think of it like this: the original sprite is a cookie cutter. From that cutter you press out as many cookies (clones) as you like. Every cookie has the same shape, but each one sits separately on the plate.

When we work with clones we use three blocks from the Control category:

Why delete a clone?

Every clone takes up space and memory on the screen. If hundreds of clones pile up, Scratch slows down. So once a clone finishes its job (for example, a bullet reaches the top of the screen), we clean it up with delete this clone. Deleting clones keeps the game fast and tidy.

How do you create a clone?

To make a clone, we first give the original sprite a start, then call the create clone of ... block.

Example 1: A single star clone

Say you have a star sprite. When the green flag is clicked, let's create one clone.

when green flag clicked
create clone of myself

This code runs once and produces a single clone. Together with the original star, there are now two stars on the stage: one is the original sprite, one is the clone.

Example 2: Telling a clone what to do when it is created

Creating a clone is not enough; we have to give it a task. For that we use the when I start as a clone header. Everything we write under this header runs separately for each newly born clone.

when I start as a clone
go to x: pick random -200 to 200, y: pick random -150 to 150
show

Now every new clone jumps to a random point and becomes visible. The original sprite and the clone do separate jobs: the original starts with when green flag clicked, while the clone starts with when I start as a clone.

Bullet example: Press a key, spawn a clone, send it up

Now let's build the main example of the lesson. Our goal: when the space key is pressed, spawn a bullet clone, send the bullet upward, and delete it when it reaches the top of the screen.

Step 1: The original sprite's code

We draw the bullet sprite and hide it first. The original sprite is invisible; only the clones will be shown. Each time the space key is pressed, a clone is created.

when green flag clicked
hide

when space key pressed
create clone of myself

Here the hide block is from the Looks category, and when space key pressed is from the Events category.

Step 2: The clone's code

When each bullet clone is born, it should start from the player's position (the spaceship), show itself and move upward. When it reaches the top, it should delete itself.

when I start as a clone
go to Spaceship
show
repeat until <touching edge?>
  change y by 10
delete this clone

Let's read this code together:

Now, every time you press the space key, new bullets are produced, each one drifts upward on its own, and disappears when it reaches the top. From a single sprite we created a shower of bullets.

Limiting the number of bullets with a variable

If you like, you can add a variable to count how many bullets are on the screen at once. For example, create a variable called bullets, add 1 each time a clone is made, and subtract 1 each time one is deleted. This helps later when you want to set a bullet limit.

Mini practice: a controlled clone shower

Create a star sprite that releases a clone when the space key is pressed. Give each clone a random horizontal position near the top of the stage, move it downward in small steps and delete it when it reaches the lower edge. Add a counter so that no more than eight stars can exist at the same time.

  1. Test one quick key press and record how many clones appear.
  2. Hold the key down and check whether the limit still works.
  3. Change the falling speed for one clone and observe whether deletion remains reliable.
  4. Explain why the original sprite must stay separate from the temporary copies.

Common mistakes

Forgetting to hide the original sprite

In the bullet example, if you don't hide the original sprite with hide, you will see an extra bullet frozen at the starting point. Hide the original sprite and show only the clones.

Forgetting to delete the clone

If you leave out the delete this clone block, bullets pile up at the top of the screen. Once hundreds of clones gather, the project slows down. Every clone should have a "delete" condition.

Using the wrong header

Writing the clone's code under when green flag clicked instead of when I start as a clone is a common mistake. A clone's behaviour must go under the when I start as a clone header.

Skipping show inside the clone

If you hid the original sprite, the clones are born hidden too. If you don't say show in the clone's code, you will never see the bullet.

Safety note

This lesson is entirely on-screen; there is no physical risk. Even so, remember that coding can keep us in front of a screen for a long time. Take a short break roughly every 20 minutes, rest your eyes and stand up. When you share Scratch projects online, do not write your real name, school or address; your username and what you share can be public.

Lesson summary

Review questions

  1. What is a clone and why do we use it?
  2. Under which header do we write the code that runs the moment a clone is born?
  3. In the bullet example, why do we hide the original sprite with the hide block?
  4. What happens over time if we never delete clones?
  5. Which block and which loop did we use to move the bullet upward?

Answers

  1. A clone is a temporary copy of a sprite created while the project runs. We use it to produce dozens of bullets, stars or enemies from a single sprite.
  2. Under the when I start as a clone header. This header runs separately for every new clone.
  3. The original sprite exists only to produce clones; if it stays visible, it remains as an extra bullet at the starting point. That is why we hide it.
  4. Clones that are never deleted pile up on the screen and take up memory and space; once hundreds gather, Scratch slows down.
  5. We used the repeat until <touching edge?> loop, and inside it the change y by 10 block to move the bullet up each step.

Source and verification note

For “Clones”, verification focuses on whether the relationship between What is a clone? and How do you create a clone? remains consistent across examples. Block names are kept consistent with the current core Scratch categories. Project behaviour should be tested separately for start-up, normal play, errors and restarting.

Next lesson

Simple Physics: Speed, Gravity and Collision

Start QuizBack to Programming with Scratch
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.