使用box2D删除正文

时间:2013-12-18 11:24:58

标签: cocos2d-iphone box2d box2d-iphone

我需要从我的世界范围中删除某个矢量,例如只删除左边的矢量。 (box2d + cocos2d iphone)

这是我设置界限的方式:

screenBorderShape.Set(lowerLeftCorner, lowerRightCorner);
screenBorderBody->CreateFixture(&screenBorderShape, 0);
screenBorderShape.Set(lowerRightCorner, upperRightCorner);
screenBorderBody->CreateFixture(&screenBorderShape, 0);
screenBorderShape.Set(upperRightCorner, upperLeftCorner);
screenBorderBody->CreateFixture(&screenBorderShape, 0);
screenBorderShape.Set(upperLeftCorner, lowerLeftCorner);
screenBorderBody->CreateFixture(&screenBorderShape, 0);

我怎样才能删除左边的那个?

我知道:

screenBorderBody->DestroyFixture(b2Fixture *fixture)

但是我需要稍后再这样做,所以我可以到达那个夹具(有身体指针)而不将这个特定的那个保存为全局吗?

感谢。

1 个答案:

答案 0 :(得分:0)

screenBorderShape.Set(lowerRightCorner,upperRightCorner);     screenBorderBody-> CreateFixture(& screenBorderShape,0);

将此灯具命名为左夹具或左墙....

在此之后你可以使用screenBorderBody-> DestroyFixture(<#b2Fixture * fixture#>)

...

方式是

groundBox.Set(b2Vec2(X1 / PTM_RATIO,Y1 / PTM_RATIO),b2Vec2(X2 / PTM_RATIO,Y1 / PTM_RATIO));     bottomFixture = groundBody-> CreateFixture(& groundBoxDef);

然后移除底部固定装置(在您的情况下为左侧)

如果只想取消碰撞,可以通过设置类别或掩码位

来实现