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. Ready, Set, Action!

Transcript

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 will use the laptop, but you should use whatever works for your product.

You also need a “cue” that tells the 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 "cue" the second character in your commercial that it is 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, drag 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, and can start performing an action.

Name the message something that makes sense.

This example calls the message "laptop," since it cues the laptop to show, but you should call your 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 the message.

This example makes the laptop start on one side of the screen, show, then glide across the screen.

But, you can add code to make your sprite do anything you want.

You could make it spin using “turn” blocks, make it play a sound, or even flash different colors.

Do whatever you like best for your product and your commercial.

In computer science, it often takes more than one try to 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 click laptop sprite, the laptop sprite receives the broadcast message, and glides across the screen.

Aweosme!

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 is 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 “cue” other sprites when it is their time to appear.

If you need help, ask your neighbor, or put up your sticky to get a Guru's attention.

arrow_backward Back
Next arrow_forward
Instructions
  1. Add a new sprite to your project.
  2. Add a "when I receive" block to your new sprite, so it listens for the message to run the code.
  3. Add code to the "when I receive" block to make the sprite do something.
  4. To tell the sprite when to act, add a "broadcast" to another sprite's code stack.