我在libgdx帧速率有问题,如果我做错了什么,alguin可以启发我,因为我不认为这是正常的,问题是我加载瓷砖地图和简单的,如果把最高分辨率320×320,800×600说这下降到12帧/秒左右,我希望解释得很好PUE腹股沟不是母语感谢。Libgdx问题帧速率(FPS)
public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
Texture img;
private OrthogonalTiledMapRenderer bachTileMapRender;
private OrthographicCamera camera;
private TiledMap map;
private int[] background = new int[] {0}, foreground = new int[] {1};
@Override
public void create() {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
map = new TmxMapLoader().load("maps/untitled.tmx");
bachTileMapRender = new OrthogonalTiledMapRenderer(map, 1/32f);//Asignar mapa
camera = new OrthographicCamera(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
camera.setToOrtho(false, 32, 32); //Virtual dimensiones
}
@Override
public void render() {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//batch.begin();
//batch.draw(img, 0, 0);
//batch.end();
camera.update();
bachTileMapRender.setView(camera);
bachTileMapRender.render(background);
System.out.println("fps:"+Gdx.graphics.getFramesPerSecond());
}
}
320×320帧速率大约是60,但是爬上了窗口,或使用800×600迅速下降
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = 320;
config.height = 320;
new LwjglApplication(new MyGdxGame(), config);
}
} PD:这是值得我的电脑是双核3000,在debian linux中
untitled.tmx
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="32" height="32" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="prueba" tilewidth="32" tileheight="32">
<image source="title.png" width="384" height="128"/>
</tileset>
<layer name="Capa de Patrones 1" width="32" height="32">
<data encoding="base64" compression="zlib">
eJztwwEJAAAMBKHr8f17rsdQcNVUVVXV1w8ar2wB
</data>
</layer>
</map>
你确定它只是在你改变分辨率下降吗?难道这是因为320 * 320具有不同的纵横比然后是800 * 600的缩放/拉伸? – Madmenyo 2014-09-22 11:19:45
感谢您的回答,如果我更改了类DesktopLauncher config.width = 320; config.height = 320; 发生800 x 600或更高分辨率 – 2014-09-22 11:25:32
奇怪,如果将其更改为800x800,该怎么办?如果这仍然运行良好,它必须与伸展有关,因为您将相机设置为800x800。另外为什么你将orthocamera.x设置为false?你应该使用camera.setToOrtho(800,800,false); – Madmenyo 2014-09-22 11:28:11