In this post, you will be learning about the basics of animation. We recommend you read our introduction to blocks before exploring this introduction to animation.
There are different types of animation, which make your sprites look like they are moving around. Let’s start off with a few of the basic ones.
1. Animating by costume:
To animate by costume, upload a sprite from the Scratch library. Most of the sprites will come with their own costumes. To animate a sprite this way, all you have to do is write a script where if, for example the green flag is clicked, the sprite changes between costumes. Make sure to add the delay! Otherwise, your sprite will move very fast.
Here’s an example of how to write your script:
There are a couple ways you can animate talking. The first is a simple, when green flag clicked, say (hello) for (2) seconds script. If you want to make your animation more detailed, you can animate the mouth of your character to move while it talks. This is possible with the costumes your sprite comes with. Because all sprites may not come with a speech costume, you might need to make your own sprite or costume.
We used the penguin sprite for our speech animation. Here’s our code:
Notice that we kept the speech part and the animation of the penguin separate. This is because we wanted both happening at the same time, not one after another. That way, it looks like the penguin is moving its mouth while it says the message.
3. Making Your Sprite Move
3a. Jumping: You can have your sprite jump up and down as an animation. What axis changes when the sprite moves up and down? That’s right, the y-axis! The code for this animation is based on the y-axis and how the sprite moves along it. See if you can figure it out yourself. If not, our code is below.
See how our x-axis stays the same even though the y-axis changes? This is because we don’t want the sprite to move left to right, only up and down in a jumping motion. Also, notice that we didn’t add a delay to our code this time. Why do you think we did that?
3b. Gliding: Gliding is probably the easiest animation. All you have to do is enter the coordinates you would like your sprite to go to, and how long it should take to get there. If you don’t have a specific coordinate (or place) you want your sprite to go to, you can also plug in the random position block, like how we did it:
3c. Moving with arrow keys: The goal of this is to allow your sprite to move left and right with your arrow keys. What changes on the coordinate plane when you move from left to right? Yup, the x-axis! That’s the purpose of this code: to change x by a certain amount every time an arrow key is pressed. Go ahead and try it out on your own!
Here’s how we did it:
4. Changing Color: This one is pretty easy too, and can be done in a matter of seconds. To change your sprite’s color, find the change color effect by ( ) block in the looks section of Scratch.
This is how we did it:
Now that you know a couple different types of animation, go ahead and try to make a program of your own! It can be a story about anything, from dancing dinosaurs and dragons, to a taco wizard exploring a new food truck. Remember, there’s no wrong way to create your story.