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 – setting the cat in motion, forever


So far, the cat has moved incrementally across the screen each time we clicked the green flag. Now, we're going to introduce the idea that the cat can stay in motion forever.

  1. We want to wrap the stack of blocks in a forever block. To do this, click on the move (10) steps block in the script and detach it from the when flag clicked.

  2. Now, from the Control palette, snap the forever block onto the when flag clicked block. Grab the stack of blocks you detached and drag it to the center of the forever block. Your script should look like the following screenshot:

  3. Run the script and watch the cat disappear from the stage.

  4. Let's get the runaway cat back. From the Motion palette, add the if on edge, bounce block to the bottom of the forever block. Now, watch the cat reappear upside down and bounce around the bottom-right corner of the stage.

  5. To stop the cat, click once on the script or click on the stop sign above the stage.

The following screenshot shows...