One method to direct the timing of events in a coding project is to broadcast a message in Scratch. Broadcasting sends a message to one or more sprites. The message is used to trigger a script to run.
Scratch Coding Blocks to Broadcast a Message
Scratch is a coding app that introduces programming concepts to beginners. It uses blocks of instructions that are joined together to build scripts. Scratch has several coding blocks that can be used for broadcasting messages.
Send a message to sprites. | |
Send a message to sprites. Pause until all scripts triggered by the message have finished running. | |
Run a script when a broadcasted message is received. |
When Should You Broadcast a Message in Scratch?
Broadcasting controls WHEN something happens – it is all about TIMING!
To understand its use, compare broadcasting to other computer-related tasks. For instance when video editing, objects are sequenced into a track on a Timeline. Or when designing a graphic story in PowerPoint, events are timed using the Animation Pane.
Scratch does not have a Timeline or Animation Pane. Instead, instructions are sequenced using coding blocks. Broadcasting blocks are used to set the timing of events in an animated scene, game, or story.
What can you do with broadcasting?
- Hold a Conversation: Have sprites chat with one another in an animated scene or story. Broadcasting can prompt a character to answer a question. Or, cause a character to respond to something that was said.
- Respond to Events: Use broadcasting to make a sprite react to an event. For example, a character may move or change appearance when something happens.
- Produce Multiple Actions at the Same Time: Broadcasting can send a message to many sprites. This can cause several characters to do something at the same time. This enhances storytelling and holds viewer interest.
- Control Game Play: Direct when a game begins using broadcasting. After the instructions appear on the screen a broadcasted message can launch the game. Use it to make targets appear or start a timer.
- End a Game: Set what happens when a game is over. Use broadcasting to inform a player that the game has ended. For instance, you could display a message, such as GAME OVER. Broadcasting can also be used to stop game play. For example, you could hide targets to prevent the player from scoring more points.
- Organize Scripts: Long scripts in Scratch cannot display on one screen. This makes them difficult to debug. A solution is to divide the script into smaller chunks using broadcasting. (TechnoCode, a recent STEM project by TechnoKids for middle school grades, has an extension activity that explains how to organize scripts using broadcasting. )
Plan to Broadcast a Message in Scratch
When using broadcasting it is a good idea to PLAN AHEAD:
- Decide what you want to happen.
- Once you have an idea, pick the sprite that will send the message. Who is in control of when an action happens?
- Study the sprite’s script. To send the message at the right time, where should the broadcast coding block be placed?
- Next, pick the sprite or sprites that will receive the message. What will they do when they receive the message?
Broadcasting Video
Watch the video to understand how broadcasting can be used in graphic storytelling. If this is a coding project that you would like to make, TechnoCode has an animated storytelling coding unit. The instructions explain how to build scripts to illustrate events. The lessons also include a story organizer, checklist, coding journal log, Scratch quiz, and story rubric.
How to Broadcast a Message in Scratch
- Select the sprite that will send a message.
- From the Events palette, add the block broadcast message1.
- Click the arrow. Select New message.
- Type message name. Click OK.
- Place the broadcast block where you want to send the message. For example:
- Select the sprite that will receive the message.
- From the Events palette, add the block when I receive message1. Click the arrow. Select the message name from Step 4.
- Build a script that has the sprite do an action. For example:
TechnoCode and Broadcasting in Scratch
TechnoCode has many programming lessons for kids. One of the coding units teaches graphic storytelling. Detailed instructions explain how to use broadcasting to direct the timing of events. Another coding unit is about game design. Broadcasting is used by students to trigger the start and end of a game. Learn more about programming for kids.