Box2d flash : Made Simple

Hey!

I've been working with box2d for a short while now.. And I think that working with the physical scale, and having to create the world yourself with a lot of script every time seems a waste of time.. So I made a class named box2dms (Made simple), where I'm working around those irritating moments, so that the user can just put in regular pixel-coordinates and stuff like that.

I'm not at all finished with the class yet, so you could say it's a beta version. I sure hope there are others out there who'd find this helpful!

Here's a short example of how it works :

Code:
import se.artheus.box2dms.box2dms;

var box2d:box2dms = new box2dms(940, 525, new b2Vec2(0, 10), 30, true); //x, y, gravity, physical scale (opt), show debug draw (opt)

box2d.createBox(860, 10, 25, 408, .7, 0); //width, height, x, y, friction, density, restitution (opt)
box2d.createCircle(885.95, 404.95, 12.5, .7, 0); // x, y, radius, friction, density, restitution (opt)
box2d.createPolygon(728.45, 285.75, [[0, 0], [104.25, 19.5], [104.25, 26.05], [0, 6.55]], .7, 0); // x, y, corner positions, friction, density, restitution (opt)


The createBox, createCircle, createPolygon methods returns a b2Body.

You can at all time access the b2World object, by just writing box2d.world

And it's really easy to tie a Movieclip to one of the b2Bodies, just do it like this :

Code:
var box:MovieClip = new MovieClip();

box.graphics.beginFill(0xFFFFFF, 0);
box.graphics.drawRect(0, 0, 50, 50);
box.graphics.endFill();

var b2box:b2Body = box2d.createBox(50, 50, 0, 0, .7, 1);

box2d.tieToBody(b2box, box);


And the 'box' movieclip follows the b2body perfectly.


Hope there are others out there who will help me developing this!

Cheers,
Artheus

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