Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

Getting Sprites to “Talk” to Each Other

A common question among Scratchers who have made some progress in their work is, “How can I get sprites to affect each other?” For instance, what if you want Sprite B to move when Sprite A touches it?

In Scratch, you use broadcasts to pass messages among sprites. You can even communicate between sprites and the Stage by sending and receiving broadcasts.

You will find the icon114 and icon115 blocks in the Events palette.

You’ll also see a icon113 Hat block that you use to catch outgoing broadcasts.

Trust me—before too long, you’ll appreciate how powerful broadcasts are; they will be an indispensable addition to your Scratch programming toolkit.

Here are a few key points to keep in mind regarding Scratch broadcast messages:

  • A sprite can both send and receive the same broadcast message.

  • Broadcast messages can be received by all sprites (and the Stage).

  • Broadcasts are most commonly used to (1) connect different events, (2) run two scripts in the same frame, and/or (3) prepare a scene with multiple sprites.

To get set up for the Move from Room to Room Try It Yourself exercise, fire up a new, blank project that contains the following assets:

  • Sprite: Default Scratch Cat; rename sprite to Cat.

  • Sprite: Magic Carpet (look in the Transportation section of the Sprite Library); rename to Carpet.

  • Stage backdrops: Add the room1 and room2 backdrops from the Indoors category of the Backdrop Library. You can delete the default backdrop for this exercise.

  • + Share This
  • 🔖 Save To Your Account