Programming for Children
Primary 4 · Science and Elementary Technology
Programming for Children
Lesson 4 of 5
16 min
Let's begin
Ishimwe wants to make a cartoon: a rocket flies through space towards the Earth while a monkey in a space helmet spins slowly. "Can I make that?" he asks. Yes, with animation!
An animation is a set of pictures that change little by little, so things seem to move. In Scratch, you animate a sprite by moving it, turning it or changing its costume.
Click the rocket and build this script:
when green flag clicked
go to x: -150 y: -150
say Let's go! for 2 seconds
point towards Earth
glide 1 secs to x: 0 y: 0
x tells how far left or right the sprite is, and y how far up or down. The middle of the stage is x: 0, y: 0.
Another way to animate is a loop: repeat 200 [ move 2 steps ]. Lots of tiny moves look like one smooth flight.
Add the Monkey sprite and give it: when green flag clicked, forever [ turn 1 degrees ]. A forever loop never ends, so click the stop sign to stop it.
Many sprites have several costumes, for example a cat with its legs in different places. Switch between them to make it walk:
forever [ next costume, move 10 steps, wait 0.2 seconds ]
The wait block slows it down so your eyes can see each costume.
The stage can have its own code too. Click the stage (under the backdrop button), add a second backdrop, and use Looks blocks:
For example: when green flag clicked, switch backdrop to Stars, wait 5 seconds, switch backdrop to Moon. A sprite can react with the Events block when backdrop switches to Moon.
Tip
Move, turn, change: three ways to animate
Move it, turn it, or change its costume, and put a wait in the loop so your eyes can keep up.
Try each one first, then tap Show answer to check.
What is the difference between a costume and a backdrop?
Answer: A costume is one look of a sprite; a backdrop is the picture behind all the sprites on the stage.
Keza's cat changes costume so fast that it just flickers. What should she add?
Answer: A wait block (for example wait 0.2 seconds) inside the loop.
Which block makes a sprite spin for as long as the program runs?
Answer: forever [ turn 1 degrees ].
Write a stage script that shows the Stars backdrop and then, after 3 seconds, the next backdrop.
Answer: when green flag clicked, switch backdrop to Stars, wait 3 seconds, next backdrop.
What you learned today
Sources and credits
The exercises (Try it yourself and the practice questions) are written by Ganzaa. The costume and backdrop parts of this lesson are written by Ganzaa. Scratch is a free project of the Scratch Foundation, at scratch.mit.edu.
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.
Quick check