I have started making a new class for box2d. It makes creation of objects in box2d a lot easier.
Included b2Fast v0.1 class + example
Creates boxes, circles, polygons and revolute joints
TODO:
Multi shaped bodies
All joints
Example:
Included b2Fast v0.1 class + example
Creates boxes, circles, polygons and revolute joints
TODO:
Multi shaped bodies
All joints
Example:
Code:
package
{
import Box2D.Dynamics.b2Body;
import flash.display.MovieClip;
import flash.events.Event;
public class test extends MovieClip
{
var f:b2Fast;
var t:int = 0;
public function test() {
f = new b2Fast;
f.enableDebug(this);
addEventListener(Event.ENTER_FRAME, upd);
f.box(stage.stageWidth / 2, 300, 400, 30);
}
function upd(e:Event) {
f.step();
t++;
if (t == 10) {
t = 0;
f.box(Math.random()*550, Math.random()*-300 -50, Math.random()*50+10, Math.random()*50+10, Math.random()*360, 1);
f.circle(Math.random()*550, Math.random()*-300-50, Math.random()*25+5, 1);
f.polygon(Math.random()*550, Math.random()*-300-50, [-20, 0, 20, 0, 0, 40], 180, 1);
}
}
}
}
Creates random rain of shapes{
import Box2D.Dynamics.b2Body;
import flash.display.MovieClip;
import flash.events.Event;
public class test extends MovieClip
{
var f:b2Fast;
var t:int = 0;
public function test() {
f = new b2Fast;
f.enableDebug(this);
addEventListener(Event.ENTER_FRAME, upd);
f.box(stage.stageWidth / 2, 300, 400, 30);
}
function upd(e:Event) {
f.step();
t++;
if (t == 10) {
t = 0;
f.box(Math.random()*550, Math.random()*-300 -50, Math.random()*50+10, Math.random()*50+10, Math.random()*360, 1);
f.circle(Math.random()*550, Math.random()*-300-50, Math.random()*25+5, 1);
f.polygon(Math.random()*550, Math.random()*-300-50, [-20, 0, 20, 0, 0, 40], 180, 1);
}
}
}
}