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 – keeping a global scoreboard


Currently, there are two conditions in our script that signify the end of the game. The first is when the player clears the level. The second is when the player's lives become zero. Because we have some duplication, we'll use a custom block to set the score. The steps are as follows:

  1. With the ball sprite selected, select the More Blocks palette and click on the Make a block button to create a block named update scoreboard.

  2. Add the scoreboard block to the when I receive (level clear) block.

  3. Add the scoreboard block before the stop (all) script in the if ((lives) = (0)) then block.

  4. We need to add a new cloud variable to use in the define update scoreboard block. From the Data palette, click on the Make a variable button. Name the variable scoreboard and select the cloud variable (stored on the server) checkbox.

  5. When you click on OK to create the project's first cloud variable, you will get an information box that tells you the cloud variables can only...