Collisions allow you to detect when one object runs into another, which is one of the most vital parts of most games. In our game, we want a collision to be detected when the rock lands on the cat's head. When that happens, we want the game to be over and the player to lose the game. This movie shows how that is done for our cat game.
- [Voiceover] So right now, the rocks move…and you can control the cat, but…there's no connection between…the rocks and the cat.…So what we're going to do…is add some code to detect collisions…between the rocks and the cat,…and stop the game when those collisions happen.…So, to do that, I'm going to…start in the rock so I have…the rock sprite selected,…and I'm in the scripts panel and I'm…looking at the rock scripts.…So what we want to do…is check to see in our forever loop…if the rock is touching the cat.…
So, we'll go over to control…and find if/then and just drag that out…underneath the if/why position block and…inside the forever loop…and then we'll head over to sensing.…And we want to see if…it's touching another object.…So I'm going to drag out this touching 1…and then change this in the dropdown…to sprite 1.…So, if it's touching sprite 1,…then what we want to do is…bring the rock to the front.…We want the rock to be…in front of the cat in that case,…and then we want to…basically stop the game.…
Have the cat say "Ow,"…
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
Skill Level Beginner
Teaching iOS Programming to Kidswith Todd Perkins1h 2m Beginner
Teach Kids Programming with PHPwith Mark Niemann-Ross1h 39m Beginner
1. Get Started with Scratch
5. Build a Game
Next steps2m 36s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.