Hey, I just ported (read renamed the function CreateShape) my code to the fixture method, however there's no collision between bodies anymore:
Code:
b2Body* Physics::createBox( float x, float y, float width, float height, float density, float friction, float restitution, bool movable )
{
b2BodyDef bodyDef;
bodyDef.position.Set( x, y );
b2Body* body = world->CreateBody( &bodyDef );
b2PolygonDef shapeDef;
shapeDef.SetAsBox( width / 2, height / 2 );
shapeDef.density = density;
shapeDef.friction = friction;
shapeDef.restitution = restitution;
body->CreateFixture( &shapeDef );
if ( movable ) { body->SetMassFromShapes( ); }
return body;
}
{
b2BodyDef bodyDef;
bodyDef.position.Set( x, y );
b2Body* body = world->CreateBody( &bodyDef );
b2PolygonDef shapeDef;
shapeDef.SetAsBox( width / 2, height / 2 );
shapeDef.density = density;
shapeDef.friction = friction;
shapeDef.restitution = restitution;
body->CreateFixture( &shapeDef );
if ( movable ) { body->SetMassFromShapes( ); }
return body;
}