Cloning Sprites

Example Game

Demonstration of Space Invaders

Discussion

Think about how we create all the “invaders”?

  • Answer with current knowledge: make one invader sprite, and copy it many times while adjusting the copies as necessary.

What might go wrong or be bad about this approach?

  • If anything in an invader changes, it will need to be changed many times.

  • Lots of sprites clogging up the program that are all basically doing the same thing.

Introduction to Cloning

Cloning is the automated way of doing the manual copying

You can create a clone using:

Create a Clone of Block

  • From the dropdown, you can choose to make a clone of either "myself" or any other sprite.

  • Note that clones inherit all aspects of the "master" or "prototype" sprite, including scripts.

  • All clones are temporary. When the program stops running, clones will be deleted.

    • You can differentiate between the original sprite and its clones using:

      This block will report true for a clone, false if it is the original.

It is important to use the When I start as a clone block to ensure clones don't duplicate out of control.

When I start as a clone Block

Activity

Complete the Lots of balls lab (next page).

  • This lab will be repeating much of what was in the lesson. This is intentional.

  • Students should focus on ensuring they are differentiating between "master" sprites and "clone" sprites, and that the stage is serving as the main "driver" for the program.

Last updated

Was this helpful?