0
私はbox2dを使って異なる形のプロジェクトを作成しています。次のコードを使って正方形を作成しました。 'b2BodyDef bodyDef; bodyDef.type = b2_dynamicBody;cocos2d worldからb2BodyDefを取得する方法...?
bodyDef.position.Set(screenSize.width/2/PTM_RATIO,50/PTM_RATIO);
bodyDef.userData = sprite;
_sqrBody = world->CreateBody(&bodyDef);
// Define another box shape for our dynamic body.
b2PolygonShape dynamicBox;
dynamicBox.SetAsBox(.5f, .5f);//These are mid points for our 1m box
// Define the dynamic body fixture.
b2FixtureDef fixtureDef;
fixtureDef.shape = &dynamicBox;
fixtureDef.density = 10.0f;
fixtureDef.friction = 0.4f;
fixtureDef.restitution = 0.1f;
_sqrFixture = _sqrBody->CreateFixture(&fixtureDef);`
iは