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 – ricocheting off bricks


Right now, the ball bounces off the edge and ricochets off the paddle, but it continues passing through the bricks. We're going to change that behavior by making the ball bounce off the bricks. Let's follow the given steps:

  1. Select the yellow brick sprite. Add a broadcast () block to the script that checks if the brick touches the ball, and create a new message called bounce. See the following screenshot:

    Tip

    Troubleshoot with the say block

    If you're having problems with a script or you want to be sure a certain part of the script is working, you can add a say () block, as seen in the previous screenshot. When the condition is met, a quick Hello! appears on the screen.

  2. Select the ball sprite, and add the when I receive block to the scripts area.

  3. Attach a point in direction () block.

  4. We're going to do a calculation inside the point in direction () block to redirect the ball back to the paddle. Add a multiplication (*) block from the Operators palette. Then...