Messages
We can communicate two programs either within the same sprite or between different sprites or with the stage by sending messages. A message can be sent from a program from one sprite to another, to perform some action on it. These blocks are located in "Events".
Practical case:
We are going to make it so that when the cat touches the dog, the cat program broadcasts a message to the dog program. When the dog receives the message, it will change its position, to a random position.
Solution
When Flag clicked, if the Cat touches the dog (Dog1), it sends a message.
Program to include in Cat code:
That message is received by the Dog1 sprite, and makes the dog move to a random position on the screen.
Program to include in Dog1 code: