SpriteKit.SKPhysicsContactDelegate Class
A delegate object for SpriteKit.SKPhysicsWorld that provides events when SpriteKit.SKPhysicsBodys begin and end contact with each other.

See Also: SKPhysicsContactDelegate Members

Syntax

[Foundation.Model]
[Foundation.Protocol]
[Foundation.Register("SKPhysicsContactDelegate", false)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.iOS_7_0)]
[ObjCRuntime.Availability(Introduced=ObjCRuntime.Platform.Mac_10_0 | ObjCRuntime.Platform.Mac_10_1 | ObjCRuntime.Platform.Mac_10_2 | ObjCRuntime.Platform.Mac_10_3 | ObjCRuntime.Platform.Mac_10_4 | ObjCRuntime.Platform.Mac_10_5 | ObjCRuntime.Platform.Mac_10_6 | ObjCRuntime.Platform.Mac_10_7 | ObjCRuntime.Platform.Mac_10_8 | ObjCRuntime.Platform.Mac_10_9 | ObjCRuntime.Platform.Mac_10_10 | ObjCRuntime.Platform.Mac_Version | ObjCRuntime.Platform.Mac_Arch64 | ObjCRuntime.Platform.Mac_Arch)]
public class SKPhysicsContactDelegate : Foundation.NSObject, ISKPhysicsContactDelegate, IDisposable

Remarks

The following example reverses gravity when a SpriteKit.SKPhysicsBody named "Ball" encounters one of the bodies named either "TopWall" or "BottomWall":

C# Example

public override void DidBeginContact(SKPhysicsContact contact)
{
	if(contact.BodyA.Node.Name == "Ball" || contact.BodyB.Node.Name == "Ball")
	{
		if(contact.BodyA.Node.Name == "BottomWall" || contact.BodyB.Node.Name == "BottomWall" || contact.BodyA.Node.Name == "TopWall" || contact.BodyB.Node.Name == "TopWall")
		{
			world.Gravity = new PointF(0, -world.Gravity.Y);
		}
	}
}        
          

Related content

Requirements

Namespace: SpriteKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0