Skip to content

Please update your browser

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

4. Changer l'apparence

Transcript

In this video, you'll learn how to use the "next costume" block to change the appearance of the sprite. A sprite, in this case your model, can have more than one appearance. These different appearances are called costumes. Changing a sprite’s costume can change its appearance slightly, or so much that it looks like an entirely different character or object. Select the sprite in your project, and click the costumes tab. You'll see that this starter project already includes four different costumes.

If you click on each of the costumes, the sprite on the stage changes into an entirely different character. If you run the code while on the costumes tab, you can switch from one costume to the next to change the character when the sprite moves on and off the screen. You can also switch costumes using a code block. Click the looks menu, then select the "next costume" block. Every time this block is clicked, the sprite changes its look. Drag the "next costume" block into the forever loop to make the sprite switch costumes before it comes on stage. You can see that the order of the blocks matters. If the "next costume" block is placed after the "glide 1 second” block, the sprite will change costumes *after* gliding onto the stage, which makes the project look more like a magic show than a fashion walk! If the "next costume" block comes *before* the “glide” block, the sprite appears to step onto the stage with its new costume already in place. Put the "next costume" block as the first item inside the forever loop, and the sprite will always switch costumes before moving onto the stage. Code blocks are run in order from the top down, and the order of the blocks can affect the behavior of your program. You're almost done. The sprites are running on and off the stage, but in most runway shows, the model stops on stage and poses for a moment.

From the control menu, choose a "wait 1 second" block to make the sprite pause on the stage.

In Scratch, you can edit the numbers in the spaces in certain types of blocks to change what happens in your project. These are called “values.” For example, changing the value in the “glide” block makes the sprite move faster or slower. Try changing the value in the “wait” block to make the sprite pause for a longer or shorter amount of time.

Experiment with different values in these fields until you find a behavior and speed that you like. Don’t worry if you tested a solution, and it didn’t work. That happens all the time in computer science! Keep coding, testing, and trying solutions until you find one that works.

Lastly, add a "when flag clicked" block from the events menu to the top of your code stack.

Now the code will start running whenever the green flag is clicked. Plus, this starter project had some extra code to start you off....see what happens when you click the green flag.

Try clicking on the sprite as it walks across the stage, and find out what happens.

Make your CS First experience more social and fun by sharing what you created today with the Scratch community. Before you go, hit the “share” button and write a description of your project so others on Scratch can enjoy it.

Now, it's your turn.

Add “next costume,” “wait,” and “when green flag clicked” blocks.

When you are done, come back to this tab and click the green “next” arrow to move on to the add-ons page, where you can choose different ways to customize your project.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Change le costume du lutin chaque fois qu'il réapparaît sur scène.
  2. Fais en sorte que le lutin s'arrête momentanément sur scène.