{
b2BodyDef bodyDef;
bodyDef.type = b2_staticBody;
bodyDef.position.Set(location.x / PTM_RATIO, location.y / PTM_RATIO);
bodyDef.userData = pSprite;
//bodyDef.userData = nullptr;
b2Body* body = _world->CreateBody(&bodyDef);
body->SetLinearVelocity(b2Vec2(1, 0));
b2PolygonShape poly;
b2Vec2 vertices[7];
vertices[0].Set(0, 0);
vertices[1].Set(1, 0);
vertices[2].Set(1, 1);
vertices[3].Set(0.75f, 1);
vertices[4].Set(0.5f, 1.5f);
vertices[5].Set(0.25f, 1);
vertices[6].Set(0, 1);
poly.Set(vertices, 7);
b2FixtureDef fixtureDef;
fixtureDef.shape = &poly;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.5f;
fixtureDef.restitution = 0.0f;
body->CreateFixture(&fixtureDef);
}
我用顶点值制作box2d的身体。
(它使用的是 b2ChainShape,所以内部是空的)
为什么会出现这些差异?
我不能解决这个问题吗?

