Hey guys.
I had everything working fine with a box, which I defined as per the hello world example.
But I want to use a circle, so I create it like so:
Code:
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(pi->startPos[i].x, pi->startPos[i].y);
b2Body* body = bw->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2CircleShape circle;
circle.m_p.Set(pi->startPos[i].x, pi->startPos[i].y);
circle.m_radius = 7.0f;
//b2PolygonShape dynamicBox;
//dynamicBox.SetAsBox(7.0f, 7.0f);
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &circle;
// Set the box density to be non-zero, so it will be dynamic.
fixtureDef.density = gPuckDensity;
// Override the default friction.
fixtureDef.friction = gPuckFriction;
fixtureDef.restitution = 0.8;
When I apply force to it - exactly the same force as the box, which worked fine - it starts off going in the right direction and then moves very quickly off the bottom left of the screen! Have I left something out?? The circles also DO NOT collide with my other shapes, just roll over them.
Thanks,
Ian