Collision and Contact masks are both extremely important when handling collisions in SpriteKit. See the difference and how to work with them in this tutorial.
- [Narrator] So now we're going to put everything…that we've talked about bitmasks…into a practical application.…So on the screen here I have a player,…the enemy, and the item.…All three of these have physics bodies attached to them,…nothing special, their just dynamic physics bodies.…Now, what we want to do is say…that when the player shoots a laser…that it goes right through the items…because the items aren't affected by lasers.…But the lasers should kill the enemies.…
So let's look at how to set that up using our bitmasks.…Now, if you notice, if you select an item…and you look in the physics properties section,…you can see that you can set the category collision…and contact masks through numbers right here.…Personally, I would recommend against that.…I feel like it's much more confusing…using the numbers here than it is typing it out…in the code where you can attach a number to a name.…So, let's head over to the code.…
And I've written a little bit of extra code.…I have some code to reference the item on line 15,…
- 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
Game Design Careers with Brenda Romerowith Brenda Romero54m 41s Beginner
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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.