Broadcast and Receive - Lakelands Computing

Title
Go to content
Using Broadcast and When I Receive..
This code would be on the Wizard
This code would be on the Dragon
We can use the wait command to help us synchronise programs - make sure they run at the right time. This works well when we can work out how long we need to wait to trigger the next command on a sprite (eg wait 4 seconds as the other sprite has say for 4 seconds). This approach doesn't really work when we don't know how long to wait for. For example if we use Ask then we need to wait until the user has pressed enter this could 4 seconds it could be 4 minutes we just don't know.

Broadcast and When I Receive help solve this problem. They are also very useful in games to start an action at a certain point, for example when a health bar reaches 50% the character may slow down.

The way it works is you make one sprite Broadcast a message when it reaches a particular point, and put When I Receive on the other sprite so it knows to act when it receives the message from the first sprite (It’s a bit like one sprite texts go to the other). Have a look at the video
All Text copyright Lakelands Academy & Mr T Purslow 2020.
All images copyright free / creative commons unless otherwise stated.
You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
All Text copyright Lakelands Academy & Mr T Purslow 2020.  All images copyright free / creative commons unless otherwise stated. You are welcome to use under a Creative Commons Attribution-nonCommercial-ShareAlike License.
Back to content