Learning Goals 3 min
By the end of this lesson you will be able to:
- Explain what if on edge, bounce does in your own words.
- Drag the block into your Script Area and place it after a move so the cat bounces off the edge instead of getting stuck.
- Click the green flag and watch the cat travel right, hit the edge, flip around, and face the other way.
Warm-Up 7 min
Last lesson the cat learned to face the way it travels — arc skill 6 of 8. Today we add the one-block trick that stops it sneaking off the garden fence and getting stuck on the edge.
Quick-fire puzzle
Daniel built this script and clicked the flag three times in a row. What happens on the third click?
when flag clicked
move (200) steps
Reveal the answer
Click 1: the cat moves from (0, 0) to (+200, 0) — still on the Stage. Click 2: it tries to move to (+400, 0), but the Stage edge stops it at (+240, 0). Click 3: the cat is already against the right edge — it tries to move further, but Scratch keeps it pinned to x = 240. The cat looks stuck.
Today's new block fixes that. When the cat hits an edge, it spins around 180° and faces the other way. Next click — off it goes back across the Stage.
New Concept — bouncing off the wall 15 min
Think of a ball rolling across the floor. When it hits the wall, it does not pass through — it bounces back. if on edge, bounce is that wall-bounce for your sprite. The block checks: am I touching an edge of the Stage? If yes, spin 180° and step back inside. If no, do nothing.
Blocks reference
| Block | Category | What it does |
|---|---|---|
| if on edge, bounce | Motion (blue) | If the sprite is touching the edge of the Stage, it flips its direction by 180° and nudges back inside. If not touching an edge, it does nothing. |
How the bounce works on the Stage
The block in a stack
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
Why it matters
Without this block, sprites pile up against the edge and get stuck. With it, your cat looks alive — it never falls off, it never freezes. Almost every Scratch animation, game, and chase uses this single block somewhere.
Worked Example — Mei Ling's bouncing cat 15 min
Open Scratch. Rename your cat to Mei Ling's Cat. We are going to send the cat from the centre to the right edge and watch it flip around.
Step 1 — Add the start hat
Drag when ⚑ clicked from the yellow Events category into the Script Area.
Step 2 — Reset position and direction
Snap go to x: (0) y: (0) under the hat. Then add point in direction (90). Now no matter how the previous run finished, the cat starts at the centre facing right.
Step 3 — Move a big step
Add move (10) steps under the point block. Change the 10 to 250. The cat will travel 250 pixels right — but the Stage edge is at +240, so the cat lands on the right edge.
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
Step 4 — Click the green flag
The cat zips to the right edge and pins against it. If you click again, it tries to move further right and stays pinned. Not great.
Step 5 — Add the bounce
From Motion, scroll until you find if on edge, bounce. Drag it under move (250) steps. Click the flag again.
Now the cat reaches the edge — and instantly spins 180°. Check the Sprite Properties: Direction now reads -90 (facing left). The cat itself looks flipped horizontally.
Step 6 — Click the flag a second time
The cat resets to the centre (because of go to), then resets to facing right (because of point in direction (90)), and bounces off the right edge again. To watch a "free" bounce, delete the go to and point in direction reset blocks for one quick experiment — click the flag, the cat bounces, click again, it comes back the other way.
What changed: last lesson, a cat could only ever face one direction at a time and could get stuck on an edge. Today, a single block flips it around the moment it touches the edge — your sprite never gets stuck again.
The full assembled stack (your reference)
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
Try It Yourself — three small builds 12 min
Goal: Make the cat bounce off the left edge instead of the right.
when flag clicked
go to x: (0) y: (0)
point in direction (-90)
move (250) steps
if on edge, bounce
Think: Direction -90 = left. The cat marches left, hits the left edge at x = -240, then bounces — its direction flips to +90 (right).
Goal: Make the cat bounce off the top edge.
when flag clicked
go to x: (0) y: (0)
point in direction (0)
move (200) steps
if on edge, bounce
Think: Direction 0 = up. The top edge is at y = +180; 200 steps takes the cat past it. The bounce flips direction to 180 (down). Five blocks total.
Goal: Two bounces in one click — right edge, then left edge.
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
move (500) steps
if on edge, bounce
Think: The first move hits the right edge; the first bounce flips direction to left. The second move (500 steps) takes the cat all the way left past the left edge; the second bounce flips direction back to right. Seven blocks — under the 8-block cap.
Mini-Challenge — bounce and say something 5 min
"The cat that thanks the wall"
Combine today's if on edge, bounce with the say block from earlier lessons. The cat should travel to the edge, bounce, then say something polite to the wall.
It works if:
- One click of the green flag runs the whole demo.
- The cat reaches an edge and visibly bounces (flips around).
- The cat says something after the bounce, not before.
- You only use blocks from today and earlier lessons.
Reveal one valid solution
when flag clicked
go to x: (0) y: (0)
point in direction (90)
move (250) steps
if on edge, bounce
say [Terima kasih, dinding!] for (2) seconds
Six blocks. The cat zips right, bounces off the right edge, then says "Thank you, wall!" in Malay while facing left.
Recap 2 min
Today you met the bounce block. if on edge, bounce checks for one thing: is the sprite touching an edge? If yes, the sprite spins 180° and steps just inside the Stage. If no, the block does nothing. It is the one-line fix that lets sprites travel without getting stuck.
- if on edge, bounce (block)
- A motion block that flips the sprite's direction by 180° if it is touching the edge of the Stage. Does nothing otherwise.
- Edge
- Any of the four borders of the Stage: left (
x = -240), right (x = +240), top (y = +180), bottom (y = -180). - Bounce
- The act of flipping direction by 180° upon touching an edge. After a right-edge bounce, Direction goes from
90to-90.
Homework 1 min
The boomerang cat. Build a script that sends the cat to one edge of the Stage, bounces it, and then sends it the other way for one more bounce.
- Open Scratch.
- Drag when ⚑ clicked into the Script Area.
- Add go to x: (0) y: (0) and point in direction (90).
- Add move (250) steps and then if on edge, bounce.
- Add a second move (500) steps and a second if on edge, bounce. (Seven blocks.)
- Click the flag. The cat should travel right, bounce, travel left, bounce again.
Bring back next class:
- A screenshot of your 7-block Script Area.
- Your written answer to this question: "What would happen if you removed the second if on edge, bounce block? Would the cat still travel back, but get stuck somewhere?"
Heads up for next class: SCR-L01-14 is a project lesson. You will assemble today's bounce trick with the glide and point-in-direction blocks to build a complete "Cat Bounce Across the Stage" animation.