我一直在與jbox2d搞混,當身體的X速度受到世界的重力影響時感到驚訝。這裏是我的代碼:setLinearVelocity()未按預期工作
//create world
Vec2 gravity = new Vec2(0, 1);
boolean sleep = true;
world = new World(gravity, sleep);
//create wheel
BodyDef wheelBodyDef = new BodyDef();
wheelBodyDef.type = BodyType.DYNAMIC;
wheelBody = world.createBody(wheelBodyDef);
CircleShape circleShape = new CircleShape();
FixtureDef wheelFixtureDef = new FixtureDef();
wheelFixtureDef.shape = circleShape;
Fixture wheelFixture = wheelBody.createFixture(wheelFixtureDef);
wheelBody.setLinearVelocity(new Vec2(50, 0));
的線速度僅使一個顯著區別,如果我申請它的每一個幀,或者如果我禁用重力。任何人都可以弄清楚我做錯了什麼?