1.创建了物理引擎中的物体之后,施加力物体才能运动。
2.在墙的四周设置墙壁
//创建地面
b2BodyDef groundBodyDef;
groundBodyDef.type=b2_staticBody;
groundBodyDef.position.Set(0,0);
b2Body*groundBody=m_world->CreateBody(&groundBodyDef);
//属性
b2EdgeShape groundShape;
groundShape.Set(b2Vec2(0,0),b2Vec2(320/PTM_RATIO,0));
b2FixtureDef groundFixDef;
groundFixDef.shape=&groundShape;
groundBody->CreateFixture(&groundFixDef);
//设置左边的墙
b2EdgeShape leftWall;
leftWall.Set(b2Vec2(0,0),b2Vec2(0,480/PTM_RATIO));
groundFixDef.shape=&leftWall;
groundBody->CreateFixture(&groundFixDef);
//同理可以设置右面和上面的墙壁