9. Next, make the Cube sprite
change costumes, so the color
changes each time it comes
down the conveyor belt:
• Go to the Looks menu
(purple) and drag a “switch
costume to [costume
name]” block above the
“go to” block
(Figure
Q
)
.
• Go to the Operators menu
(green). You will see
blocks that look like math
operations. Drag the “pick
random [1] to [10]” block
over the name area on the
“switch costume” block.
• Count the number of
costumes you have,
and type that number
over the 10.
10. From the Events (tan) menu, drag a “When [flag] clicked” block on the
top of the stack. Click on the stack to make sure everything is working!
11. Now create a new stack of code telling the cube to change course when
it receives a message from the robot arm saying that a green cube has
been detected. The cube needs to fly through the air in the direction of
the Green Cubes sign.To begin:
• Go to the Events menu (tan) and look for “when I receive
[message1].” Drag it into an open area in the workspace
(Figure
R
)
.
• Click on “message1” and create a new message. Give it a name like
CubeSort.
• On the Stage, move the cube to the right edge near the Green Cubes
sign
(Figure
S
)
.
Q
R
96
Making Simple Robots, 2nd Edition
Make_Simple_Robots_interior_FIN.indd 96Make_Simple_Robots_interior_FIN.indd 96 4/26/22 1:55 PM4/26/22 1:55 PM