- How to animate a sprite
- How to add to add sounds to Scratch
- I will be able to make a sprite move
- I will be able to make a sprite rotate
- I will be able to play a sound in Scratch
In this lesson we are going to make our sprite dance. To get them to dance, we must animate them.
In computer science, animation means making a sprite move.
Finished product
You can see a preview of the finished drawing below:
Getting started
Select Choose a Sprite at the bottom.
At the top search for "dance" to find all sprites who have dance moves. Find "Anina Dance".
Playing sound
Now we are going to add some music in the background.
First, we need to find Sound on the left side.
Now find the play sound dance magic until done block and drag it into your code.
We need to attach this block to an event block. In this case, we're going to use the when clicked block.
When we have this, attach play sound dance magic until done block to the when clicked block.
Getting our character to dance
First drag another when clicked block into your sprite and underneath it add the next costume block underneath it.
Your code should look something like:
You should see the sprite change and the music playing in the background. Each time you click the green flag you will notice that the character changes to another pose and starts dancing. Let's make her keep on dancing.
We need to add a few more next costume blocks to our character. Letβs add three so that it looks like the following.
What happened? The character only changed once. Actually, the character changes three times very quickly β too quick for us to see. We need to add in a small time delay.
Find the wait 1 seconds block within Control tab on the left side.
Now drag one in between each of the next costumes so it looks like:
Computer programs
A computer program runs in sequence. This means in Scratch that the computer will run through each block one after the other, so the order is so important.
In order to make the character dance in the right way, the order is very important.
Repeating something
Computer are designed to repeat something over and over again to save time in building programs. Computers use something called a loop to repeat something over and over again. In Scratch we can save ourselves putting in hundreds of blocks by telling the computer to repeat this over and over again.
Find the Control tab on the left side and look for the repeat 10 times block.
Now place your block under a new when clicked block and then drag our blocks into it so that everything we have just created is inside that block and your blocks look like this:
Making the characters stop when the music stops
Did you notice that your character continues to dance when the music stops?
To fix this, change your blocks so that they look like the example shown on the right-hand side (note you will need to remove one of the next costume blocks too).
When you have done this, you should notice that your character stops dancing when the music stops. Can you think why?
Making the background change colour
We can also make the background look a bit more like a rave or disco by adding in a colour effect. First click on the backdrop on the right-hand side and then add the following blocks to the backdrop.
Stopping the animation
One block we have not come across yet is the stop all block.
To stop our animation running and to stop the background changing once the music has stopped, we need to use this block. In your Anina Dance sprite, we need to add the stop all block after the music stops so that it looks like:
-
1
Upload your screenshot below:
-
2
What word best describes the difference between a game and an animation?
-
3
The following code is added to a program. How many times will the sprite change costume?
-
4
The following blocks are used in a Scratch program.
Notice that the next costume block is used three times. How could this be made more efficiently using loops?
-
5
What would happen if the wait blocks were removed from the program?
-
6
How well do think you completed this task?
-
7
What parts of this task, if any, did you struggle with?
- Try adding another character, such as "Jouvi Dance", and make them dance too.
- Try adding in another backdrop into your animation and see if you can work out how to change to that based on what you have learned so far.