2017-06-13 103 views
0

没有这个代码fps是60-65。但是当我使用此代码时,fps降至50.LibGDX的低fps

另一个问题是FPS在某些设备上太低。但是,这个游戏很简单。我为所有形状使用ShapeRenderer。游戏是在这里:link

try { 
      Thread.sleep((long)(1000/60-Gdx.graphics.getDeltaTime())); 
     } catch (InterruptedException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 

编辑:我使用此代码解决了这个问题 - >link

+2

你不应该使用的代码,你想盖FPS? – Lestat

+2

你为什么把这个转换成很长的?该分区将被视为一个具有完整整数结果的整数除法,而不是以浮点类型进行转换。 –

+0

并请...不要将所有内容写入try&catch块。 –

回答

3

通过在应用程序加载器的配置中定义foregroundFPS,您可以将FPS限制为libgdx应用程序中的任何值。

LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); 
    config.width = 640; 
    config.height = 480; 
    config.foregroundFPS = 60; // <- limit when focused 
    config.backgroundFPS = 60; // <- limit when minimized 
    config.samples =2; // AA for shape renderer.. not textures! 
    new LwjglApplication(new libgdxapp(), config); 

android config

Continuous rendering

+0

那么,我该怎么做android。 'cfg.samples = 2'不适用于AA。 – Salihcan

+0

在android中,你使用config.numSamples = 2而不是样本 – dfour

+0

我的意思是cfg.samples不能在桌面上工作。并且,什么是适用于Android的'config.foregroundFPS = 60'代码 – Salihcan