Skip to content

Please update your browser

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

4. Input Emotion


In this video, you’ll add another input that will change the emotion the sprite is feeling!

Right click the “define speak” block, and select “edit.”

The costume name is also a string, so add another string input.

Call it “emotion.”

Click OK.

Another box appears at the right end of each of the “speak” blocks.

This is where you enter the “emotion” that will show at the end of the “sentence.”

To program the sprite to switch to the costume that reflects the right emotion for your conversation, type in the exact name of a costume.

The starter project contains a note listing the costume names, or you can see them by clicking the costumes tab.

Each emotion displayed will reflect the tone of the dialogue Malik says.

You’ll choose the emotions that most closely match the lines of dialogue in your project.

Next, update the “speak” block’s definition, so it can change the “emotion” costumes as well as what the sprite says.

Drag the “emotion” parameter from the definition into the “switch costume” block, where it shows the sprite’s emotion.

Click the flag to test the code.

The sprite moves its mouth while it says the first line, switches to “happy,” then says the second line and switches to “disgusted.”

But, the sprite switches costumes so quickly, it is hard to see them.

Place a "wait" block after the first "speak" block.

Click the flag to test whether you can see each of the reactions.

In this case, Malik smiles before looking disgusted.


Your project is already doing a lot of different things, and the code is still short and simple thanks to functions.

Right now, only Malik talks, so this conversation is pretty one-sided.

Program the other sprite, Isabel, to talk and turn the animation into a dialogue!

Most of the programming you will use to make Isabel talk is the same you used to make Malik talk, so copy the three code stacks from the “Malik talk” sprite into the “Isabel talk” sprite.

Click the "Isabel talk" sprite, then right-click the scripts area.

Select "clean up" to automatically order the code stacks.

Change the code slightly for the “Isabel talk” sprite to make the conversation work correctly.

For example, the “speak” function in “Isabel talk” should not make Malik’s mouth move by broadcasting “Malik talking.”

Name the “broadcast” block something that makes sense, like “Isabel talking.”

Next, click the dropdown on the “when I receive," block, and select “Isabel talking.”

Finally, change what Isabel says and what emotions are shown in the “speak” blocks.

In this example, Isabel first says “Peanut butter and jelly sandwiches!” with a happy face.

Then, “Why don’t you like them?”, with a sad face.

Click the flag to test the code.

Oh no!

Isabel and Malik talk at the same time!

You’ll fix this in the next video.

Now, it’s your turn!

Add a string input called “emotion.”

Update the “speak” blocks to input an emotion.

Copy the three block stacks from “Malik Talk” to “Isabel Talk.”

Change the values in the broadcast for "Isabel Talk."

arrow_backward Back
Next arrow_forward
  1. Add a string input called "emotion."
  2. Update the "speak" blocks to input an emotion.
  3. Copy the three block stacks from "Malik Talk" to "Isabel Talk.
  4. Change the values in the broadcast for "Isabel Talk."