2. Change Color and Reset
In this video, you'll program the color button to change the color of the image when it is clicked.
You’ll do this by broadcasting a message from the color sprite to the nature sprite.
First, select the color sprite.
To make the sprite broadcast a message when clicked, add a "broadcast" block from the events menu.
From the dropdown menu, select new message, and name the message something like "change color."
Add a "when this sprite clicked" block above this block.
Click the color button sprite on the stage.
Hey, nothing happens!
The color sprite broadcasts a message, but the nature sprite doesn’t change color.
Click the nature sprite, and add a "when I receive" block to the scripts area.
Set the message to the message name you just created.
To make the sprite change color when it receives the message, add a "change color effect" block from the looks menu.
This block has a default value of 25.
This example uses a value of 10, but you can type in any value you like.
Clicking the color button more than once will change the color effect multiple times.
= A larger number, on the other hand, will create a more dramatic difference.
Try out different numbers in the "change color effect" block until you like the result.
Click the color button.
Cool, when the color button is clicked, it broadcasts the change color message.
When the nature sprite receives this message, it changes color.
To reset the image to its original color, select the reset sprite.
Add a "broadcast" block, select "new message" from the dropdown menu, and name the message something like, "Reset."
Then, add a "when this sprite clicked" block to the top of the code stack.
Now that the reset sprite broadcasts a message, program the nature sprite to receive that message.
Select the nature sprite, add a "when I receive" block, and select the "Reset" message you just created.
Add a "clear graphic effects" block from the looks menu to the block stack.
Click the reset button.
The image returns to its original state.
In the next video, you'll learn how to program the ghost, pixelate, mosaic, and fisheye buttons to broadcast messages to the image sprite.
Now, it's your turn.
Program the color sprite to broadcast a message when clicked, and program the nature sprite to change color when it receives that message.
Program the reset sprite to broadcast a message when clicked, and program the nature sprite to clear graphic effects when it receives that message.