我有以下设置:
private static final float SCENE_WIDTH = 1280;
private static final float SCENE_HEIGHT =720;
//Gravity
world = new World(new Vector2(0,-9.8f), true);
camera = new OrthographicCamera();
viewport = new FitViewport(SCENE_WIDTH, SCENE_HEIGHT, camera);
//viewport.apply();
camera.position.set(SCENE_WIDTH * 0.5f, SCENE_HEIGHT * 0.5f, 0);
然后我创建了一个具有以下功能的主体:
//Center the body so it can start falling down
defaultDynamicBodyDef.position.x = SCENE_WIDTH * 0.5f;
defaultDynamicBodyDef.position.y = SCENE_HEIGHT * 0.5f;
// Shape for square
square = new PolygonShape();
// IMPORTANT 100 = 1m
square.setAsBox(100, 100);
// Fixture definition for our shapes
boxFixtureDef = new FixtureDef();
boxFixtureDef.shape = square;
boxFixtureDef.density = 0.8f;
boxFixtureDef.friction = 0.8f;
boxFixtureDef.restitution = 0.15f;
见上文所说的IMPORTANT
。使用这些设置时1m = 100
缩放正方形会缓慢下降。
但如果我的设置如下:
private static final float SCENE_WIDTH = 12.8f;
private static final float SCENE_HEIGHT =7.2f;
然后将方块大小更改为:
// Shape for square
square = new PolygonShape();
// IMPORTANT 1m = 1
square.setAsBox(1f, 1f);
广场倒下的速度要快得多?我很迷惑。总而言之,具有方形参数100和100的世界单位1280和720,身体比12.8和7.2以及1和1的世界单位下降得慢。 1为squre。在这两种情况下我都使用世界单位,但秋天的速度是不同的?那是为什么?
答案 0 :(得分:0)
因为两个例子中的引力都相同。因此,正方形将以相同的速度/加速度移动,而在第二个示例中,正方形将更快地移出屏幕。