Now you’re going to add different coloured pencils to your project and allow the user to choose between them.
Click on the Costumes tab of the ‘pencil’ sprite.
Rename the pencil-a
costume to pencil-blue
Right click on the pencil-blue costume and select duplicate.
Name the new costume ‘pencil-green’, and colour the pencil green.
Draw two new sprites: one blue square and one green square. These are for choosing between the blue and green pencil.
Rename the new sprites so that they are called ‘blue’ and ‘green’
Add some code to the ‘green’ sprite so that when this sprite is clicked, it broadcasts
the message “green”.
The pencil sprite should listen for the “green” message and change its costume and pencil colour in response.
Switch to your pencil sprite. Add some code so that when this sprite receives the green
broadcast, it switchs to the green pencil costume and changes the pen colour to green.
To set the pencil to colour to green, click the coloured square in the set pen color
block, and then click on the green square sprite.
Then to a similar thing so that you can switch the pencil colour to blue.
Click on the blue square sprite and add this code:
Then click on the pencil sprite and add this code:
Finally, add this code to tell the pencil sprite which colour to start with, and to make sure that the screen is clear when your program starts.
If you prefer, you can start with a different colour pencil.
Test your code. Can you switch between the blue and green pencil colours by clicking on the blue or green square sprites?