SKPhysicsWorld.AddJoint(SKPhysicsJoint) Method

Definition

T:SpriteKit.SKPhysicsJoint

[Foundation.Export("addJoint:")]
public virtual void AddJoint (SpriteKit.SKPhysicsJoint joint);
abstract member AddJoint : SpriteKit.SKPhysicsJoint -> unit
override this.AddJoint : SpriteKit.SKPhysicsJoint -> unit

Parameters

joint
SKPhysicsJoint

The SKPhysicsJoint to be added.

Attributes

Remarks

The SKNodes whose PhysicsBodys are associated with the joint must be added to the SKScene before calling this method, or a segfault will result. The following example demonstrates the necessary order:


var joint = SKPhysicsJointFixed.Create(node1.PhysicsBody, node1.PhysicsBody, node1.Position);
//mySkScene.PhysicsWorld.AddJoint(joint); //NO. This will segfault if node1 or node2 not in mySkScene
mySkScene.AddChild(node1);
mySkScene.AddChild(node2);
mySkScene.PhysicsWorld.AddJoint(joint); //This works              

Applies to