Book Image

Scratch Cookbook

By : Brandon Milonovich
Book Image

Scratch Cookbook

By: Brandon Milonovich

Overview of this book

Scratch 2.0 is an easy to use programming language that allows you to animate stories and create interactive games. Scratch also gives you the capability of using programming to calculate complicated calculations for you. Scratch Cookbook will lead you through easy-to-follow recipes that give you everything you need to become a more advanced programmer. Scratch Cookbook will take you through the essential features of Scratch. You'll then work through simple recipes to gain an understanding of the more advanced features of Scratch. You will learn how to create animations using Scratch. Sensory board integration (getting input from the outside environment) will also be covered, along with using Scratch to solve complicated and tedious calculations for you. You'll also learn how to work through the exciting process of project remixing where you build on the work of others. Scratch Cookbook will give you everything you need to get started with building your own programs in Scratch that involve sounds, animations, and user interaction.
Table of Contents (17 chapters)
Scratch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Objects disappearing


When we play the game we have created so far, we may want more to happen when the red bar hits a ball. Let's follow this recipe to make the ball disappear from the stage.

Getting ready

Continue with the game we've been making all along in this chapter. There isn't much we need to prepare, as long as you've been following the recipes up until now.

How to do it...

Apply the following to each bouncing ball sprite:

  1. Under the Looks category, find the hide block. Drag this to our script that controls bouncing off of the red bar.

  2. Under any of the green flag top hat blocks, drop a show block from the Looks category between the top hat block and the loop.

How it works...

By adding these two simple blocks we can make it so that each time the game starts, all of the bouncing balls are brought back on the stage. As soon as they touch the red bar, they will disappear for the remainder of the game.

You might notice, though, that the score will keep increasing. This is because those bouncing...