ISKPhysicsContactDelegate Interface
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A delegate object for SKPhysicsWorld that provides events when SKPhysicsBodys begin and end contact with each other.
[Foundation.Protocol(Name="SKPhysicsContactDelegate", WrapperType=typeof(SpriteKit.SKPhysicsContactDelegateWrapper))]
[Foundation.ProtocolMember(IsProperty=false, IsRequired=false, IsStatic=false, Name="DidBeginContact", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(SpriteKit.SKPhysicsContact) }, Selector="didBeginContact:")]
[Foundation.ProtocolMember(IsProperty=false, IsRequired=false, IsStatic=false, Name="DidEndContact", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(SpriteKit.SKPhysicsContact) }, Selector="didEndContact:")]
public interface ISKPhysicsContactDelegate : IDisposable, ObjCRuntime.INativeObject
[<Foundation.Protocol(Name="SKPhysicsContactDelegate", WrapperType=typeof(SpriteKit.SKPhysicsContactDelegateWrapper))>]
[<Foundation.ProtocolMember(IsProperty=false, IsRequired=false, IsStatic=false, Name="DidBeginContact", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(SpriteKit.SKPhysicsContact) }, Selector="didBeginContact:")>]
[<Foundation.ProtocolMember(IsProperty=false, IsRequired=false, IsStatic=false, Name="DidEndContact", ParameterByRef=new System.Boolean[] { false }, ParameterType=new System.Type[] { typeof(SpriteKit.SKPhysicsContact) }, Selector="didEndContact:")>]
type ISKPhysicsContactDelegate = interface
interface INativeObject
interface IDisposable
- Derived
- Attributes
- Implements
Remarks
The following example reverses gravity when a SKPhysicsBody named "Sphere" encounters one of the bodies named either "TopWall" or "BottomWall":
public override void DidBeginContact(SKPhysicsContact contact)
{
if(contact.BodyA.Node.Name == "Sphere" || contact.BodyB.Node.Name == "Sphere")
{
if(contact.BodyA.Node.Name == "BottomWall" || contact.BodyB.Node.Name == "BottomWall" || contact.BodyA.Node.Name == "TopWall" || contact.BodyB.Node.Name == "TopWall")
{
world.Gravity = new CGPoint(0, -world.Gravity.Y);
}
}
}
Properties
| Name | Description |
|---|---|
| Handle |
Handle (pointer) to the unmanaged object representation. (Inherited from INativeObject) |
Methods
| Name | Description |
|---|---|
| DidBeginContact(SKPhysicsContact) |
Method that is called when contact is started. |
| DidEndContact(SKPhysicsContact) |
Method that is called after contact ends. |
Extension Methods
| Name | Description |
|---|---|
| GetHandle(INativeObject) | |
| GetNonNullHandle(INativeObject, String) | |
| DidBeginContact(ISKPhysicsContactDelegate, SKPhysicsContact) |
Method that is called when contact is started. |
| DidEndContact(ISKPhysicsContactDelegate, SKPhysicsContact) |
Method that is called after contact ends. |