Book Image

Scratch Cookbook

By : Brandon Milonovich
Book Image

Scratch Cookbook

By: Brandon Milonovich

Overview of this book

Scratch 2.0 is an easy to use programming language that allows you to animate stories and create interactive games. Scratch also gives you the capability of using programming to calculate complicated calculations for you. Scratch Cookbook will lead you through easy-to-follow recipes that give you everything you need to become a more advanced programmer. Scratch Cookbook will take you through the essential features of Scratch. You'll then work through simple recipes to gain an understanding of the more advanced features of Scratch. You will learn how to create animations using Scratch. Sensory board integration (getting input from the outside environment) will also be covered, along with using Scratch to solve complicated and tedious calculations for you. You'll also learn how to work through the exciting process of project remixing where you build on the work of others. Scratch Cookbook will give you everything you need to get started with building your own programs in Scratch that involve sounds, animations, and user interaction.
Table of Contents (17 chapters)
Scratch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Changing the stage background


Once you've been programming in Scratch for a while, there is a good chance that you may need to change the background to something other than the default white color. Fortunately, Scratch makes this easy to do!

Getting ready

The area directly underneath the stage is where we select the sprite we are currently going to work on the programming for. You'll also notice that on the left side is an icon with a picture of the stage background (currently white if you haven't been straying from this chapter). This icon is labeled stage. Click on this.

If you've done anything in the script area with the sprite you had selected, you'll notice it is no longer visible in the script area. Whatever you do, don't worry. You have a different script area for each sprite as well as the stage.

Note

You might be wondering what we are going to do with the script area for the stage. We won't use this for a while until we get into more advanced programs, but the stage script area is great for programming actions that will occur in the background of your program. Sometimes you may not have a block of programming that isn't specific to a particular sprite. This is where you will put that block.

How to do it…

So let's get rid of that boring background! Follow along with these steps!

  1. In the stage script area, click on the second tab towards the top labelled Backdrops. You can import several backgrounds that you may later on want to access through programming blocks in your block palette. For now, let's just import a new one and delete the white background.

  2. Similar to how we imported new sprites in three different ways; you have towards the top of the Backdrops tab three different options for backgrounds. The second of these brings up the paint editor. If you didn't take the time to get used to the paint editor when making your own sprite this may be a great time to create a background. You can add any colors you want, shapes, or imported images.

    Tip

    Don't import a sprite when creating your own background. If you do, be careful. You may later on try to drag the sprite, thinking it's an actual sprite in your program. This will leave you confused (and possibly frustrated) when you can't get something to work.

  3. If you didn't go down the route of creating your own background, then you can choose the very common import button. Just like the sprite library, you have categories. The categories for your pre-made backgrounds are indoors, nature, outdoors, and sports. You also have an x-y grid you can use if you are getting into some fun with math.

    Tip

    Not happy with the backgrounds available? Don't want to make your own? The dialog box that comes up just points to the folder on your computer where Scratch has put these pre-made designs when it was installed. You can access your pictures on other parts of your computer just as you would in any other software package on your computer.

  4. The third option is to upload an image directly from your computer.

  5. The fourth option you have is to access your computer's webcam and take a picture. Clicking on the camera option will pop up the webcam of your computer. Click on the picture of the camera and you should see your webcam's image pop into the background!

  6. Once you've selected your new background, you'll see it added to the list of backgrounds available to program with. It should look something similar to the following screenshot:

There's more…

To delete the white background we won't need, click the small circle containing an x.

Note

Notice that you can edit or copy backgrounds. This gives you the functionality to customize backgrounds and make them your own. Also, notice that you can change the given name of a background (the default seen in the preceding screenshot is background1). As you build more complicated programs, it may be beneficial to give these names you'll recognize throughout the program. You might find it useful to do the same thing with your sprites; we'll bring this up again later though.

Now that you have a new sprite and a new background, we are ready to create our first program. We may not have a fancy game yet, but it's enough to get us acquainted with Scratch and ready for our next steps.

See also

  • The Hello World project recipe in this chapter.