{ }codelper

Learn with tiles › 36

Broadcasting

One object broadcasts, and another object hears it and moves.

1

Until now each object only did its own work. Now they tell each other things.

The broadcast (name) (value) tile sends a broadcast to every object in the scene. A broadcast has a name. You will learn about the value of the tile a little later.

Nyang already has tiles. When Nyang receives the broadcast go, Nyang says Coming! and walks toward Lara.

To do Make Lara say Go! and then send the broadcast go when you tap Lara.

Loading tiles…

2

This time Lara is the one who receives.

when I receive (name) (value) runs the tiles below it when a broadcast with that name arrives. It is an event tile, like "when tapped".

One second after the start, Nyang says Lara! and sends the broadcast call.

To do Make Lara say Yes? when Lara receives the broadcast call.

Loading tiles…

3

A broadcast can carry one value. The receiver gets it as the value of "when I receive".

When Nyang receives the broadcast up, Nyang says the value that came with it. Each time you tap Lara, Lara raises the variable score by 1.

To do Each time you tap Lara, send the broadcast up with the value of the variable score. Nyang says 1, 2, 3 in order.

Loading tiles…

Next: Clones →