0

我需要获取夹具的主体,但是当我调用 fixture.GetBody() 函数时,它返回此错误: Object # has no method 'GetBody';

这是代码:

var bodyDef = 新 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());

感谢您的任何建议。

4

1 回答 1

1

b2FixtureDef没有 getBody(),所以这就是错误的含义。b2FixtureDef的文档链接在那里。看起来 Fixture 类型甚至没有可以设置的主体,就像在行中一样bounceDef.body = bouncebodyDef;

于 2013-02-06T21:49:30.900 回答