Building a button with 'when this sprite clicked'

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Building a button with 'when this sprite clicked'

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which block makes a sprite work like a button that starts a script when the user clicks it?
A when this sprite clicked
B when green flag clicked
2. Mia draws a sprite that looks like a green circle. She wants it to be a Start button. What should she add so users know what it does?
A A second green circle with no words
B A label on the sprite that says Start
3. True or false: A sprite with a 'when this sprite clicked' script will run its blocks when you click the BACKGROUND, not the sprite.
A False
B True
4. Which script gives the user feedback that the button was clicked?
A when this sprite clicked → (no blocks under it)
B when this sprite clicked → change color effect by 25
5. Jay wants a button that says 'Play'. Which is the best way to make the label?
A Type the word Play in the sprite's costume
B Type the word Play in the code area only

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1when this sprite clicked Awhen this sprite clicked switch backdrop to [game v]
2change [color v] effect by 25 Bsay [Start] for (2) seconds
3Put a label on a button sprite so users know what it does, such as the word Start. CThe green flag event starts the script when the project begins, not when the user clicks the sprite, so the sprite does not work as a button. Use 'when this sprite clicked' instead.
4Make a sprite work as a button by starting its script with a click event. DThe event block is at the bottom. A hat block must be at the top of the script, so the colour change will never run when the sprite is clicked.
5when green flag clicked say [Play!] for (2) seconds EAn event block that starts its script when the user clicks that sprite, so the sprite works like a button.
6change [color v] effect by 25 when this sprite clicked FA looks block that changes the sprite's colour, which can show the user that the button was clicked or can be clicked.

Definitions

when this sprite clicked

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
________________________ say "Play!" for 2 seconds
2.
when this sprite clicked change _____ effect by 25
3.
when this sprite clicked say "Play!" for _ seconds
4.
forever if <________ mouse-pointer?> then set color effect to 50
5.
when ___________ clicked say "Go!" for 1 seconds

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A when this sprite clicked
B set color effect to 50
C wait 0.5 seconds
D set color effect to 50
Question 2
A when green flag clicked
B say "Hello!" for 2 seconds
C change color effect by 25
Question 3
A when this sprite clicked
B set color effect to 50
C switch backdrop to Game
D show
Question 4
A when this sprite clicked
B switch backdrop to pressed
C wait 0.3 seconds
D switch costume to normal
Question 5
A when green flag clicked
B go to x: 0 y: 0
C say ""
D when this sprite clicked
E change color effect by 25

Answer Key

Building a button with 'when this sprite clicked'
Section A: Quick Questions
Q1
A — when this sprite clicked
Q2
B — A label on the sprite that says Start
Q3
A — False
Q4
B — when this sprite clicked → change color effect by 25
Q5
A — Type the word Play in the sprite's costume
Section B: Match the Pairs
Q1
when this sprite clicked → An event block that starts its script when the user clicks that sprite, so the sprite works like a button.
Q2
change [color v] effect by 25 → A looks block that changes the sprite's colour, which can show the user that the button was clicked or can be clicked.
Q3
Put a label on a button sprite so users know what it does, such as the word Start. → say [Start] for (2) seconds
Q4
Make a sprite work as a button by starting its script with a click event. → when this sprite clicked switch backdrop to [game v]
Q5
when green flag clicked say [Play!] for (2) seconds → The green flag event starts the script when the project begins, not when the user clicks the sprite, so the sprite does not work as a button. Use 'when this sprite clicked' instead.
Q6
change [color v] effect by 25 when this sprite clicked → The event block is at the bottom. A hat block must be at the top of the script, so the colour change will never run when the sprite is clicked.
Section C: Definitions
Q1
when this sprite clicked — An event block that starts its script when the user clicks that sprite, so the sprite works like a button. Add a label to the sprite and a colour change to show it can be clicked.
Section D: Fill in the Blanks
Q1
when this sprite clicked say "Play!" for 2 seconds
Q2
when this sprite clicked change color effect by 25
Q3
when this sprite clicked say "Play!" for 2 seconds
Q4
forever if <touching mouse-pointer?> then set color effect to 50
Q5
when this sprite clicked say "Go!" for 1 seconds
Section E: Spot the Error
Q1
D — The last block should set the colour effect back to 0. If it sets 50 again, the button stays changed and never returns to normal.
Q2
A — A sprite only works like a button if its script starts with 'when this sprite clicked'. The green flag block starts the script when the flag is clicked, not the sprite.
Q3
D — A start button should hide once the game screen appears. 'show' would leave the button on the screen when it is no longer needed. It should be 'hide'.
Q4
B — The button is a sprite, so its look changes with 'switch costume'. 'switch backdrop' changes the stage background, not the button.
Q5
C — The say block gives the button its label. An empty message shows no label, so the user cannot tell it is a button. It should say "Click me!".