0

I need to get the body of a fixture but when I call the fixture.GetBody() function, It returns this error: Object # has no method 'GetBody';

here is the code:

var bodyDef = new b2BodyDef;

var bouncebodyDef = new b2BodyDef;

bouncebodyDef.type = b2Body.b2_dynamicBody;   

var bounceDef = new b2FixtureDef;
    bounceDef.density = 1;
    bounceDef.body = bouncebodyDef;
    bounceDef.friction = 1;
    bounceDef.restitution = 0;
    bounceDef.userData = 'bounce';

bounceDef.shape = new b2PolygonShape;
bounceDef.shape.SetAsBox(1.5, 0.1);
bouncebodyDef.position.Set(2, 12);
bouncebodyDef.angle = (3.4);
world.CreateBody(bouncebodyDef).CreateFixture(bounceDef);

console.log(bounceDef.GetBody());

Thanks for any suggestions.

adam
  • 807
  • 3
  • 11
  • 17

1 Answers1

1

b2FixtureDef doesn't have a getBody(), so that's what the error means. The documentation for b2FixtureDef is linked there. It doesn't look like the Fixture type even has a body that you can set, like in the line bounceDef.body = bouncebodyDef;

Walls
  • 3,972
  • 6
  • 37
  • 52