I am developing a game using libGdx
in which a level has 2400 * 450 tiles Map and each tile is of 4 pixels. I am also using box2d
in my game.
My problem is that when I run the game on my phone it takes a lot of time to load the screen (more than a minute). How can I reduce this loading time?
I created tilemap using Tiled
and I am using Android Studio
.
Below is my code (SCALE is 2.0f and PPM is 4)
@Override
public void show() {
w = Gdx.graphics.getWidth();
h = Gdx.graphics.getHeight();
camera = new OrthographicCamera();
camera.setToOrtho(false, w / SCALE, h / SCALE);
camera.update();
viewport = new FitViewport(w / SCALE, h / SCALE ,camera);
viewport.apply();
.
.
.
map = new TmxMapLoader().load("maps/lvl3.tmx");
tmr = new OrthogonalTiledMapRenderer(map, 1/SCALE);
}
@Override
public void render(float delta) {
update(Gdx.graphics.getDeltaTime());
//Render
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
tmr.render();
.
.
.
b2dr.render(world, camera.combined.scl(PPM));
}
public void update(float delta) {
world.step(1 / 60f, 6, 2);
cameraUpdate(delta);
tmr.setView(camera);
batch.setProjectionMatrix(camera.combined);
}
@Override
public void resize(int width, int height) {
camera.setToOrtho(false, width / SCALE, height / SCALE);
viewport.update( width , height );
}
Please help and thanks in advance
loadSync()
andloadASync()
in the TmxMapLoader class. \$\endgroup\$ – Charanor Mar 14 '17 at 19:28