Game Development Reference
In-Depth Information
ccp(halfTileSize, halfTileSize),
ccp(halfTileSize, -halfTileSize),
};
// Create a static body
cpBody* staticBody = cpBodyNew(INFINITY, INFINITY);
staticBody-> p = pos;
CGPoint offset = CGPointZero;
cpShape* shape = cpPolyShapeNew(staticBody, numVertices, vertices, offset);
cpSpaceAddStaticShape(space, shape);
// Create three new dynamic bodies
float posOffset = 1.4f;
pos.x + = TILESIZE * posOffset;
cpBody* bodyA = cpBodyNew(mass, moment);
bodyA-> p = pos;
cpSpaceAddBody(space, bodyA);
shape = cpPolyShapeNew(bodyA, numVertices, vertices, offset);
cpSpaceAddShape(space, shape);
PhysicsSprite* spriteA = [self createPhysicsSpriteAt:pos];
[spriteA setPhysicsBody:bodyA];
bodyA-> data = (__bridge void*)spriteA;
pos.x + = TILESIZE * posOffset;
cpBody* bodyB = cpBodyNew(mass, moment);
bodyB-> p = pos;
cpSpaceAddBody(space, bodyB);
shape = cpPolyShapeNew(bodyB, numVertices, vertices, offset);
cpSpaceAddShape(space, shape);
PhysicsSprite* spriteB = [self createPhysicsSpriteAt:pos];
[spriteB setPhysicsBody:bodyB];
bodyB-> data = (__bridge void*)spriteB;
Search Nedrilad ::




Custom Search