iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsContact Class Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsContact

Inheritance


Conforms To


Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


Available in iOS 7.0 and later.

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.

  • bodyA bodyA Property

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

    Declaration

    Swift

    var bodyA: SKPhysicsBody! { get }

    Objective-C

    @property(nonatomic, readonly) SKPhysicsBody *bodyA

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • bodyB bodyB Property

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

    Declaration

    Swift

    var bodyB: SKPhysicsBody! { get }

    Objective-C

    @property(nonatomic, readonly) SKPhysicsBody *bodyB

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    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

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    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

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    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

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 8.0 and later.