Collision detection is one of the most crucial parts of a physics engine. This tutorial shows how to detect collisions in SpriteKit.
- [Instructor] Physics really starts to get interesting…when you introduce collision detection.…Now when I say collision detection,…I mean being able to respond with code,…when certain objects collide with each other.…Let's set it up.…So I'm in here in GameScene.swift and I'm going to implement…the SK physics delegate protocol.…So, I'll need to type a comma after SKScene on line 12,…so in order to handle collisions, we need to say…that our class can handle collisions,…or in other words, it can be a physics contact delegate.…
So I'll type that out there,…and then inside didMovetoview, I'm going to go…above where I set the player,…and I'm going to type self physics world,…this is settings for the physics world,….contactdelegate, and I'm going to set that…equal as self.…So, these are two things that are required…to handle collision.…Finally what we need to do is actually run the method…that handles collisions.…
This is a method that comes from SK physics contact delegate…for all the methods that come with that,…you can always click in there,…
- 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.