b2Vec2 gravity;
//设置世界重力加速度为10,-向下,+向上
gravity.Set(0.0f, -10.0f);
world = newb2World(gravity);
//物体静止时,允许睡眠,不被纳入世界计算,这样提高性能
world->SetAllowSleeping(true);
world->SetContinuousPhysics(true);
//Define the grounp body 世界是有边界的
//保存构造刚体数据
b2BodyDef groundBodyDef;
//刚体(0,0)点坐标在左下角
groundBodyDef.position.Set(0,0);
//创建刚体
b2Body *groundBody = world->CreateBody(&groundBodyDef);
//define the ground box shape
//一个线段(边缘)的形状.这些可以在链或环连接其他边缘形状。使用连接信息,以确保正确的接触法线。
b2EdgeShape groundBox ;
//bottom
groundBox.Set(b2Vec2(0,0), b2Vec2(960 /PTM_RATIO,0));
groundBody->CreateFixture(&groundBox,0);
//top
groundBox.Set(b2Vec2(0,640 / PTM_RATIO),b2Vec2(960 /PTM_RATIO,640/PTM_RATIO));
groundBody->CreateFixture(&groundBox,0);
//left
groundBox.Set(b2Vec2(0,640 / PTM_RATIO),b2Vec2(0,0));
groundBody->CreateFixture(&groundBox,0);
//right
groundBox.Set(b2Vec2(960 /PTM_RATIO, 640 /PTM_RATIO), b2Vec2(960 /PTM_RATIO,640/PTM_RATIO));
groundBody->CreateFixture(&groundBox,0);