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 learn how to add
action to your commercial.
Using a broadcast block.
Most commercials have more
than one character or object in them.
So add another Sprite to your project,
this example I'll use the laptop but you should
use whatever works for your product.
You also need a queue that tells a second character
in the commercial that it's time to appear or speak.
In scratch a broadcast block sends a message between
sprites or between the sprite and the background.
Use a broadcast block to queue the second character
in the commercial that it's time for action.
In this example, when the text
changes the second time the laptop appears.
Your code may not look exactly like this example code
so you should add the broadcast block
wherever makes sense for your commercial.
To tell the new sprite when to appear,
First, click on the sprite that will send the message.
From the events menu, drive out a broadcast block
and place it in your code stack at the point
where the second sprite should say or do something.
In this example, the text changes twice
then broadcasts a message
to the other sprites in the project.
The sprites receive this message,
they can start performing an action.
Name the message something that makes sense,
this example calls the message, laptop.
Since it queues the laptop to the show,
but you should call the message something
that refers to your Sprite.
Click OK, try that out.
The broadcast message ran but nothing
happened in the project because there
is no code instructing any sprite
to receive the message.
Click on the second sprite for your commercial,
that should receive the broadcasted message.
From the Events menu, add a When I receive block
and set the message to the one you just created.
Add code blocks that tell the sprite
what to do when it receives a message.
This example makes the laptop start on one
side of the screen,
show, then glide across the screen.
But you can add go to make
your sprite do anything you want.
You can make it spin using turn blocks,
make it play a sound,
or even flash different colors.
Do whatever you'd like best
for your product and your commercial.
In computer science it often takes more than one
try to try and find the right solution.
Keep coding, testing and trying solutions
until you find the one that works.
Click the green flag to test the code you just built.
In this example, the text switches to the first costume,
then the second costume,
then the broadcast message is sent.
The laptop sprite receives the broadcast message
and glides across the screen.
In this example, the laptop shouldn't show
at the beginning of the commercial.
But adding a hide block will take
care of that when the flag is clicked.
Remember, your code won't look
exactly like this example code.
Now it's your turn.
Add another sprite to your project,
then use a broadcast block to tell the new sprite
when it's time to appear and perform an action.
Add a When I Receive block and code an action
for the new sprite to perform.
Use the broadcast block to queue other sprites
when it's their time to appear.
Sign in to track your progress and earn badges