I can't seem to reuse b2BodyDef and b2FixtureDef. There is no error being thrown, it's just not rendering to the screen.
My code:
My code:
Code: Select all
var bodyDef1 = new Box2D.Dynamics.b2BodyDef;
bodyDef1.type = Box2D.Dynamics.b2Body.b2_dynamicBody;
bodyDef1.position.SetV(new b2Vec2(450/30,100/30));
var fixtureDef1 = new Box2D.Dynamics.b2FixtureDef;
fixtureDef1.density = 10;
fixtureDef1.friction = 1;
fixtureDef1.restitution = 1;
fixtureDef1.shape = new Box2D.Collision.Shapes.b2PolygonShape;
fixtureDef1.shape.SetAsBox(15/30, 15/30);
fixtureDef1.userData = "fix1";
world.CreateBody(bodyDef1).CreateFixture(fixtureDef1);
//here below, trying to reuse the bodydef1, and fixtureDef1:
bodyDef1.position.SetV(new b2Vec2(0,0));
fixtureDef1.shape.SetAs Box(1,1);
fixtureDef1.userData = "fix2";
world.CreateBody(bodyDef1).CreateFixture(fixtureDef1);