Reputation: 9261
I have this image(https://i.sstatic.net/ucafS.jpg) and am trying to make it take up the whole screen. Heres my code
static Texture img;
static Sprite sprite;
public static void load(){
img = new Texture(Gdx.files.internal("menu/stick.PNG"));
//libgdx scales it , it wont mess up
img.setFilter(TextureFilter.Linear, TextureFilter.Linear);
sprite = new Sprite(img);
sprite.flip(false, true);
sprite.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
The output still doesnt show the stick figure taking up the whole screen. Output:https://i.sstatic.net/kGTfV.jpg
Am i going about this the wrong way? I thought by setting the sprite(the object rendering the image to the screen) to the size of the screen, the image should take up the whole screen as well.
Upvotes: 2
Views: 821
Reputation: 143
Something like this should work:
batch.draw(sprite.getTexture(), x, y, sprite.getWidth(), sprite.getHeight());
Upvotes: 3
Reputation: 45072
Set the bound of the image.
Image backgroundImage = new Image(Assets.loadTexture("wood.jpg"));
backgroundImage.setBounds(0,0,screenWidth, screenHeight);
backgroundImage.setOrigin(screenWidth/2,screenHeight/2);
See image is now full screen
Upvotes: 0