In this screencast, you’ll make Cassy dance in one spot on the screen. Watch first, asthe screencast shows you the steps you’ll need to take. Then comes the fun part, whenyou get to try it for yourself. Some sprites in Scratch, like Cassy, havemultiple costumes such as the ones shown here on the costumes tab. A “costume” is oneof 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 choosingthe looks menu. There, you will find many blocks that affect Cassy's appearance. Clickany block to see what it does, or you can drag a block intothe script editor to include it in your project. If you drag the "next costume" block intothe 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 tokeep 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 crazyfast! And she keeps right on dancing. Computers are great at following instructions quicklyand repeating them forever. One of the best reasons to know a little computer sciencelike this is that you can use it to make repeated tasks happen automatically. This is certainlya 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 thecontrol 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 inthe “wait” block to change the speed of the costume change until you find one thatworks. For example, adding a "wait 1 second" blockinto the forever loop makes Cassy wait 1 second between costume changes. You see? If thatstill seems a little slow, try changing the wait value to .1.. too fast.. maybe .2. That'sbetter! When you do this on your own, try a few different values in the “wait” blockand pick the one you like best. Now it's your turn to make Cassy dance. Usethe “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 foreverwhen you click on them.
Once you’ve finished this step, return to this CS First page and click the green arrowto move on to the next screencast.