Scaling circule

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:
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();
      }


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
It took me some time, but I found the solution - hope it would help someone (please tell me if so)

Code:

      override protected function updateMyLook():void
      {
         
         var circF:b2Fixture = this._body.GetFixtureList() as b2Fixture;
         var circ:b2CircleShape = circF.GetShape() as b2CircleShape;
         var r = circ.GetRadius();
         this._body.DestroyFixture(circF);
         
         var bBodyShape:b2CircleShape = new b2CircleShape(((r * PhysicsVars.RATIO) - 0.03) / 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);
         
         _body.GetAngularVelocity()
         
         super.updateMyLook();
      }


Thanks Shefy
I had a similar question a few days ago - I'm using the Alchemy port, but I assume things work the same at the Box2D level.

In my case it was sufficient to simply change the radius of the shape instead of creating a new fixture:

Code:
         var circF:b2Fixture = this._body.GetFixtureList() as b2Fixture;
         var circ:b2CircleShape = circF.GetShape() as b2CircleShape;
         var r:Number = circ.m_radius;
         circ.m_radius = ((r * PhysicsVars.RATIO) - 0.03) / PhysicsVars.RATIO;
10x - Trying it now.

In my version - I would have to use setRadius(r) - since m_radius is now no longer public.

What is Alchemy?
Great - it worked 🙂

Which means that what is shown in the tutorial is an overkill.

Still would loveto know - What is Alchemy?
http://www.sideroller.com/wck/

Adobe Alchemy is a C++ compiler that targets the Flash VM. mayobutter ported the original Box2D C++ to Flash using Alchemy (and a lot of elbow grease, apparently)
interesting. Can you show what you were working on?


Thanks for your help, I put a link to this thread in the comments on the tutorial page I started from - maybe we could help more people.
There are almost no tutorials on the latest Box2d for flash, and they changed quite a bit.
Here's my proof-of-concept for frothy bubbles. Mostly just playing around right now, trying out different things.

I am developing with FlashDevelop, so there is no .fla file. I'm just including the 3 source files. Since it uses the Alchemy port you'll have to grab that too from http://github.com/jesses/wck, or modify it to build with the Flash port.
Nice.

I'm attaching something I did as an experiment for a game I'm working on.

have a look on the Actor class and how I'm using it, I think it might be helpful, this is something I learned from Todd Tutorial on making peggle look alike:

http://www.kerp.net/box2d/

Again - 10x 4 your help

Original thread: https://box2d.org/forum/viewtopic.php?t=5601