Broadcasting

Animation with Scratch - Lesson 2

Objectives

  • Create, test and improve effective control sequences.
  • Use conditional statements, broadcasting and sensing.
  • Use logical reasoning to explain how some simple algorithms work and to detect and correct errors in algorithms and programs

Broadcasting

Begin by introducing/recapping the concept of ‘broadcasting’ in Scratch.

A broadcast is a method where a custom message can be sent at a time of your choice. The broadcast message can then act as a trigger to make any sprite or the stage do something, by starting a new script that is linked to the name of the broadcast you create.

Open this Scratch file. It’s a simple way to explain broadcasting. In it, the orange cat follows the mouse pointer, the purple cat does nothing until the orange cat touches the red circle. At that point a message is broadcast, which tells the purple cat to do something (follow the other cat), which is the key point to broadcasting; something only happens when it gets the message to do it. 

Sprites or the Stage can send messages back and forth, for example, touching the green circle tells the stage to change background (look at the script on the stage in the example file).

You may want to go through broadcasting in a very step-by-step way with them to begin with as it can be challenging for some until they ‘click’ with the concept. Build a file with them:

  1. Create 2 sprites
  2. Program Sprite 1 to start somewhere and glide across the screen.
  3. Create a broadcast after the glide block.
  4. On Sprite 2 add a ‘When I receive’ block that listens for the broadcast, then add a ‘go to’ block to tell it where to start, then a glide block to make it move and a ‘Say hello’ block for some speech.

Sprite 1:

Sprite 2:

 

Ask them to test this and emphasise how Sprite 2 will always move when it receives the broadcast message and that it will only move because of this message. It all happens instantly though so there is no delay in waiting for the message.

Once they have that working, let the children experiment with broadcasting, they should:

  • Make a second sprite say something because of a broadcast (great for getting the timing of back and forth conversations right!)

 

  • Make something be hidden at the beginning but appear when it receives a broadcast (‘show’ and ‘hide’)

 

 

Next have a look at the beginning of this example France presentation

Watch it full screen first up to the point where Jean Claude appears.

  • How does it work?
  • Can you explain any parts of it without looking at the script?
  • Where do you think broadcasting is used?

Have a look at some of the script, point out that much of it is speech bubbles. Focus on this part (shown in the teacher’s presentation). 

 

 

Highlight that the timing of the whole thing is done with ‘broadcasting’

Look at Sprites as presenters, and how Sprite 1 works, what does this first bit of Script do for Sprite 1? It tells it when and how to first appear, its first bit of movement, a sound effect, and the first bit of info for the presentation.

Ask the students to create a short animation that involves two characters. It should contain (at least):

  • One sprite showing at the start
  • The other sprite hidden at the start
  • A broadcast that makes the second sprite appear when the first sprite does something
  • Both sprites moving
  • Both sprites speaking
  • A background change

 

Commenting your code

Finally, show the students how you can add comments to your code in Scratch. Why might this be useful? This is a really common practise in any coding language. Often programs are written by more than one person and comments make it much easier for someone new coming to code to see what it means and how it works. It’s also great for leaving notes to yourself if you are halfway through a project when you need to stop, and a lovely way to be able to demonstrate you understand what your code does. 

Ask them to have a go at leaving comments on their code, particularly where broadcasts are used in their project. Here’s an example, just right-click blocks to add a comment to them:

 

 

Ensure they have named their project with their name and save any work they wish to keep > File > Save to my computer:

 

Plenary

What are broadcasts and what sort of actions can they trigger? They are messages sent between any sprites and/or the stage. They can trigger pretty much anything you want them to! 

What two parts are essential to a broadcast working? The ‘broadcast’ (send) and ‘when I receive’ blocks are the two key parts. Either of these blocks on their own are useless. It’s also vital that message names match, encourage students to name broadcasts appropriately so someone would know what they do if they looked at their code. 

Why might we add comments to our code?

Who successfully added a comment today?

Take a look at a partner’s comments, would they make sense or be useful if you had never seen their code before? Do they explain it well?

< Previous Lesson