Game Development Reference
In-Depth Information
contactListener = new ContactListener();
world- > SetContactListener(contactListener);
debugDraw = new GLESDebugDraw(PTM_RATIO);
world- > SetDebugDraw(debugDraw);
uint32 flags = 0;
flags + = b2Draw::e_shapeBit;
flags + = b2Draw::e_jointBit;
// flags + = b2Draw::e_aabbBit;
// flags + = b2Draw::e_pairBit;
// flags + = b2Draw::e_centerOfMassBit;
debugDraw- > SetFlags(flags);
// Define the ground body.
b2BodyDef groundBodyDef;
// Call the body factory which allocates memory for the ground body
// from a pool and creates the ground box shape (also from a pool).
// The body is also added to the world.
b2Body* groundBody = world- > CreateBody(&groundBodyDef);
// Define the ground box shape.
CGSize screenSize = [CCDirector sharedDirector].winSize;
float boxWidth = screenSize.width / PTM_RATIO;
float boxHeight = screenSize.height / PTM_RATIO;
b2EdgeShape groundBox;
int density = 0;
// left
groundBox.Set(b2Vec2(0, boxHeight), b2Vec2(0, 0));
b2Fixture* left = groundBody- > CreateFixture(&groundBox, density);
// right
groundBox.Set(b2Vec2(boxWidth, boxHeight), b2Vec2(boxWidth, 0));
b2Fixture* right = groundBody- > CreateFixture(&groundBox, density);
// set the collision flags: category and mask
b2Filter collisonFilter;
collisonFilter.groupIndex = 0;
Search Nedrilad ::




Custom Search