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.
And then in our player, we’ll add the following to the game loop.
Back in our Game Over sprite, we’ll listen for that message.
And that will do it! Broadcasting is super useful when you need to communicate between sprites.