Learning Goals 3 min
By the end of this lesson you will be able to:
- Drag
when this sprite clickedfrom Events and give it an action. - Explain what the word this refers to in that block.
- Say which of the three hats you now know suits a given job.
Warm-Up 7 min
Your show opens on the flag and takes orders from the keyboard. But the audience is still typing at the cat from a distance. Today they get to touch it.
Quick-fire puzzle
Priya built this on her cat. The flag did nothing. Every key did nothing. Then she clicked the cat itself and it sprang to life. What does it do?
when this sprite clicked
say [Ouch!] for (1) seconds
turn cw (15) degrees
Reveal the answer
Every click makes the cat say “Ouch!” for a second, then tilt 15 degrees. Five clicks and it is leaning 75 degrees; twenty-four and it has come full circle.
Clicking empty stage does nothing, because the hat is not watching the Stage. It is watching one sprite — the one it lives on.
New Concept — a sprite as a button 15 min
Think of a lift with a row of floor buttons. Pressing the button for floor three does not send you to floor five, however hard you press. Each button answers only for itself, and sprites work the same way.
The new block
| Block | Category | What it does |
|---|---|---|
when this sprite clicked | Events | Waits for a mouse click on the sprite carrying this script, then runs the blocks below. |
What “this” means
Notice there is no drop-down. The other two hats let you choose — which key, which event. This one does not, because the answer is already decided by where you put the block.
Drop it in the cat’s Script Area and it means the cat. Drop the very same block on the dancer and it means the dancer. The block never changes; its meaning comes from its home.
when this sprite clicked
say [Hi! You clicked me.] for (2) seconds
Three hats, three ways in
You now know every hat block Level 1 needs, and choosing between them is a real design decision rather than a detail.
| Hat | Who triggers it | Best for |
|---|---|---|
when flag clicked | Anyone, from above the Stage | Starting or resetting a whole project. |
when [space v] key pressed | Anyone with a keyboard | Repeated actions during play — moving, jumping. |
when this sprite clicked | Anyone with a mouse, aiming at one sprite | Buttons, menus, characters that answer back. |
Clicks land on pixels, not boxes
A click only counts if it lands on part of the costume that is actually drawn. The gaps between the cat’s legs are see-through, and a click there sails straight past.
This catches everybody out at least once. If your clicks feel unreliable, you are probably aiming at a hole.
Why it matters
Clickable sprites are what make a project feel like an app rather than a film. A menu of buttons, a character who answers when poked, a puzzle where you collect things — all of it starts with this one block.
Worked Example — the cat that answers back 15 min
We build a click trick, then add a flag script beside it so the two kinds of event can be compared directly.
Step 1 — Drag the click hat
From Events, drop when this sprite clicked into the cat’s Script Area. There is no drop-down to set — sitting on the cat is all the configuration it needs.
Step 2 — Give it a reaction
Snap on say [Hi! You clicked me.] for (2) seconds. Click the cat on the Stage. The bubble appears without the flag being touched.
Step 3 — Aim badly on purpose
Now click a gap between the cat’s legs. Nothing happens. That is not a fault — you missed the drawn pixels, and it is the single most common confusion with this block.
Step 4 — Make it a trick
Add turn cw (30) degrees above the say block so the cat spins before it speaks.
when this sprite clicked
turn cw (30) degrees
say [Wheee!] for (1) seconds
Step 5 — Add a flag script beside it
Drop a when flag clicked hat well clear of the first stack, with reset blocks underneath.
when flag clicked
go to x: (0) y: (0)
point in direction (90)
when this sprite clicked
turn cw (30) degrees
say [Wheee!] for (1) seconds
Step 6 — Play with both
Click the cat until it is leaning at an odd angle, then click the flag. It snaps upright and returns to the centre, ready to go again.
That pairing — a flag script that resets and an event script that plays — is the shape of almost every finished Scratch project you will meet.
What changed: your project now has two completely separate ways to be used, each doing the job it is best suited to.
The full assembled scripts (your reference)
when flag clicked
go to x: (0) y: (0)
point in direction (90)
when this sprite clicked
turn cw (30) degrees
say [Wheee!] for (1) seconds
Try It Yourself — three small builds 12 min
Goal: Make the cat meow whenever it is clicked. Then deliberately click a transparent gap and note what happens.
when this sprite clicked
say [Meow!] for (1) seconds
Think: the flag is never involved. A script needs a cue, and a mouse click is as good a cue as any.
Goal: Turn each click into one step of a loop around the stage — a turn, a walk, then a cheer.
when this sprite clicked
turn cw (30) degrees
move (20) steps
say [Wheee!] for (1) seconds
Think: twelve clicks make a full turn, but because each one also walks forward, the cat traces a ring rather than spinning on the spot.
Mini-mission: two performers, two buttons. Add a second sprite and give each its own click script, so the audience can choose which performer to wake.
It works if: clicking each sprite produces a clearly different reaction, and clicking one leaves the other completely still. Keep each stack under 8 blocks.
Think: the block is identical on both sprites. So what makes them behave differently — and where exactly did you have to drop each one?
Mini-Challenge — the three-stop tour 5 min
“Click the cat to tour three cities”
One click on the cat should send it on a complete tour, naming three Malaysian cities as it travels between three places on the stage.
It works if:
- A single click on the cat plays the entire tour with no further input.
- Three different cities are named, each while the cat is at a different place.
- The click hat is the only hat in the script.
- You combined it with at least one travel block from an earlier lesson.
Reveal one valid solution (teacher)
when this sprite clicked
say [Kuala Lumpur] for (2) seconds
glide (2) secs to x: (-100) y: (0)
say [Penang] for (2) seconds
glide (2) secs to x: (100) y: (0)
say [Johor Bahru] for (2) seconds
Six blocks, about ten seconds. Worth raising with the class: clicking again mid-tour does nothing, because the script is still busy. That is a real property of event hats, not a mistake.
Recap 2 min
The third hat waits for a mouse click on the sprite it lives on. It has no drop-down because its meaning comes from where you put it — this sprite is whichever Script Area it sits in. Clicks only count on the drawn parts of a costume, and this hat ignores the flag entirely, so a reset script and a click script can share a sprite quite happily.
- when this sprite clicked
- An Events hat that waits for a mouse click on the sprite carrying the script.
- This sprite
- Whichever sprite’s Script Area the block sits in. The block itself never names one.
- Costume pixels
- The drawn parts of a sprite. Clicks on transparent gaps do not register.
- Reset script
- A flag script whose job is to return everything to a known starting state.
Homework 1 min
The clickable pair. Build two sprites that each answer to being clicked, plus a flag script that resets the stage.
- Keep the cat and add one more sprite from the library.
- Give each sprite a click script that makes it say something different.
- Give the cat a flag script that sends it back to the middle of the stage.
- Click each sprite three times, then click the flag. Screenshot both Script Areas.
when this sprite clicked
say [I am the cat!] for (2) seconds
when flag clicked
go to x: (0) y: (0)
Bring back next class:
- Screenshots of both sprites’ Script Areas.
- Your answer to: “The click block looks identical on both sprites. So how does Scratch know which one you clicked?”
Heads up for next class: SCR-L01-18 looks properly at wait (1) seconds — the block that gives a routine its rhythm.