AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Animating with forever

Week 2 · Unit 1: Be an animator · 3 lessons
1

The forever block

Computing 4: Unit 1, pp. 8–19
GoalUse the forever block in a Scratch program and say what it does when the green flag is clicked.
New words
forever block · a Scratch block that repeats the blocks inside it until you stop the programcostume · one of the pictures a sprite can wearsprite · a character or object in a Scratch program
Explanation

In Scratch, the forever block is in the Control group. The blocks inside its mouth repeat over and over until you click the red stop button. A sprite can have many costumes, which are slightly different pictures of the sprite. The block “next costume” changes to the next picture in the list, and after the last picture it goes back to the first one. Put “next costume” and a short wait inside a forever loop, and the sprite seems to move. Without the wait, the pictures change so fast that you cannot see them. A forever block has no notch at the bottom, so no block can be fixed underneath it.

whenclickednext costumewait0.5secondsforever
Worked examples
startafter 1after 2after 3after 4
A moon sprite has 3 costumes: new moon, crescent moon and full moon. It starts on costume 1. Each time “next costume” runs, it moves on one costume and goes back to the first after the last. After 4 uses, the moon shows the crescent.
whenclickedset size to130%wait0.3secondsset size to100%wait0.3secondsforever
A heart sprite beats like a pulse. It is big for 0.3 seconds, then normal for 0.3 seconds, and again and again. One full round takes 0.6 seconds, so in 3 seconds it makes 5 rounds.
Script 1whenclickednext costumewait0.5secondsforeverScript 2whenclickedturn ↻10degreeswait0.1secondsforever
One forever loop never ends, so a second job cannot wait underneath it. To do two jobs at the same time, use two scripts that both start with “when green flag clicked”. Here the sprite changes costume and turns at the same time.
Class activity

Be the loop (with a friend): draw a flower on three small cards: a bud, half open and fully open. Stack the cards with the bud on top. One person is the forever block. Show the top card for two counts, then move it to the bottom of the stack so the next card shows. Keep going until your partner calls “Stop!”. Before you start, guess which card will be showing after 7 changes, then check. If you have a computer or tablet, put “next costume” and “wait” inside a forever block for a sprite with several costumes.

Practice
1
A plant sprite has 3 costumes and starts on costume 1. Which costume shows after “next costume” has run 5 times?
costume 1costume 2costume 3
2
How long does one full round of this loop take?
whenclickedset size to80%wait0.5secondsset size to100%wait0.5secondsforever
3
Why does a loop that changes costumes need a wait block?
4
Which script keeps changing costume until you stop it? What does the other script do?
Script Awhenclickednext costumewait1secondsScript Bwhenclickednext costumewait1secondsforever