[libGDX] Images not resizing properly

Hi,

I am trying to resize a window but keep the logo image inside the window the same size, and get the background to scale both down and up as opposed to just up

here is an extract from my code:

	public void render(float delta) {
		Gdx.gl.glClearColor(0, 0, 0, 1);

		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		bg = new Sprite(new Texture("img/menubg2.gif"));
		bg.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		batch.begin();
		bg.draw(batch);
		batch.end();
		stage.act(delta);
		stage.draw();
		batch.begin();
		heading.draw(batch);
		batch.end();
		
		tweenManager.update(delta);
	}
	public void show() {

		stage = new Stage();		
		Gdx.input.setInputProcessor(stage);

		table = new Table(skin);
		table.setFillParent(true);
		
		batch = new SpriteBatch();
		//Draw Logo
		heading = new Sprite(new Texture("img/logo.png"));
		heading.setBounds(Gdx.graphics.getWidth() / 2 - 200, Gdx.graphics.getHeight() - 175, 400, 150);
                }

Thanks,

  • Dan

Do you want to keep the image the same size? Or keep it’s aspect ratio, just to clarify.

What you have now should keep it’s size.

Don’t use new in render().