Please update your browser
Your browser version is not supported by this site. CS First may not work properly. Learn more.
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 six 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 a dialogue,
or a conversation, between the two characters.
Think of some lines that the sprites might say
that would make them each feel emotions,
like happy, sad, disgusted, or surprised.
To begin programming your conversation,
make the Mailk 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 two 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 the stack to test it out.
The mouth moves while Malik says the first line of dialogue.
Right now, Malik's mouth only opens and closes once.
In thee 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 top 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 two 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 the 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.
Sign in to track your progress and earn badges