Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

2. Show Off Your Moves

Transcript

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’ll build your project using the sport you chose. Click on the sprite you will animate, then click on the “costumes” tab. You’ll see pictures of the sprite in a few different poses. If you click through these costumes quickly, the sprite looks like it's moving. Computers are useful because you can program them 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 look like it’s animated. Pretty cool! Scratch also offers a block that will continue to change the costumes without you clicking it over and over. The “repeat” block makes actions 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 it changes 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 looks good to you. Next, add an event that will make the athlete perform. In computer science, events cause an action in a program. In this case, a user pressing 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 stack that makes the athlete perform. From the dropdown menu, select a key to use as 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 your project to perform. The code for the other sprites will be very similar to the code you just created. Copying code from one sprite to another is easier and faster than creating new code for each sprite. To copy the code, drag it over to the sprite in the sprites menu. Then, change the keypress event. For this example, the second athlete performs when the "two" key is pressed, and the third when the “three” key is pressed. Tinker with 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 costumes using 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 the next video, where you'll program the sports commentator.

arrow_backward Back
Next arrow_forward
Instructions
  1. Make the sprite look like it's performing using the "change costume" and "repeat" blocks.
  2. Slow down the costume changes using the "wait" block.
  3. Make the code run when the user presses a key using the "when key pressed" block.
  4. Copy the code to the other sprites. Change the keypress event for each athlete.
  5. Tinker with the values in the repeat loops and "wait" blocks.