I set my texture to resize to Gdx.graphics.getWidth()
, Gdx.graphics.getHeight()
every time render function calls. In fact when I launch the app, texture sets full screen (as I want). But when I change the size of the app, the texture draws in some dumb way, while I want it to be full screen all the time.
Here is the code:
package com.leopikinc.bobdestroyer;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class BobDestroyer extends ApplicationAdapter {
SpriteBatch batch;
Texture mainscreen;
Music intromusic;
float VOLUME;
@Override
public void create () {
VOLUME = 1f;
batch = new SpriteBatch();
mainscreen = new Texture(Gdx.files.internal("data/FirstLevel.png"));
intromusic = Gdx.audio.newMusic(Gdx.files.internal("data/IntroMusic.mp3"));
intromusic.setLooping(true);
intromusic.setVolume(VOLUME);
intromusic.play();
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 1, 1, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(mainscreen, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.end();
}
@Override
public void resize(int width, int height){
}
}