Make a sprite grow and shrink
Combine repeat and changeSize inside a forever loop to create a smooth pulsing animation.
whenGreenFlag(() => { forever(() => { repeat(10, () => { changeSize(5); wait(0.05); }); repeat(10, () => { changeSize(-5); wait(0.05); }); });});The sprite grows by 5% ten times, then shrinks by 5% ten times — back to its original size — and repeats forever. Adjust the numbers to change how big it gets and how fast it pulses.
Functions used
Section titled “Functions used”whenGreenFlag— run code when the green flag is clickedforever— repeat a block of code indefinitelyrepeat— run a block of code a fixed number of timeschangeSize— change this sprite’s size by an amountwait— pause the script for a number of seconds