I can’t seem to get my background to look smooth and not blurred.
Atm my game is 1280 x 720. The pixels per meter ratio is 1:20. My background texture is 400 x 225. It fits well in the zone however the image looks blurred.
How can I work out what dimension my backgrounds should be based on my pixel per meter ratio and game resolution? This has me really confused :emo:
Here’s what I have so far:
@Override
public void show() {
...
b1 = new Texture(Gdx.files.internal("backgrounds/spr_stars01.png"), true);
b1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
...
}
@Override
public void render(float delta) { //(43, 55, 61)
...
Gdx.gl.glClearColor(132/255f, 0/255f, 35/255f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
world.step(TIMESTEP, VELOCITYITERATIONS, POSITIONITERATIONS);
world.getBodies(bodies);
camera.position.set(player.getPosition().x, player.getPosition().y, 0);
camera.update();
timer += (delta*1.25f);
batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(b1, player.getPosition().x/20, player.getPosition().y/20);
batch.end();
...
}
@Override
public void resize(int width, int height) {
camera.viewportWidth = 1200 / 20; //60m
camera.viewportHeight = 800 / 20; //40m
hud.getViewport().update(width, height);
}
The result:
The background: