Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – breaking bricks when I start as a clone


Cloning works in Scratch in two major steps. First, we need to duplicate the sprite. Second, we write the scripts that tell the clone what to do.

We created the clones in the previous exercise. Now, let's break the bricks by following the given steps:

  1. From the Control palette, add the when I start as a clone block from the Events palette to the scripts area of the yellow brick sprite to handle the cloned sprites.

  2. We'll need to continuously check if the ball and the clone touch so that we know when the brick is supposed to break.

  3. Start with a forever block, and then add the if () then block from the Control palette.

  4. Inside the if () then block, add the delete clone block from the Control palette, which will represent the breaking brick.

  5. From the Sensing palette, add the touching ()? block to the value of the if () then block, and select ball as the touching value.

The following screenshot shows the new script (on the right-hand side) and...