Game Development Reference
In-Depth Information
b2PolygonShape box;
box.SetAsBox(20 /PTM_RATIO, 20 / PTM_RATIO);
//Define fixture
b2FixtureDef fixtureDef;
fixtureDef.shape = &box;
fixtureDef.density = 2;
fixtureDef.restitution = 0;
body->CreateFixture(&fixtureDef);
Note that you use the world object to create the bodies. And also note that boxes are cre-
ated with half their desired width and height.
Density, friction, and restitution all have default values, so you don't always need to set
these.
Search WWH ::




Custom Search