我编写了一个基本的Box2d-“游戏”:没有纹理等等,只有一个玩家(身体),从一个静态的地面体跳到另一个。
问题在于,地面分别是玩家身体,其后是相机,每隔几秒就会断断续续。 (https://www.dropbox.com/s/llsg2q65lz828t6/stuttering.avi)(请下载此视频,否则您的Flash播放器会显示更多口吃)
如果你看看地面元素,你可以看到这非常好。
捆绑纹理也会断断续续。
奇怪的是:全屏模式没有任何卡住(config.fullscreen = true);仅适用于Android-Phones和窗口模式。
虽然这只是一个小游戏,但我尝试使用Interpolation并分析了GC动作:没有结果:\
提前致谢!
我代码中的一些和平(我关闭了插值):
private float step = 1.0f / 60.0f;
public void show()
{
//...
bodyDef.type = BodyType.StaticBody;
bodyDef.position.set(0, 0);
//...
ChainShape groundShape = new ChainShape();
float width = 20;
float height = 0.25f;
fixtureDef.restitution = 0.0f;
fixtureDef.friction = 0.5f;
fixtureDef.shape = groundShape;
fixtureDef.friction = .5f;
fixtureDef.restitution = 0;
groundShape.createChain(new Vector2[] { new Vector2(0, 0), new Vector2(width, 0), new Vector2(width, -height), new Vector2(0, -height), new Vector2(0, 0) });
fixtureDef.shape = groundShape;
world.createBody(bodyDef).createFixture(fixtureDef);
groundShape.dispose();
groundShape = new ChainShape();
bodyDef.position.set(25, 0);
groundShape.createChain(new Vector2[] { new Vector2(0, 0), new Vector2(width, 0), new Vector2(width, -height), new Vector2(0, -height), new Vector2(0, 0) });
fixtureDef.shape = groundShape;
world.createBody(bodyDef).createFixture(fixtureDef);
groundShape.dispose();
//...
}
public void render(float delta)
{
world.step(step, 8, 3);
input.update();
playCam.position.set(player.getBody().getPosition().x + 6.5f, 3.5f, 0);
playCam.update();
player.move();
debugRenderer.render(world, playCam.combined);
}
播放器级:
move()
{
playerbody.setLinearVelocity(20f, 0);
}