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 – moving the dog based on x and y coordinates


In this exercise, we're going to use the x and y coordinates to move our dog:

  1. Let's prepare the stage by hiding the horse1 sprite by right-clicking on the thumbnail in the sprites list and choosing Hide. Then, display the bedroom1 backdrop on the stage.

  2. Next, add the dog2 sprite from the Animals category of Scratch's sprite library.

  3. Position the dog so that it's talking into the microphone. Resize the sprite as necessary.

  4. With the dog in position, let's find the x and y coordinates of the sprite so we can ensure the dog always returns to this position. Select the dog2 sprite in the sprite list and then click on the i icon on the sprite thumbnail to display the sprite properties pane as seen in the following screenshot:

  5. Now, we'll create the script that always returns the dog to the spot in front of the microphone. From the Motion palette, drag the set x to () block to the scripts area. Change the value to the dog's x value. My example...