arrow_back Shout it Out
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.