Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scratch 1.4: Beginner's Guide

You're reading from   Scratch 1.4: Beginner's Guide Learn to program while creating interactive stories, games, and multimedia projects using Scratch

Arrow left icon
Product type Paperback
Published in Jul 2009
Publisher Packt
ISBN-13 9781847196767
Length 264 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Table of Contents (17) Chapters Close

Scratch 1.4 Beginner's Guide
Credits
About the Author
About the Reviewer
Preface
1. Welcome to Scratch! FREE CHAPTER 2. Installation 3. Start Scratching 4. Graphics and Slideshows 5. Storytelling 6. Arcade Games 7. Games of Fortune 8. Math and Finance 9. Share! 10. Real-world stimuli Scratch Resources
Index

Capture sound input


We're going to create a quick program that switches the background when a sound is made.

Time for action – switch backgrounds on sound

Let's emulate night and day with our backgrounds so that each sound changes the scene. Open a new Scratch project and begin:

  1. Create the second background by copying the default white background. Then, edit background2 and use the fill tool to paint it black.

  2. Add the when flag clicked control block to the scripts area of the stage.

  3. Add a forever if block to the when flag clicked block.

  4. We need to evaluate the sound level before we act on it. From the Operators palette, add the greater than block.

  5. Now, let's evaluate the sound. From the Sensing palette, drag the sensor value block into the first field of the greater than block. Select the sound option from the drop-down list of options.

  6. We want to switch the background whenever the sound is greater than 0. Type a 0 in the second field of the greater than block so that the statement reads sound sensor...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image