iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsContact Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsContact

An SKPhysicsContact object is created automatically by Sprite Kit to describe a contact between two physical bodies in a physics world.

To receive contact messages, read the physicsWorld property of an SKScene object you are interested in, and assign its contactDelegate property to point to an object that implements the SKPhysicsContactDelegate protocol. Then, for each physics body in your scene, set the categoryBitMask and contactTestBitMask properties to define which interactions should generate contact messages.

  • The first body in the contact. (read-only)

    Declaration

    Swift

    var bodyA: SKPhysicsBody { get }

    Objective-C

    @property(nonatomic, readonly) SKPhysicsBody *bodyA

    Availability

    Available in iOS 7.0 and later.

  • The second body in the contact. (read-only)

    Declaration

    Swift

    var bodyB: SKPhysicsBody { get }

    Objective-C

    @property(nonatomic, readonly) SKPhysicsBody *bodyB

    Availability

    Available in iOS 7.0 and later.

  • The contact point between the two physics bodies, in scene coordinates. (read-only)

    Declaration

    Swift

    var contactPoint: CGPoint { get }

    Objective-C

    @property(nonatomic, readonly) CGPoint contactPoint

    Availability

    Available in iOS 7.0 and later.

  • The impulse that specifies how hard these two bodies struck each other in newton-seconds. (read-only)

    Declaration

    Swift

    var collisionImpulse: CGFloat { get }

    Objective-C

    @property(nonatomic, readonly) CGFloat collisionImpulse

    Availability

    Available in iOS 7.0 and later.

  • The normal vector specifying the direction of the collision. (read-only)

    Declaration

    Swift

    var contactNormal: CGVector { get }

    Objective-C

    @property(nonatomic, readonly) CGVector contactNormal

    Availability

    Available in iOS 8.0 and later.