Scratch the broadcast and broadcast wait

I. Introduction

Scratch the building block associated with the message three, as shown below:

Scratch the broadcast and broadcast wait

So, what difference does it make two kinds of broadcast back? The answer is as follows:

  • Broadcast (message): send a message to all the roles, including self contained. After sending, we will continue to execute code down immediately

  • Broadcast (message) and waits: Send a message to all the roles, including self contained. After transmission, the code will wait until all messages received after the completion of the execution continues downward.

Second, examples

Now, let us explain the difference between the two above broadcast by a simple example. First, please watch the following three screenshots:
Scratch the broadcast and broadcast wait

Scratch the broadcast and broadcast wait
Scratch the broadcast and broadcast wait

Next, look at the code again, and finally we'll summarize.

Cat Code:
Scratch the broadcast and broadcast wait

Kitten 1 Code:
Scratch the broadcast and broadcast wait

Kitten 2 code:
Scratch the broadcast and broadcast wait

3 kittens Code:
Scratch the broadcast and broadcast wait

After pressing the green flag small program execution, the result is displayed in accordance with the above three sequence FIG. This clearly illustrates the broadcast message and wait for [the role of] building blocks, the building blocks of the code behind the implementation of this code is all that is, when the message is received after completion of execution.

III Summary

The above first broadcast message] [building role with global variables have the same effect, but the second broadcast message and wait for [building] the meaning is very unusual, it's like a commander, through this special " command "to control all of consistent actions of its subsidiary - the same group until after the task is completed, then the next issue unified command to complete the second and third batch task ......

[Note] I for a long period will focus on young people to explore the teaching program, teaching the game and knowledge of robot programming, interested friends please pay attention to my number one hundred and welcome message a lot to explore:

Scratch the broadcast and broadcast wait

Guess you like

Origin blog.51cto.com/zhuxianzhong/2463498