shynjax287
shynjax287

Reputation: 138

SKNode touching other SKNode recognition

I'm creating a new game project, and this requires some basic interactions between sprites. I was wondering how to implement the SKPhysicsContact class to detect when two SKSpriteNodes touch. Here is the SKPhysicsContact class reference:

https://developer.apple.com/library/ios/documentation/SpriteKit/Reference/SKPhysicsContact/#//apple_ref/occ/instp/SKPhysicsContact/contactNormal

I'm not sure how to use the bodyA and bodyB methods to detect touches

Whenever I try to use it, I can't seem to figure out how to actually use the class. Any ideas on how to use the class to detect touches between two bodies?

Upvotes: 0

Views: 41

Answers (1)

DreamerNo56
DreamerNo56

Reputation: 213

Once your scene is a contact delegate, you will get the calls didBeginContact, and didEndContact. These methods uses both Body A and Body B to tell you whats actually colliding. From there you decide what you want to happen when they collide, for example make BodyA = nil.

Upvotes: 0

Related Questions