See how to handle collisions and to respond appropriately when you have many different types of objects in this tutorial.
- [Instructor] Our next step is to look at exactly…which objects made contact with each other…and to respond accordingly.…So the first thing that we need is a category…to which the objects belong.…So above this removeFromParent code,…I'm going to find two constants.…Number one is going to be for category A.…I'll call that cA.…That's a UInt32.…32 bit integer.…I'll set that equal to contact.bodyA.categoryBitMask.…
So we know what category this object is in.…Same thing for the next line.…Just going to copy and paste this line of code,…change cA to cB and bodyA to bodyB.…So now we have the category for the first body right here,…and a category for bodyB right here.…So now the step is to check to see which category it was.…So we want to see if one of these was the player.…So if cA is equal to playerCategory,…or cB is equal to playerCategory,…so if so, we know one of these objects was the player.…
And now we want to figure out which one was not the player.…So I'll create another constant, we'll call this one…otherNode, and this is going to be an SKNode.…
- Creating a SpriteKit project
- Adding and modifying sprites
- Creating sprites in code
- Transitioning between scenes
- Working with children and parents
- Adding physics
- Detecting and responding to collisions
- Applying particle effects
- Creating actions
- Working with sound
- Adding cameras and lights
Skill Level Intermediate
Careers in the Game Industrywith Christian Bradley1h 19m Beginner
Building a Game App with the Android SDKwith David Gassner2h 6m Intermediate
1. Introduction to SpriteKit
2. Add Physics
3. Work with Particle Effects
4. Work with Actions
5. Work with Audio
6. Additional Features
Next steps1m 41s
- 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.