The first bit of logic, or interactivity in the game is going to be making the character walk. Walking involves two processes- changing the sprite's costume to perform the walking animation, and actually moving and rotating the sprite on the screen. In this movie, add the scripts that will make the cat move, rotate, and animate on the screen so he can walk using the keyboard.
- View Offline
- [Voiceover] Let's start with making the cat walk.…Make sure you have the cat sprite selected.…So I'm on sprite1 right here.…And then what I want to do is head over…to the Events scripts.…Then I'm going to drag out when green flag is clicked.…I'm going to do this actually twice.…One group of actions is going to handle…the movement of the sprite.…And then one group of actions is going to handle…the changing of costumes of the sprite.…So let's head over to Control.…
And I'm going to drag a forever loop…under each of these events.…Then I'm going to drag two if-thens…into the top one.…The top one is going to be the one…that handles the key presses.…So it's going to say, if you're pressing…the left arrow, then move to the left.…If you're pressing the right arrow,…then move to the right.…And then I'm going to drag…an if-then inside of the bottom forever loop.…This is the one that's going to check…to see if any key is pressed at all,…then change the costume of the cat.…
So let's head over to Sensing.…So now we want to check to see…
He starts with demonstrating how to create your first project and gather the artwork (aka sprites) and other assets you'll need to build it. Todd then reviews the prebuilt scripts, the bits of code that control the logic of your Scratch projects, and explains how to use the different script types for different functions, such as animating sprites, responding to events such as button clicks, and comparing values. In chapter 3, he covers costumes, and in chapter 4, he shows how to load and play sounds. Finally, he shows how to put it all together into a complete web game, which you can then share with the Scratch community.
- What is Scratch?
- Creating your first project
- Choosing a backdrop for your application
- Creating sprites (reusable graphics) in Scratch
- Working with scripts: animating objects, responding to events, and checking logic
- Switching sprite costumes
- Changing the appearance of sprites with custom-drawn costumes
- Playing sounds
- Building a game with Scratch