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 2 of 2)

Transcript

In this video, you’ll animate objects to fly out of the box.

Click the “box” sprite. Hide the box sprite at the end of the animation using a “hide” block from the “looks” menu. To create the objects that fly out of the box, make a clone of the sprite, and switch its costume to an object.

Open the “control” menu, and add a “create clone of myself” block right before the “hide” block. Then, add a “when I start as a clone” block. Open the “looks” menu, and add a “switch costume” block. Select the object you want to appear from the dropdown menu. This example uses the “cupcake” costume.

Use a “wait” block to slow down the animation.

Click the “when I receive” block stack to test this code so far.

Cool! An object comes out of the box. Click the stop sign to clear the clone from the stage.

Next, make the object glide away from the box. From the “motion” menu, add a “glide” block. To make the object glide to a random spot, add “pick random” blocks from the “operators” menu to both blanks in the “glide” block. Type “negative 240” and “240” into the x values and “negative 180” and “180” in the y values to make the object glide to a random spot anywhere on the stage.

Click the stack a few times to test it out. Cool! The cupcake goes to a different spot every time. To make many objects fly out of the box at once, put a “repeat” block around the “create clone” block. Change the value in the “repeat” block to the number of clones that should appear. This example uses 50. Click the stop sign to clear the stage, then click the block stack to test this out.

Whoah! Awesome! Add a “delete this clone” block after the “glide” block, so the objects don’t stay on the stage forever. Click the stop sign, then the “when I receive” block stack to make sure this works.

This effect looks great so far, but there are still some small tweaks that would make it look even better. Computer scientists like you always look for ways to improve their programs.

First, the objects appear behind the box. To make the objects appear in front of the box, add a “go to front” block from the “looks” menu right after the “when I start as a clone” block. Test this out.

Cool! The objects also disappear a bit too fast. Add a “wait” block before the “delete this clone” block to make them stick around for a little longer. Test this out.

That’s a neat effect. Lastly, the objects fly all over the stage.

It may look better if the objects only glide towards the bottom of the stage. Change the “180” in the “pick random” block to a smaller number, like negative 60.

Test this out by clicking the flag.

Great! Now the objects only appear at the bottom of the stage.

Feel free to make even more tweaks to customize your box. Remember to test often!

Now, it’s your turn! Make an object fly out of the box using the “create clone,” “when I start as a clone,” and “switch costume” blocks.

Make many objects fly all over the stage using “glide,” “pick random,” and “repeat” blocks.

Delete the clones after they animate using a “delete this clone” block.

Improve the look of the animation by adding a “go to front” and “wait” block, and by tinkering with the values in the “pick random” blocks.

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
Anweisungen
  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!