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 Die Figuren reagieren lassen

Transcript

In this add-on, you'll program a sprite to play a sound and cheer when it is clicked.

You'll also program the other sprites to react positively or negatively when that sprite is selected. To get started, select the sprite that you want to cheer when it is clicked.

Next, select the Sounds tab, and click "choose sound from library."

To preview the sounds, click the play icons.

Once you find a sound that you like, click on it, then click "OK."

To make the music play in your project, you need to add blocks that tell the program when to play the sound. Click on the scripts tab, then open the “sounds” menu. Drag out the "play sound" block, and snap it to the bottom of the "when this sprite is clicked" code stack.

Now, each time the sprite is clicked, its vote counter will increase by one and it will make the sound you picked.

To make the sprite cheer when clicked, add a "say" block to the bottom of the code stack.

Change the message in the space on the "say" block to something cheerful. In this example, the sprite says, "Yay!" when clicked.

To make sprites respond when another sprite is picked, the sprite that was chosen must send a message that it was picked.

To do this, select the events menu, and drag out a “broadcast” block. Click the dropdown menu, then select “new message.” Name the message something that makes sense to you.

In this example, the message is called "React." Place the “broadcast” block under the "when this sprite is clicked" block. Now, when the sprite is clicked, it will send out the message "React" to any other sprite that is waiting to hear that message. Next, you need to program the other sprites to receive the broadcasted message.

Click on a different sprite. Drag out the "when I receive" block. Make sure the message “React,” or the message name you chose, is selected in the dropdown menu. Now, when this sprite receives the "React" message, the sprite will run any code below the block Add a "say" block under the "when I receive" block. Make the sprite say something in reaction to another sprite being picked. The sprite might get jealous and say something like, "Boo!" Or, the sprite may be encouraging, and say something like, "Good for you!"

To make the other two sprites also react, drag the "when I receive" code stack to each of them. This will copy the code from one sprite to another.

Feel free to modify the text in the "say" block for each sprite to make each react differently.

Erweiterung auswählen
Die Figur herumwirbeln lassen
Programmiere eine Figur so, dass sie sich dreht und die Farbe wechselt, wenn ein Nutzer darauf klickt.
Die Figuren reagieren lassen
Die Figuren so programmieren, dass die reagieren, wenn eine andere Figur ausgewählt wird.
Die Figur verkleinern
Eine der Figuren kleiner werden lassen, wenn sie die Maus berührt.
Die Abstimmung geheim halten (Herausforderung)
Programmieren, dass die Stimmen für jede Figur geheim gezählt werden.
Zur Wahl auffordern (Herausforderung)
Programmieren, dass eine Figur darum bittet, ausgewählt zu werden, wenn sie den Mauszeiger berührt.
Das gewisse Etwas programmieren (Herausforderung)
Programmieren, dass eine Sonnenbrille von oben auf deine Figur hinuntergleitet.
arrow_backward Zurück
Weiter arrow_forward
Anweisungen
  1. Wählt eine Erweiterung aus und klickt auf „Ansehen“, um zu erfahren, wie ihr euer Projekt individuell gestalten könnt.
  2. Wenn ihr fertig seid, kehrt zur Seite mit den Erweiterungen zurück und probiert eine andere Erweiterung aus!