0
我有一個Box2DWeb模擬自定義形狀的身體,但它根本不與其他身體交互。調試繪圖顯示檢測到碰撞,但不起作用。閱讀自定義形狀我沒有找到任何設置來啓用碰撞,我不知道什麼是錯的。自定義形狀身體像這樣創建的,我也貼的例子here:Box2dWeb自定義形狀交互
bodyDef = new b2BodyDef;
bodyDef.type = b2Body.b2_dynamicBody;
bodyDef.position.x = canvas.width/30/2;
bodyDef.position.y = 2;
body = world.CreateBody(bodyDef);
v = [[2,0],
[2,2],
[0,2],
[0,3],
[2,3],
[2,5],
[3,5],
[3,3],
[5,3],
[5,2],
[3,2],
[3,0]];
vecs = [];
for(i=0;i<v.length;i++){
cc = new b2Vec2();
cc.Set(v[i][0],v[i][1]);
vecs[i] = cc;
}
fixDef.shape = new b2PolygonShape;
fixDef.shape.SetAsArray(vecs,vecs.length);
body.CreateFixture(fixDef);