reuse b2BodyDef and b2FixtureDef

Discuss issues specific the Javascript port of Box2D
Posts: 4
Joined: Thu Oct 09, 2014 12:35 pm

reuse b2BodyDef and b2FixtureDef

Postby L2L2L » Thu Oct 23, 2014 9:40 pm

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:

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";

   //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";

Return to “Javascript”

Who is online

Users browsing this forum: No registered users and 1 guest