Learning Goals 3 min
By the end of this lesson you will be able to:
- Find broadcast (message1 v) in the Events palette and explain that it sends a named cue that every sprite can hear.
- Create a new broadcast name from the dropdown (e.g.
start race,game over) and use the same name everywhere it appears. - Build a tiny project where one sprite presses a button (broadcast) and a different sprite reacts to it — the start of every multi-sprite scene you'll ever build.
Warm-Up — the parade marshall 7 min
Imagine a school parade. Twenty students stand in a line. None of them moves. Then the marshall blows a single whistle. All twenty start marching at the same time — left foot, right foot, in perfect step.
Two questions:
- Did the marshall walk over and tap each student on the shoulder? No — that would take ages.
- Did the marshall shout instructions for every step? No — the marshall just sounded one whistle.
One whistle. Twenty reactions. The whistle is a cue — a signal that means something specific, that everyone is listening for, that triggers different actions in different students.
Today's lesson is Scratch's whistle. broadcast (start march v) sends a cue across the whole project. Any sprite (or backdrop) that has a when I receive (start march v) hat block will hear it and run its own script in response.
Reveal — what we'll fix today
Until now, every multi-sprite project has worked by giving each sprite its own when ⚑ clicked hat. That's fine for "everyone start at the flag", but useless for "everyone start after the bell rings" or "the cat presses a button and then the door opens". For those, you need cues — broadcasts.
New Concept — the broadcast cue 15 min
Until now, every sprite has been a soloist — its scripts run on their own, triggered by the flag or a key or a click on itself. Broadcasts are how sprites become a band: one sprite plays a note, and the others know to come in.
The broadcast block
Open the yellow Events palette. Three new blocks live there besides the hats you already know:
- broadcast (message1 v) — sends a cue. Fires off and continues.
- broadcast (message1 v) and wait — sends a cue, then pauses until every listener finishes (next lesson).
- when I receive (message1 v) — a hat block that fires when the named cue is heard (next-next lesson).
Today we focus on the first one, plus a tiny preview of the receiver hat so we have something to play with.
broadcast (start v)
Creating a new message name
Click the small ▾ inside the broadcast block. You get a tiny menu:
message1— the default. Boring.New message…— click this to type your own name.
Type a name that describes the event, not the action. game over is good. say hello and turn red is bad — that's an action, not an event. Good broadcast names: start race, door opens, player scored, level 2, say hi.
The name you type lives in the project's message list. Once you create start race, it appears in the dropdown for every broadcast block and every when-I-receive hat block, on every sprite. That shared list is how senders and receivers find each other.
The fire-and-forget model
A broadcast is fire-and-forget: the sender doesn't know — and doesn't care — who's listening. Maybe one sprite reacts. Maybe ten. Maybe none. The sender just sends.
This is wonderful for two reasons:
- You can add more listeners later without changing the sender's code. Today the door opens; tomorrow you add a backdrop change too — just put a second when I receive (door opens v) hat on the Stage. The sender doesn't change.
- You can remove listeners with no risk. Delete a sprite that was listening — nothing breaks. The broadcast still goes out; it just has one fewer ear.
A complete tiny example
when this sprite clicked
broadcast (start race v)
when I receive (start race v)
move (100) steps
Two sprites. One broadcast. The cat doesn't know about the button; the button doesn't know about the cat. They communicate through the message name.
Worked Example — the button-press race start 14 min
Two sprites and one broadcast. The button starts the race; the cat does the running.
start race.Step 1 — Two sprites
New project. The cat stays. From the sprite picker, add the Button1 sprite (or any small object you'll use as a button). Drag the button to the bottom-right corner of the Stage. Drag the cat to the left side.
Step 2 — Create the broadcast name
Click the button sprite. Open the yellow Events palette. Drag in when this sprite clicked, then below it drag broadcast (message1 v).
Click the dropdown inside broadcast. Pick New message…. Type start race. Click OK.
The dropdown now reads start race. From now on every broadcast and receiver block in this project can pick start race from the dropdown.
Step 3 — The button's full script
when this sprite clicked
broadcast (start race v)
Step 4 — Switch to the cat
Click the cat in the Sprite list.
Step 5 — Add the receiver hat
From Events, drag when I receive (message1 v). Open its dropdown. Pick start race from the list (it's there because you created it on the button in step 2 — the message list is shared across the whole project).
Step 6 — The reaction
Add motion and looks blocks under the receiver. We'll have the cat say a count-down and then run:
when I receive (start race v)
say [3] for (0.5) seconds
say [2] for (0.5) seconds
say [1] for (0.5) seconds
say [Go!] for (0.5) seconds
repeat (10)
move (20) steps
end
Step 7 — Click the flag, then click the button
Clicking the flag does nothing visible — there's no when ⚑ clicked hat anywhere in this project. The whole project is asleep, waiting.
Now click the button on the Stage. The cat counts down 3, 2, 1, Go! and runs.
Step 8 — Add a second listener
Without touching the button's script, drag a third sprite into the project (a fish, anything). Give it the exact same receiver:
when I receive (start race v)
repeat (10)
move (15) steps
end
Click the button again. Both cat and fish start running, in step, because both heard the same cue. The button still doesn't know about the fish — and doesn't need to.
What you just built: a one-to-many cue system. One sprite sends, many sprites react. This is how you'll build every menu, every level transition, every "press start" screen for the rest of the course.
Try It Yourself — three broadcast drills 15 min
Goal: One sprite. Two scripts. Pressing the space key broadcasts jump. The same sprite has a when I receive (jump v) hat that makes it jump (change y by 60, wait 0.2, change y by −60).
when [space v] key pressed
broadcast (jump v)
when I receive (jump v)
change y by (60)
wait (0.2) seconds
change y by (-60)
Think: A sprite can broadcast to itself. This looks like overkill for one sprite — why not just put the jump in the key-press script directly? — but it scales: in the Stretch task we add another sprite that also jumps, with no change to the sender.
Goal: Two sprites — a button and a backdrop-changer. Click the button to broadcast night. The Stage receives night and switches to a dark backdrop (add at least two backdrops from the library first — one daytime, one night).
when this sprite clicked
broadcast (night v)
when I receive (night v)
switch backdrop to (Night City v)
Think: The Stage is a sprite-like thing for script purposes. Backdrops are to the Stage what costumes are to a sprite. Broadcasts cross the whole project, including the Stage.
Goal: Three sprites that all dance together. A drummer sprite broadcasts beat every 0.5 seconds forever. Two dancers each have a when I receive (beat v) hat that makes them do different moves — one spins, one bounces.
when flag clicked
forever
broadcast (beat v)
wait (0.5) seconds
end
when I receive (beat v)
turn cw (15) degrees
when I receive (beat v)
change y by (10)
wait (0.1) seconds
change y by (-10)
Think: Both dancers hear the same cue, in step, but do different things. The drummer doesn't know they're there. To add a third dancer, just add another sprite with its own when I receive (beat v) — zero changes to the drummer.
Mini-Challenge — the cue that never lands 5 min
"Aljay's silent door"
Aljay builds a two-sprite project — a key and a door. He wants clicking the key to open the door. He writes this on the key:
when this sprite clicked
broadcast (Door Opens v)
And this on the door:
when I receive (door opens v)
next costume
He clicks the flag, then clicks the key. The door does nothing. What's the bug?
Reveal one valid solution
The message names don't match. The key broadcasts Door Opens (capital D, capital O). The door listens for door opens (all lowercase). Scratch treats those as two different messages.
Worse: Aljay almost certainly typed door opens manually into the door's receiver instead of picking it from the dropdown. That created a second, never-used message in the project. Now the message list contains Door Opens (which the key sends, but nobody hears) and door opens (which the door listens for, but nobody sends).
The fix: open either block's dropdown and re-pick the right name from the list — don't retype it. Better practice: delete one of the messages by clicking Edit message… in the dropdown and unifying them. Best practice from day one: always pick existing message names from the dropdown, only ever type a new name when you genuinely want a new message.
Renamed properly, both blocks point at the same shared message, and clicking the key opens the door.
Recap 3 min
You met the broadcast — Scratch's wireless cue. A single broadcast (name v) block sends a named message that every sprite (and the Stage) can hear. Any sprite holding a matching when I receive (name v) hat reacts when the cue arrives. Broadcasts are fire-and-forget — the sender doesn't know or care who's listening. That's the secret to scenes with two, three, or twenty sprites that all act in coordination without one giant tangled script.
- Broadcast
- An Events-palette block that sends a named cue across the whole project. The sender doesn't know which sprites are listening.
- Message
- The named cue itself —
start race,game over,beat. Created from the broadcast or when-I-receive dropdown via "New message…". - When I receive
- A hat block that fires when a matching broadcast lands. One sprite can have many of these — one per message it cares about.
- Fire-and-forget
- The way plain broadcast works — the sender ships the cue and continues immediately. The "and wait" variant (next lesson) pauses the sender until every listener finishes.
- Message list
- The project-wide list of every message name you've created. Shared by every sprite and the Stage. Always re-pick existing names from the dropdown — never retype.
- The Stage
- Has its own scripts and can be a sender or receiver of broadcasts. Backdrops are to the Stage what costumes are to a sprite.
Homework 2 min
The Two-Stage Show. Build a tiny project that uses broadcasts to switch between two "scenes" — a daytime scene with a sun, and a night scene with a moon.
- Open a fresh project. Add two backdrops from the library — a daytime one and a night one.
- Add two sprites — a sun and a moon (pick from the library, or paint simple circles).
- Add a button sprite at the bottom of the Stage.
- On the button: when clicked, broadcast
toggle. (No need to track "which scene am I on" — both broadcasts can fire from one button if you alternate. Or use two buttons if that's simpler.) - On the Stage: when receiving
night, switch to the night backdrop. When receivingday, switch to the day backdrop. - On the sun: when I receive (day v) + show; when I receive (night v) + hide.
- On the moon: the opposite — show on night, hide on day.
- Add a when ⚑ clicked + broadcast (day v) on the Stage so each new flag-click resets to day.
Save as HW-L2-20-Day-Night.sb3. Click the flag — daytime scene. Click your button(s) to toggle to night. The sun hides, the moon shows, the backdrop turns dark. Click again to toggle back.
Bring back next class:
- The
.sb3. - Your answer to: "How many broadcasts are in your message list, and what would you have to change to add a 'dawn' scene with a third backdrop?"
Heads up for next class: SCR-L02-21 drills into when I receive on its own — the receiver hat that turns a quiet sprite into one that listens for cues.