Game Development Reference
In-Depth Information
4. Now we will implement the fixed joint; open the GameScene.m file, and add
the following function to implement the fixed joint:
-(void)createFixedJointOnScene:(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 =
Search WWH ::




Custom Search