Learning Goals 3 min
By the end of this lesson you will be able to:
- Explain what the number in set size to (100) % actually means — that 100 is the sprite's default size, 50 is half, 200 is double, and the units are percent, not pixels.
- Use a balanced pair of change size by (5) and change size by (-5) blocks inside a loop to make a sprite pulse — grow, shrink, repeat.
- Reset a sprite to a known size with set size to (100) % at the start of a script, and explain why this matters as much as clear graphic effects did last lesson.
Warm-Up — three predictions 7 min
You've used change size by () back in Level 1. Today we'll loop it. Predict what each of these three tiny scripts does before you look at the answers.
Puzzle 1 — one-way
when flag clicked
forever
change size by (5)
end
Reveal the answer
The cat grows and grows and grows until it fills the screen, then keeps growing off-screen. The forever loop adds 5 every frame, with no upper limit. Scratch has a size cap (around 540% for the default cat) but the script never realises that. The cat ends up frozen at maximum, off-screen.
Puzzle 2 — back-and-forth
when flag clicked
forever
change size by (5)
change size by (-5)
end
Reveal the answer
The cat sits there looking perfectly still. Each loop adds 5, then subtracts 5 — net change zero, every frame. The change is happening, but it happens faster than the eye can see. To get a visible pulse, we need to (a) make the change bigger, or (b) pause between the up and the down. Today's lesson is mostly about (b).
Puzzle 3 — grow, then pause, then shrink
when flag clicked
forever
change size by (5)
wait (0.1) seconds
change size by (-5)
wait (0.1) seconds
end
Reveal the answer
The cat breathes — gentle pulse, in and out, forever. Same blocks as Daniel's stack, plus 0.1 second pauses. That tiny gap is enough for your eye to actually see the size flicker up before it comes back down. Today's lesson is one big variation of this pattern.
New Concept — size is a percentage 15 min
Every sprite has a property called size. You can see it in the sprite info bar (the little panel above the sprite list). Click any sprite and look for "Size". It's a number, and that number is a percentage, not a count of pixels.
What 100 means
Every sprite is born at size 100. That's what the costume editor calls "full size". From there:
- 50 = half-size. The cat is half as tall and half as wide as it was at 100.
- 200 = double. Twice as tall, twice as wide.
- 10 = tiny — a little dot. Useful for stars, particles, bullets.
- 0 = invisible (but not really gone — collision still works on a tiny invisible point in the middle).
Scratch caps the max size at whatever fits on screen, usually around 540 for a default-size cat. Below 0 makes no sense, so Scratch clamps that too.
Sprite stays centred
Important: changing size does not move the sprite. The sprite's centre (called its costume centre) stays exactly where it was on the Stage. Grow from 100 to 200, the sprite swells outward from that centre point in all directions. This is what makes "pulse" feel like breathing instead of jumping.
The two blocks you need
change size by (10)
set size to (100) %
- change size by (10) — adds 10 to the current size. Use negative numbers to shrink: change size by (-10).
- set size to (100) % — jumps to exactly that size, no matter where you were. Use this at the start of every script that messes with size, so the sprite always begins from a known state.
The pulse recipe
A pulse is just: grow a little, wait a little, shrink the same amount, wait the same time. Inside a forever loop. That's it. Three ingredients:
- The change amount. Bigger = more dramatic pulse. 5 is gentle, 20 is bouncy, 50 is comical.
- The wait time. Shorter = faster heartbeat. 0.1 seconds is fast, 0.3 is calm, 1.0 is meditative.
- Symmetry. The grow amount and the shrink amount must be equal, or your sprite drifts in size forever. Same for the waits.
The smooth-pulse upgrade
A single big change-then-wait looks "steppy" — sprite snaps to bigger, then snaps to smaller. For a smoother feel, break the change into many tiny steps inside a repeat:
when flag clicked
set size to (100) %
forever
repeat (10)
change size by (2)
wait (0.02) seconds
end
repeat (10)
change size by (-2)
wait (0.02) seconds
end
end
Worked Example — the heart that beats 12 min
We'll build a heart-shaped sprite that beats forever — pulses bigger and smaller like a real heart. Seven steps.
Step 1 — Pick the sprite
New Scratch project. Delete the cat. Click the "Choose a Sprite" button (bottom-right), search for Heart, and add it. Centre it on the Stage by dragging.
Step 2 — Plant the reset
From Events: when ⚑ clicked. Underneath, from Looks: set size to (100) %. That guarantees a clean starting size every run.
Step 3 — Open a forever
From Control: forever. Snap it under the set-size.
Step 4 — Grow phase (the squeeze)
Inside the forever, from Control: repeat (10). Inside that, from Looks: change size by (3). Then from Control: wait (0.02) seconds. Ten little nudges of +3 over 0.2 seconds — heart grows by 30.
Step 5 — Shrink phase (the release)
Below the first repeat (10) but still inside the forever, drop another repeat (10). Inside: change size by (-3) and wait (0.02) seconds. Heart shrinks back by 30 — back to 100.
Step 6 — Test it
Click the flag. The heart beats once every 0.4 seconds — about 150 beats per minute, which is a panicked heart. We'll slow it down.
Step 7 — Add a rest between beats
At the bottom of the forever (after the shrink repeat), add one more wait (0.3) seconds. That gives the heart a calm pause between beats — closer to 80 BPM. A resting heart.
The full assembled stack
when flag clicked
set size to (100) %
forever
repeat (10)
change size by (3)
wait (0.02) seconds
end
repeat (10)
change size by (-3)
wait (0.02) seconds
end
wait (0.3) seconds
end
What you just built: the difference between a still picture and a living object. A sprite that pulses gently is the cheapest way in all of game design to say "this thing is alive, click me, I matter." Daniel's cake shop project last term used this exact pattern on the kuih sprites — they pulsed gently so kids would know to click them.
Try It Yourself — three pulse drills 15 min
Goal: The cat grows slightly when you hover the mouse over it, and shrinks back when you move the mouse away. Use touching [mouse-pointer v]?.
when flag clicked
set size to (100) %
forever
if <touching [mouse-pointer v] ?> then
set size to (120) %
else
set size to (100) %
end
end
Think: This is the "hover state" pattern from web buttons. Every clickable thing on a website does some version of this — bigger / brighter / underlined when the mouse is over it.
Goal: Make a star sprite that twinkles — slowly grows from 80% to 120% and back. One full twinkle should take about 2 seconds. Use the smooth repeat pattern.
when flag clicked
set size to (80) %
forever
repeat (20)
change size by (2)
wait (0.05) seconds
end
repeat (20)
change size by (-2)
wait (0.05) seconds
end
end
Think: If you copy-paste this script onto three different star sprites and just change the starting size on each (75%, 80%, 85%), the three stars will pulse out of sync and the sky looks alive. Tiny trick, big effect.
Goal: A "low health" warning. The cat pulses red and big when a variable called health drops below 30, but stays calmly at size 100 otherwise. You'll need to make a variable called health first and set [health v] to (50) at flag click — then change it manually using the variable monitor on the Stage to test.
when flag clicked
set [health v] to (50)
set size to (100) %
clear graphic effects
forever
if <(health) < (30)> then
set [color v] effect to (0)
change size by (10)
wait (0.1) seconds
change size by (-10)
wait (0.1) seconds
else
set size to (100) %
end
end
Think: You're combining last lesson (effects) with this lesson (size) and Level 2 conditionals. This is exactly how every game does the "you're nearly dead" warning — the player's eye is pulled to the pulse without you needing to write any words.
Mini-Challenge — the pulse that won't stop growing 5 min
"Aisyah's runaway balloon"
Aisyah wants a balloon sprite to gently pulse forever — grow by 10, shrink by 10. She writes this:
when flag clicked
forever
change size by (10)
wait (0.2) seconds
change size by (-9)
wait (0.2) seconds
end
Click the flag mentally and watch for 30 seconds. What happens to the balloon, and why?
Reveal one valid solution
Every pulse, the balloon grows by 10 and shrinks by 9 — net gain of +1 per pulse. Over 30 seconds (about 75 pulses), the balloon will have inflated by +75 — gone from 100 to 175. Stay on it for two minutes and the balloon eats the screen.
This is called drift. The fix is to make the change amounts exactly equal:
when flag clicked
set size to (100) %
forever
change size by (10)
wait (0.2) seconds
change size by (-10)
wait (0.2) seconds
end
Plus we added set size to (100) % at the top, so even if there's a tiny rounding drift over a long session, each flag click resets cleanly. Symmetry in, symmetry out. Any imbalance in a loop runs away from you.
Recap 3 min
You met size as a percentage, not a pixel count — 100 is normal, 50 is half, 200 is double, and the sprite stays centred while it changes. change size by () nudges; set size to () % snaps. The pulse pattern — grow, wait, shrink, wait, inside a forever — turns a still sprite into one that looks alive. The whole trick depends on symmetry: equal grow and shrink, equal waits, or your sprite drifts in size forever. Combined with last lesson's graphic effects, you now have two of the three big "make it feel polished" tools in Scratch.
- Size
- A percentage stored per-sprite. 100 is the costume's natural size. Lives in the sprite info panel and can be changed by change size by () or set size to () %.
- Costume centre
- The point inside a costume that Scratch treats as "the middle". When size changes, the sprite swells or shrinks outward from this centre. Set it with the crosshair in the paint editor.
- Pulse
- A loop that alternates growing and shrinking by the same amount, with small waits in between. The cheapest way to make a sprite look alive.
- Drift
- When a loop's grow amount and shrink amount don't match exactly, the sprite slowly creeps in one direction over time. The bug from the Mini-Challenge. Symmetry prevents it.
- Smooth pulse
- The upgraded pattern that breaks one big change into many tiny ones with a repeat, giving an eye-pleasing gradual swell instead of a snap.
Homework 2 min
The Pulsing Market. Open a fresh project. Build a tiny pasar (market) with three food sprites — pick any three from the Scratch sprite library (Cake, Donut, Bananas, anything edible). Each sprite should pulse gently, but with different timings.
- Sprite 1 pulses fast — grow/shrink by 5, wait 0.05 seconds between. Excited.
- Sprite 2 pulses calm — grow/shrink by 10, wait 0.15 seconds between. Steady.
- Sprite 3 pulses slow — grow/shrink by 15, wait 0.3 seconds between, plus a 0.5-second rest between pulses. Tired teh tarik uncle.
- Every sprite must start with set size to (100) % at flag click. Every sprite must use balanced grow and shrink amounts (no drift!).
Save as HW-L2-29-Pulsing-Market.sb3. Hit the flag and watch all three sprites pulse independently. Notice how out-of-sync they get over 30 seconds — that's a feature, not a bug. Synchronised pulses look mechanical; desynced pulses look organic.
Bring back next class:
- The
.sb3file. - Your answer to: "After running the project for 30 seconds, are any of the sprites bigger or smaller than they started? If yes, where's the drift bug? If no, how did you make sure each pair was perfectly balanced?"
Heads up for next class: SCR-L02-30 meets when backdrop switches to [Night v] — a hat block that uses backdrop changes as a trigger for sprite scripts. Together with the last two lessons, you'll have a full scene-change toolkit: change the scene, change the look, change the size.