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. Mosse da campione


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 Indietro
Avanti arrow_forward
  1. Fai muovere lo sprite usando i blocchi "Cambia costume" e "Ripeti".
  2. Rallenta il cambio dei costumi utilizzando il blocco "Attendi".
  3. Programma l'esecuzione del codice quando l'utente preme un tasto, usando il blocco "Quando si preme il tasto".
  4. Copia il codice sugli altri sprite. Cambia il tasto situazione degli altri atleti.
  5. Sperimenta con i valori dei loop "Ripeti" e dei blocchi "Attendi".