Hi,
I'm working with the latest Box2d for flash version, and I'm trying to scale a circle shape in a body (make it smaller in each frame)
I'm looking at this example:
http://www.emanueleferonato.com/2009/12/12/scaling-objects-with-box2d/
But I don't understand how to use it with the newer version.
I'v tried:
but then I cant destroy circ since it is not a fixture. If I'm trying to take fixture from the list, I wouldn't be able to get radius.
can someone show me an example, of how it should be done?
Thanks, Shefy
I'm working with the latest Box2d for flash version, and I'm trying to scale a circle shape in a body (make it smaller in each frame)
I'm looking at this example:
http://www.emanueleferonato.com/2009/12/12/scaling-objects-with-box2d/
But I don't understand how to use it with the newer version.
I'v tried:
Code:
override protected function updateMyLook():void
{
var circ:b2CircleShape = this._body.GetFixtureList() as b2CircleShape;
var r = circ.GetRadius();
this._body.DestroyFixture(circ);
var bBodyShape:b2CircleShape = new b2CircleShape(((r * PhysicsVars.RATIO) - 1) / PhysicsVars.RATIO);
var bBodyFixtureDef:b2FixtureDef = new b2FixtureDef();
bBodyFixtureDef.shape = bBodyShape;
bBodyFixtureDef.density = 0;
bBodyFixtureDef.friction = 0;
bBodyFixtureDef.restitution = 0.5;
bBodyFixtureDef.isSensor = false; // setting as sensor for collusions
this._body.CreateFixture(bBodyFixtureDef);
super.updateMyLook();
}
{
var circ:b2CircleShape = this._body.GetFixtureList() as b2CircleShape;
var r = circ.GetRadius();
this._body.DestroyFixture(circ);
var bBodyShape:b2CircleShape = new b2CircleShape(((r * PhysicsVars.RATIO) - 1) / PhysicsVars.RATIO);
var bBodyFixtureDef:b2FixtureDef = new b2FixtureDef();
bBodyFixtureDef.shape = bBodyShape;
bBodyFixtureDef.density = 0;
bBodyFixtureDef.friction = 0;
bBodyFixtureDef.restitution = 0.5;
bBodyFixtureDef.isSensor = false; // setting as sensor for collusions
this._body.CreateFixture(bBodyFixtureDef);
super.updateMyLook();
}
but then I cant destroy circ since it is not a fixture. If I'm trying to take fixture from the list, I wouldn't be able to get radius.
can someone show me an example, of how it should be done?
Thanks, Shefy