I've only ran a few tests and was able to replace the fixture without destroying it. As mayobutter mentioned it before, box2d doesn't officially support it but it works 🙂
To resize a polygon:
To resize a polygon:
Code:
var points:Vector.<V2> = new Vector.<V2>;
i = 0; // ASSUMING that there's only one fixture
var affectedPolygon:b2PolygonShape=b2fixtures[i].GetShape() as b2PolygonShape;
for (var i:int = 0; i< affectedPolygon.GetVertexCount(); i++) {
points.push(affectedPolygon.GetVertex(i).multiplyN(scaleMultiplier));
}
affectedPolygon.Set(points);
// update mass
b2body.ResetMassData();
// IF NEEDED
b2body.SetAwake(true); // otherwise, no collision detection will be performed on sleeping objects
i = 0; // ASSUMING that there's only one fixture
var affectedPolygon:b2PolygonShape=b2fixtures[i].GetShape() as b2PolygonShape;
for (var i:int = 0; i< affectedPolygon.GetVertexCount(); i++) {
points.push(affectedPolygon.GetVertex(i).multiplyN(scaleMultiplier));
}
affectedPolygon.Set(points);
// update mass
b2body.ResetMassData();
// IF NEEDED
b2body.SetAwake(true); // otherwise, no collision detection will be performed on sleeping objects