In this video, you will make the athletes in your project look like they’re performing.
The example project will build off of the cheerleading starter project, but you’llbuild your project using the sport you chose. Click on the sprite you will animate, thenclick on the “costumes” tab. You’ll see pictures of the sprite in a fewdifferent poses. If you click through these costumes quickly, the sprite looks like it'smoving. Computers are useful because you can programthem to do tasks for you. To program the sprite to change costumes, go to the “looks”menu, and drag out the “next costume” block.
Click on it. The sprite changes costumes. Keep clicking on it to make the sprite looklike it’s animated. Pretty cool! Scratch also offers a block that will continueto change the costumes without you clicking it over and over. The “repeat” block makesactions repeat a number of times. From the “control” menu, drag out a “repeat”block, and place it around the ”next costume” block.
Click on the code to test it. Interesting – the costume changes many times, but itchanges very quickly. To slow down the costume changes, select a “wait” block from the“control” menu, and place it inside the “repeat” block.
Tinker with the values in the "repeat" loop and “wait” block until the animation looksgood to you. Next, add an event that will make the athleteperform. In computer science, events cause an action in a program. In this case, a userpressing a key is the event that makes the athlete perform.
Click on the “events” menu. Place a “when key pressed” event block on top of the stackthat makes the athlete perform. From the dropdown menu, select a key to useas an event. This example uses the "one" key. To test this code, press the key on your keyboard.
The athlete starts performing! Great! Next, code the rest of the athletes in yourproject to perform. The code for the other sprites will be very similar to the code youjust created. Copying code from one sprite to another is easier and faster than creatingnew code for each sprite. To copy the code, drag it over to the sprite in the spritesmenu. Then, change the keypress event. For this example, the second athlete performswhen the "two" key is pressed, and the third when the “three” key is pressed. Tinkerwith the number of repeats and the wait times for each sprite until you like their performances.
Here's the gameplan: First, make the sprite keep changing costumesusing the “repeat” loop and “change costume” block.
Slow down the costume changes using the “wait” block.
Make the code run when the user presses a key using the “when key pressed” block.
Copy the code to the other sprites, and change the keypress event for each athlete.
Finally, tinker with the values in the repeat loops and “wait” blocks.
When you're finished, come back to this page and click the "next" arrow to move on to thenext video, where you'll program the sports commentator.