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

Think, then code

Week 14 · Unit 6: Be a storyteller · 3 lessons
3

Sprites with and without code

Computing 3: Unit 6, pp. 93–104
GoalDecide which sprites need code and which can be static objects.
New words
static object · a sprite that has no code, so it stays as it isbackdrop · the picture behind the spritescharacter · a sprite that moves, speaks or changes
Explanation

A story in Scratch has many sprites, but not every sprite needs code. A sprite with no code stays where it is and does not change. We call it a static object. A tree, a barn and the sun are often static objects. They make the scene. The characters that move, speak or change need a script. A script belongs to one sprite, and only that sprite follows it. Fewer scripts mean fewer places for mistakes. Plan with a table: sprite, does it need code, what does it do.

x 240−240y 180−180roostercowbarntreesun
Worked examples
SpriteNeeds code?What it does
Roosteryeswakes up the farm
Cowyessays “Moo!” when clicked
Barnnostays in place
Treenostays in place
Sunnostays in place
Here is the plan for a farm story. Only two sprites need code.
Roosterwhenclickedgo to x:-120y:-40wait2secondssayWake up, farm!for2secondsnext costumeCowwhen this sprite clickedsayMoo!for1secondsnext costume
The rooster and the cow each have their own script. The barn, the tree and the sun have none.
Starts by itselfwhenclickedsayHello!for2secondsStarts on a clickwhen this sprite clickedsayHello!for2seconds
Two hat blocks start scripts in different ways. The first starts when the flag is clicked. The second waits until someone clicks the sprite itself.
Class activity

Puppet theatre (in groups): draw a scene on a big sheet, such as a park with a bench, a pond, a duck and a dog. Cut out the characters. Decide which ones will have “code”: a person moves them or speaks for them. The others are glued to the backdrop and are static. Write a plan table: sprite, needs code, what it does. Then perform the story. Did a glued object ever need to move? If yes, change your plan.

Practice
1
A pond scene has a frog that says “Ribbit!” when clicked, a duck that glides across the pond, a tree and a cloud. Which sprites need code? Which are static?
frogducktreecloud
2
A sprite has no code. What does it do when the green flag is clicked?
3
This script belongs to the duck. You click the cloud. What happens?
when this sprite clickedglide2secs to x:100y:-50sayQuack!for1seconds
4
Why is it good to keep some sprites static?