我正在使用下面的代码来尝试生成多边形形状的精灵。我遇到了代码问题,有人能发现它有什么问题吗?
b2BodyDef woodBodyDef;
woodBodyDef.position.Set(400/PTM_RATIO,100/PTM_RATIO);
woodBodyDef.type = b2_dynamicBody;
woodBodyDef.userData = _wood;
_body = _world->CreateBody(&woodBodyDef);
b2PolygonShape woodShape;
int num = 4;
b2Vec2 vertices[] = {
b2Vec2(-137.0f/PTM_RATIO,-32.5f/PTM_RATIO),
b2Vec2(-137.0f /PTM_RATIO,36.5f/PTM_RATIO),
b2Vec2(137.0f /PTM_RATIO,36.5f/PTM_RATIO),
b2Vec2(136.0f /PTM_RATIO, -32.5f/PTM_RATIO)
};
woodShape.Set(vertices, num);
b2FixtureDef woodShapeDef;
woodShapeDef.shape = &woodShape;
woodShapeDef.density = 1.0f;
woodShapeDef.friction = 1.0f;
woodShapeDef.restitution = 0.5f;
woodBodyDef.userData = _wood;
_body = _world->CreateBody(&woodBodyDef);