Scratch for Kids

A Watch the course on Frontend Masters

Broadcasting A Message

Let’s say we want to have a Game Over screen. Ideally, this would show when the game ends, right? But, how does the screen know?

Well, sprites can broadcast messages. But, first let’s start by hiding our game over screen when the game begins.

whenclickedhide

And then in our player, we’ll add the following to the game loop.

iftouchingEnemythenbroadcastGame Over

Back in our Game Over sprite, we’ll listen for that message.

whenIreceiveGame Overshowstopall

And that will do it! Broadcasting is super useful when you need to communicate between sprites.