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. Créer une impression de mouvement


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 Retour
Suivant arrow_forward
  1. Donne à ton lutin une impression de mouvement à l'aide des blocs "Basculer sur costume" et "Répéter".
  2. Ralentis les changements de costume à l'aide d'un bloc "Attendre".
  3. Exécute le code lorsque l'utilisateur appuie sur une touche à l'aide d'un bloc "Quand touche cliquée".
  4. Copie le code aux autres lutins. Change l'événement clavier pour chaque athlète.
  5. Joue avec les valeurs dans les boucles "Répéter" et les blocs "Attendre".