2. Make Cassy Dance in One Spot
In this screencast, you’ll make Cassy dance in one spot on the screen. Watch first, as the screencast shows you the steps you’ll need to take. Then comes the fun part, when you get to try it for yourself. Some sprites in Scratch, like Cassy, have multiple costumes such as the ones shown here on the costumes tab. A “costume” is one of many possible appearances of a sprite. If you click on each of Cassy's costumes, her appearance changes so she looks like she is dancing.
You can also change Cassy's costume with code by clicking on the Scripts tab and choosing the looks menu. There, you will find many blocks that affect Cassy's appearance. Click any block to see what it does, or you can drag a block into the script editor to include it in your project. If you drag the "next costume" block into the script editor and click the code block, Cassy's costume changes, and she dances.
But you want Cassy to keep dancing, and your hand will get pretty tired if you have to keep clicking the “next costume” block. This is a great time to use the “forever” block. Click on the control menu, and choose the “forever” block. Drag the “forever” block into the script editor, and place it around the next costume block.
Now, click the block stack to test your code and see what happens. Cassy dances crazy fast! And she keeps right on dancing. Computers are great at following instructions quickly and repeating them forever. One of the best reasons to know a little computer science like this is that you can use it to make repeated tasks happen automatically. This is certainly a lot easier than clicking that “next costume” block forever yourself!
To change how fast Cassy dances, use a "wait” block, which you will also find under the control menu. Place the “wait” block inside the forever loop to create a pause, or wait, before the next costume change. If Cassyis moving too slowly, tinker with the value in the “wait” block to change the speed of the costume change until you find one that works. For example, adding a "wait 1 second" block into the forever loop makes Cassy wait 1 second between costume changes. You see? If that still seems a little slow, try changing the wait value to .1.. too fast.. maybe .2. That's better! When you do this on your own, try a few different values in the “wait” block and pick the one you like best. Now it's your turn to make Cassy dance. Use the “next costume” block and a “wait” block with any value inside it that you choose.
Remember to put a forever block around those blocks so they run over and over again forever when you click on them.
Once you’ve finished this step, return to this CS First page and click the green arrow to move on to the next screencast.