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 – limiting color values with a slider


Let's perform the following steps to limit color values via the slider:

  1. We have two color values to manipulate, so create two more variables with the names color and shade. Turn each new variable into a slider control on the stage.

  2. Let's limit the input that the user can enter. Right-click on the color slider, and select the option set slider min and max. This will open a Slider Range dialog box as shown in the following screenshot:

  3. In the Min and Max fields, enter 0 and 199 respectively. Click on OK to save the range.

  4. Test the slider control out, and verify that you cannot select a value higher than 199.

  5. Now incorporate the color and shade variables into the appropriate blocks in the script as shown in the following screenshot:

What just happened?

Now, every value in our shapes project can be set by the user via slider controls that are displayed on the stage. This exercise showed us that we can force the user to enter a range of values via...