Reputation: 138
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:
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
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