Game Development Reference
In-Depth Information
How to do it…
Now we will open our working project again to integrate and implement all types of joints
in our project. The following steps will provide the step-by-step ways to implement the
joints and understand them in more depth.
1. To implement the pin joint, open the GameScene.m file and add the following
function in it:
-(void)createPinJointOnScene:(SKScene*)scene
{
//Adding Rectangle
SKSpriteNode* backBone = [[SKSpriteNode alloc]
initWithColor:[UIColor whiteColor] size:CGSizeMake(20,
200)];
backBone.position =
CGPointMake(CGRectGetWidth(self.frame)/2.0,
CGRectGetHeight(self.frame)/2.0);
backBone.physicsBody = [SKPhysicsBody
bodyWithRectangleOfSize:backBone.size];
backBone.physicsBody.categoryBitMask =
GFPhysicsCategoryRectangle;
backBone.physicsBody.collisionBitMask =
GFPhysicsCategoryWorld;
[scene addChild:backBone];
//Adding Square
SKSpriteNode* head = [[SKSpriteNode alloc]
initWithColor:[SKColor grayColor] size:CGSizeMake(40,
40)];
head.position = CGPointMake(backBone.position.x+5,
backBone.position.y-40);
head.physicsBody = [SKPhysicsBody
bodyWithRectangleOfSize:head.size];
head.physicsBody.categoryBitMask =
GFPhysicsCategorySquare;
head.physicsBody.collisionBitMask =
GFPhysicsCategoryWorld;
[scene addChild:head];
Search WWH ::




Custom Search