This is a step to step guide, explaining how to animate a sprite in Scratch. In this post, in the end, we will achieve an animated sprite, which can move eat, and change colour. Before we begin, you will need an account in Scratch. If you don’t have one then, head to how to create an account in scratch.
What Is A Sprite In Scratch
A sprite is a synonym for a character, and is used In Scratch to symbolise a character.
Choose Your Sprite To Animate
Click the icon above to choose a new sprite:
Then, select your pet:
You can delete the cat with the scissors tool. Click on the scissors, then click on the cat:
Or, use the right-click menu (CTRL+click on Mac), and choose ‘delete’.
Choose a Backdrop
Choose where your pet will live.
Click the icon above to open the Backdrop library:
Then choose the backdrop you want for your pet, such as garden rock:
Introduce Your Pet
Move your pet where you want it to start.
Use the go-to block to set that position:
Tip: You can find the x and y value of any point on the Scratch stage by moving your mouse pointer. Look at the x y below the stage:
Have your pet make a sound when you click it.
Click the Sounds tab as mentioned above, then click.
Add a script that plays this sound when you click on your pet.
You can also have your pet say something when you click on it.
Animate Your Pet
Click the Costumes tab.
If your pet has more than one costume, you can animate it by using the switch costume block.
Tip: To add a costume to an animation, click with the Duplicate tool. Then use the drawing tools to edit it.
Time to Eat
Give your pet something to eat.
Click to choose a new sprite:
Then, select food:
To tell your pet when the food sprite is clicked, go to Events, and drag in a when sprite clickedblock. Then, snap on a broadcast block. Choose ‘new message’ from the menu and type in ‘food.’
Now, whenever you click on the food sprite, it will send a message to your pet.
Tip: Add the go-to front block to place your food sprite in front of the pet.
Eat Some Food
Decide what your pet will do when it receives the ‘food’ message.
Go to the Events category and drag out a when I receive a block.
To make your pet glide toward the food, click on the Motion category. Use the glide block to tell your pet where you want it to go.
Tip: You can type in an x and y position. Or drag your pet to where you want it to go, and the x and y within glide (in the blocks palette) will automatically update.
Add another glide block at the end of the script to make your pet go back to its original position.
Time to Play
Choose something for your pet to play with, such as a trampoline.
Go to Events. Drag in a when sprite clicked the block. Then add a broadcast block. Choose ‘new message’ and call it ‘play.’
Now decide what your pet will do when it receives the ‘play’ message. For example, you can have your pet jump up and down.
Click to select your pet
Here’s a script that glides to a trampoline and jumps:
Add More Activities
What else do you want your pet to do? You can use broadcast and receive blocks to add other activities.
Here are a couple of ideas. Feel free to experiment.
Play a musical instrument:
Choose a drum and add a script for your pet to play it:
Drink some water:
Monitor Your Pet
You can use variable blocks to monitor how your pet is feeling.
For example, to monitor if your pet is hungry, go to Data and click on ‘Make a Variable.’ Type in something like ‘Hungry.’
You can use a script like this so that your pet gets hungrier over time:
To make it less hungry, add this block to the ‘when I receive food’ script:
You could also monitor if your pet is thirsty, sleepy, or bored.
If you want more information, go to https://en.scratch-wiki.info/wiki/Animating_a_Sprite .