iOS Developer Library

Developer

SpriteKit Framework Reference SKPhysicsContactDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

SKPhysicsContactDelegate

Inheritance


Not Applicable

Import Statement


Swift

import SpriteKit

Objective-C

@import SpriteKit;

Availability


Available in iOS 7.0 and later.

An object that implements the SKPhysicsContactDelegate protocol can respond when two physics bodies are in contact with each other in a physics world. To receive contact messages, you set the contactDelegate property of a SKPhysicsWorld object. The delegate is called when a contact starts or ends.

  • Called when two bodies first contact each other.

    Declaration

    Swift

    optional func didBeginContact(_ contact: SKPhysicsContact)

    Objective-C

    - (void)didBeginContact:(SKPhysicsContact *)contact

    Parameters

    contact

    An object that describes the contact.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.

  • Called when the contact ends between two physics bodies.

    Declaration

    Swift

    optional func didEndContact(_ contact: SKPhysicsContact)

    Objective-C

    - (void)didEndContact:(SKPhysicsContact *)contact

    Parameters

    contact

    An object that describes the contact.

    Import Statement

    Objective-C

    @import SpriteKit;

    Swift

    import SpriteKit

    Availability

    Available in iOS 7.0 and later.