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 – using mouse location to hide arrows


This exercise will add a little bit of glitz to our project, but there's also a functional reason behind our wanting to build this interface. The arrows obstruct a part of our backdrop. Hiding the arrows shows more of the backdrop.

  1. To determine when we show or hide the arrows, we need to continually check the position of the mouse. Let's start building the script to do this on the Next arrow sprite. Start the script with the when flag clicked block. Attach a forever block.

  2. Inside the forever block, add the if () then, else block from the Control palette.

  3. The if () then, else block checks to see if a condition is true. To determine when to show the arrows, we're going to check the x and y position of the mouse. We'll start by adding the () and () block from the Operators palette to the value of if () then, else to accommodate a check for both x and y positions.

  4. In the left value of the () and () block, add the is greater than (>) block...