Skip to content

Please update your browser

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

3. Cloner le lutin volant

Transcript

In this video, you'll learn how to create many sprites that fly across the screen.

In Scratch, you can create a copy of an object using the "create clone" block. The clone will have the same attributes and characteristics as the original object.

When you program the computer to create a clone, or copy, of a sprite, you can provide instructions, or code, for how the copy should look or function. Without instructions, clicking the "create clone of myself" block will make a clone of the sprite appear on the stage, but the clone will not fly or do any other actions the original sprite performs.

Use the "when I start as clone" event block to provide instructions that will make the new clone perform an action. Add the "when I start as clone" block, then drag your "go to" and "glide" block stack under this event. Now, whenever you click the "create clone" block, the clone receives instructions telling it to fly across the screen. Clicking "create clone" multiple times makes several clones fly across the screen.

To automate the cloning, drag the "create clone of myself" block into the forever block.

Whoa! That's a lot of clones trying to cross the screen at the same time. Add a "wait" block to the forever loop to slow down the clone creation. Adjust the value in the “wait” block until you like the clone creation pace. Great! You now have several clones zipping across your screen. But, they don’t disappear when they reach the right side of the screen.

To fix that, add a "delete this clone" block after the “glide” block. You might also want to drag your flying sprite to one side of the screen.

Computer scientists like you often need to test several solutions to a tough problem before they find the one that works. If your code isn't working correctly, keep trying different fixes until you solve the problem. Now, it's your turn: Add the event "when I start as clone," and place the code that makes your sprite fly under it. Add "create clone" and "wait" blocks to the forever loop. Add a "delete this clone" block to the bottom of the stack.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Crée un clone du lutin.
  2. Fais voler le clone du lutin dans la scène.
  3. Fais voler plusieurs lutins dans la scène.
  4. Ralentis l'opération de création de clones.
  5. Fais disparaître les clones une fois leur vol dans la scène terminé.