Box2d Flash AS3 (1.4.3 released)

I just had to figure this out myself. The b2World.createBody(b:b2BodyDef) function returns a b2Body object. This is your handle to the object in the world. Store the b2Body object so you can later tell the world to destroy the body.
I can reccomend you to sub-class the b2Body to e.g. Avatar.
Also sub-class b2World to something like b2WorldAdvanced.

Then you can do your own function like:

b2WorldAdvanced.CreateAvatar(a:Avatar);

and

b2WorldAdvanced.RemoveAvatar(a:Avatar)

or better, to solve your problem with keeping references:

b2WorldAdvanced.RemoveAvatar(id:Number)

or

b2WorldAdvanced.RemoveAvatar(name:String)
Cool and Nice guys.

At least we have some ids to work with now.
From all the flash demos I've seen so far there seems to be very few bodies. It's often someone throwing a snowball, few packets or something else.

It seems that the threshold is at 35 bodies on my machine, then the framerate drops from 30 to 22. I need to come somewhere close to 100 bodies on the screen.

My question is: Can it be done? What can I do to get the speed up?
Take a look at the second demo, it has close to 100 moving bodies in it. On my cpu it doesn't drop below 30fps even when the big tower is collapsing, and even then the physics step is holding up to around 100fps (10ms).

A pile of 100 bodies all interacting at once might be a problem, but hundreds of bodies spread throughout the scene shouldn't be a problem at all.

Hundreds of MovieClips on screen would probably be a bigger performance problem than the bodies.
Thanks. I was running Flex in debug mode. 😀

Now the choke-point on my machine is 85 boxes jumping randomly.
BTW thats with 85 bitmaps. 🙂

Which should suffice.

I guess box shapes are faster than circles and polygons?
Heh, well that's good to hear. :P

As far as I know circle shapes are the fastest, especially circle-circle collisions, boxes are just polys that are easier to create, and I guess it would get more complex with the more points/sides the poly has.
Box2DFlashAS3 1.4.3 has been released.
Basically it's just the bug fixes from Box2D 1.4.3, but there's a few other changes and a 'Hello World' example which uses MovieClips from the library to render the physics objects.

http://box2dflash.sourceforge.net/

Let me know if you have any problems with it.
-Matt
Thanks, then I will convert my box shapes to circles.
is there any way to assign a maximum speed to a body?
i have a ball and several objects with restitution 2 or 3 and sometimes the ball becomes so fast that it gets "out of the world" (and "jumps over" my 300-400 pixel wide boxes at the edge of the world)

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