In this video, you’ll program the first sprite, Malik, to talk.
To start, click on the “Malik talk” sprite, then the costumes tab.
Notice that this sprite has 6 mouth costumes.
Click through them to see how they look.
Clicking between the “neutral” and “talk” costumes makes it look like the Malik sprite is talking.
Begin your animation by creating dialogue, or a conversation, between the two characters.
Think of some lines the sprites might say that would make them each feel emotions, like happy, sad, disgusted, or surprised.
To begin programming your conversation, click the scripts tab.
Make the “Malik talk” sprite say your first line of dialogue.
Select a “say” block, and type some words for Malik to say.
In this example, Malik says, “What do you want for lunch?”
Next, animate the sprite to look like it’s talking.
To do this, switch between the sprite’s “neutral” and “talk” costumes.
Place one “switch costume” block above the “say” block, and place another one below.
Switch the first costume to “talk” and the second one to “neutral.”
Click the block stack to try it out.
Malik says something, and the mouth moves at the same time.
separate the connected blocks.
Replace the "say" block with a "wait" block.
Change the value to 2 seconds.
Add a “when I receive” block on top of this block stack.
Click the dropdown, and select “new message.”
Name this message something like “Malik talking,” and click “OK.”
Whenever this block stack receives the message “Malik talking,” the mouth will animate.
To send the “Malik talking” message, drag a “broadcast Malik talking” block above the “say” block.
Click this stack to test it.
The mouth moves while Malik says the first line of dialogue.
Right now, Malik’s mouth only opens and closes once.
In the next step, make the mouth move continuously as the sprite speaks.
Add a "repeat" loop around the "switch costume" blocks.
Click the "broadcast Malik talking" block to test.
Notice that the talk costume displays for two seconds, then the costume changes to neutral for just a fraction of a second before it changes back.
To fix this, add another "wait" block after the “switch costume to neutral” block.
To speed up the mouth animation, update the values in the “wait” blocks.
Change the wait time to 0.1 seconds in each “wait” block, and change the value in the repeat loop to 8.
This stack of code takes a little less than 2 seconds to run, which is about the length of time the speech bubble displays.
Click the "broadcast Malik talking" code stack to test.
The sprite now says its line, and the mouth moves.
Program the sprite to show an emotion after it finishes talking.
Drag out a “switch costume” block, and place it under the “say” block.
From the dropdown, select a costume that shows the emotion the sprite is feeling.
This example uses the “happy” costume.
Finally, add a “when flag clicked” block to the top of this code stack, and click the flag to watch the first part of the animation.
Now, it’s your turn!
Write a line of dialogue, and animate the sprite’s mouth to move.
Broadcast a message that tells that code to run.
Choose a costume to show what emotion the sprite is feeling.
Add a “when flag clicked” block to the top of the stack.
- Write a line of dialogue, and animate the sprite's mouth to move.
- Broadcast a message that tells that code to run.
- Choose a costume to show what emotion the sprite is feeling.
- Add a "when flag clicked" block to the top of the stack.