我有三个 b2Body-s。头部、下巴和一个静态类型的 b2Body。我将静态 b2Body 中的 b2Joint 添加到头部,将另一个 b2Joint 添加到头部和下巴。Head 忽略静态体,因为 collideConnected 对关节为 false,但 chin 不会忽略它。怎么做这个?请提出建议。
问问题
115 次
1 回答
1
enum CATEGORY_BITS
{
BODY1_CATEGORY_BITS = 0x00000001,
BODY2_CATEGORY_BITS = 0x00000002,
BODY3_CATEGORY_BITS = 0x00000004,
};
当你创造身体时......
b2FixtureDef fixtureForBODY1;
fixtureForBODY1.shape = &shapeForBODY1;
fixtureForBODY1.filter.categoryBits = BODY1_CATEGORY_BITS;
fixtureForBODY1.filter.maskBits = BODY1_CATEGORY_BITS | BODY3_CATEGORY_BITS;
b2FixtureDef fixtureForBODY2;
fixtureForBODY2.shape = &shapeForBODY2;
fixtureForBODY2.filter.categoryBits = BODY2_CATEGORY_BITS;
fixtureForBODY2.filter.maskBits = BODY2_CATEGORY_BITS | BODY4_CATEGORY_BITS;
b2FixtureDef fixtureForBODY3;
fixtureForBODY3.shape = &shapeForBODY3;
fixtureForBODY3.filter.categoryBits = BODY3_CATEGORY_BITS;
fixtureForBODY3.filter.maskBits = BODY3_CATEGORY_BITS | BODY1_CATEGORY_BITS;
b2FixtureDef fixtureForBODY4;
fixtureForBODY4.shape = &shapeForBODY4;
fixtureForBODY4.filter.categoryBits = BODY4_CATEGORY_BITS;
fixtureForBODY4.filter.maskBits = BODY4_CATEGORY_BITS | BODY2_CATEGORY_BITS;
// BODY1 -> not collide connected (BODY2 and BODY4)
// BODY1 -> collide connected (BODY1 and BODY3)
于 2013-04-06T13:33:17.323 回答