Skip to content

Please update your browser

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

arrow_back Boîte mystérieuse (Part 1 of 2)

Transcript

In this two-part add-on, you’ll program the character to react to something inside a box. Click the “box” sprite, and look inside the “costumes” tab. This sprite has a costume that looks like a closed box, a costume that looks like an open box, and a bunch of costumes for what could be inside the box.

In this video, you’ll only use the “open” and “closed” box costumes. To animate the box opening, add code to make this sprite change costumes from the closed box to the open box. Click the “scripts” tab. Open the “looks” menu, and drag out a “switch costume” block. Select the “closed box” costume from the dropdown menu. Click this block to test it. Nothing seems to happen because the sprite is hidden. Snap a “show” block under the “switch costume” block, and test again. Great! A closed box shows up. Move the box to where you’d like it to appear on the screen-- this example puts the box in the lower left corner.

Next, animate the box to open. Add another “switch costume” block to the end of the stack. Choose the “opened box” costume from the dropdown menu. Click the new block to test. Hmm.. now the box is open when the program starts! That’s because the costumes are switching so fast that you never see the closed box. To fix this, open the “control” menu, and add a “wait” block before the second “switch costume” block. Click the flag to test. Great! Now the box stays closed for a second, then opens. Tinker with the value in the “wait” block to control how long the program waits until the box opens.

Next, make the character react to the box opening. To do this, broadcast a message to the character sprite telling it how to react. Open the “events” menu, and add a “broadcast” block. Choose a reaction from the dropdown menu. In this example, the character will dance in excitement, but you can use any reaction that fits the personality of your character.

Click the stack to test it out. Great! When the box opens, the character reacts.

Next, make this animation part of your story. Click the “narrator” sprite. Add some dialogue using a “say” block to set up opening the box.

Then, add either a “broadcast” block or a “broadcast and wait” block. A “broadcast and wait” block tells the program to wait until the box animation finishes before running any other code. The “broadcast” block keeps the code running while the box opens. This example uses a “broadcast” block.

Open the dropdown menu, and click “new message.” Type a message that describes the box animation, like “open box,” then click “OK.”

Then, click the “box” sprite, and add a “when I receive” block on top of the stack you programmed. Select your new message from the dropdown menu.

Click the flag to test out the story.

The narrator talks, and the box animation appears.

Great! Now, it’s your turn!

Animate the box to open using “show,” “switch costume,” and “wait” blocks.

Program the character to react using a “broadcast” block.

Hide the box at the end of the animation using a “hide” block.

Make the box animation part of the story by adding some dialogue and a “broadcast” or “broadcast and wait” block to the narrator sprite, and a “when I receive” block to the box sprite.

In part 2 of this add-on, you’ll program objects to come out of the box!

Choisir une extension
Changement de décor
Dans cette extension, tu vas changer le décor de ton histoire.
Boîte mystérieuse (Part 1 of 2)
Anime l'apparition d'une boîte mystère !
Boîte mystérieuse (Part 2 of 2)
Anime l'apparition d'une boîte mystère !
Animer le narrateur (Part 1 of 2)
Anime le narrateur pour qu’il parle !
Animer le narrateur (Part 2 of 2)
Anime le narrateur pour qu’il parle !
Jouer une chanson
Cette extension va te montrer comment utiliser Scratch pour créer ta propre chanson.
Ajouter un autre lutin
Dans cette extension, tu vas Ajouter un autre lutin à ton histoire pour la pimenter !
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Choisis une extension, et clique sur "Regarder" pour découvrir comment la créer.
  2. Une fois que tu as terminé une extension, essayes-en une autre !