2

I have this image(https://i.stack.imgur.com/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.stack.imgur.com/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.

committedandroider
  • 8,711
  • 14
  • 71
  • 126
  • How are you setting your projection matrix on the sprite batch? It will depend on how you're doing that. – Tenfour04 Jul 07 '14 at 01:43

2 Answers2

3

Something like this should work:

batch.draw(sprite.getTexture() x, y, sprite.getWidth(), sprite.getHeight());
Gallo2fire
  • 153
  • 1
  • 9
0

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

enter image description here

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154