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 Eine Überraschungskiste programmieren (Part 1 of 2)


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!

Erweiterung auswählen
Die Kulisse verändern
Die Kulisse in eurer Geschichte verändern
Eine Überraschungskiste programmieren (Part 1 of 2)
Eine Überraschungskiste animieren
Eine Überraschungskiste programmieren (Part 2 of 2)
Eine Überraschungskiste animieren
Den Erzähler animieren (Part 1 of 2)
Den Erzähler so animieren, dass es aussieht, als würde er sprechen
Den Erzähler animieren (Part 2 of 2)
Den Erzähler so animieren, dass es aussieht, als würde er sprechen
Ein Lied spielen
Lernen, wie man mit Scratch ein eigenes Lied schreiben kann
Eine Figur hinzufügen
Mit dieser Erweiterung fügt ihr eine weitere Figur zu eurer Geschichte hinzu, damit sie noch spannender wird!
arrow_backward Zurück
Weiter arrow_forward
  1. Wählt eine der Erweiterungen aus und schaut euch das Video an, um zu sehen, wie sie programmiert wird.
  2. Wenn ihr mit einer Erweiterung fertig seid, probiert eine andere aus!