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 – adding the left and right arrow controls


Moving the paddle with the mouse works, but users on a laptop may find their built-in mouse difficult to use. Let's revise the paddle script to use the left and right arrows to control movement by following the given steps:

  1. Select the paddle sprite from the sprite list.

  2. From the Control palette, add the when key pressed block to the scripts area.

  3. Change the value to left arrow.

  4. From the Motion palette, attach the move () steps block to the when left arrow key pressed block.

  5. Change the value to -10 (negative 10).

  6. Repeat steps 4 and 5, but use the right arrow key to move 10 steps.

  7. Play the game, and use the arrow keys to move the paddle. The paddle appears to move slowly across the screen.

  8. Let's try to take bigger steps. Change the number of steps to a larger number, such as 50.

  9. Clean up the script by removing the original when flag clicked block that used the mouse x value to control the movement. From the Motion palette, uncheck the x position...