2
任何人都知道如何將2個圓形夾具添加到一個具有所需定位的b2body? 我知道如何使用m_centroid
將兩個多邊形夾具添加到一個物體。但我怎樣才能做到圈裝置。Cocos2d Box2d多個b2circle形狀夾具一體定位
任何答案將不勝感激。我想把一些物體粘在一起。我試過關節,但都是彈性的。我想要距離靜態。
謝謝大家!
任何人都知道如何將2個圓形夾具添加到一個具有所需定位的b2body? 我知道如何使用m_centroid
將兩個多邊形夾具添加到一個物體。但我怎樣才能做到圈裝置。Cocos2d Box2d多個b2circle形狀夾具一體定位
任何答案將不勝感激。我想把一些物體粘在一起。我試過關節,但都是彈性的。我想要距離靜態。
謝謝大家!
你應該創建兩場比賽對你的身體和這些燈具的形狀應該是b2CircleShape
//Create a body. You'll need a b2BodyDef, but I've assumed you know how to use these since you say you've created bodies successfully before.
b2Body* body = world->CreateBody(&bodyDef);
//Create the first circle shape. It's offset from the center of the body by -2, 0.
b2CircleShape circleShape1;
circleShape1.m_radius = 0.5f;
circleShape1.m_p.Set(-2.0f, 0.0f);
b2FixtureDef circle1FixtureDef;
circle1FixtureDef.shape = &circleShape1;
circle1FixtureDef.density = 1.0f;
//Create the second circle shape. It's offset from the center of the body by 2, 0.
b2CircleShape circleShape2;
circleShape2.m_radius = 0.5f;
circleShape2.m_p.Set(2.0f, 0.0f);
b2FixtureDef circle2FixtureDef;
circle2FixtureDef.shape = &circleShape2;
circle2FixtureDef.density = 1.0f;
//Attach both of these fixtures to the body.
body->CreateFixture(&circle1FixtureDef);
body->CreateFixture(&circle2FixtureDef);
真棒! m_p就是我正在尋找的! – locrizak