0

I have a image background size 480 * 800. I use texturepacker to create .pack file. I try to display background into screen but background display very small and not fit screen device. Please help me display background correctly. Thanks

anh le
  • 183
  • 1
  • 7

1 Answers1

0

You need to simply adjust the image's size:

 private SpriteBatch spriteBatch;
 private Texture texture; 
 private Sprite textureSprite;

   public void show(){ // It might also be called create(); 
   spriteBatch = new SpriteBatch();
   texture = new Texture(Gdx.files.internal("location of img in assets folder"));
   textureSprite = new Sprite(texture);

   //Set the image width/height to the width/height of the screen.
   textureSprite.setBounds(0,0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
 } 
 public void render(float delta) {
     Gdx.gl.glClearColor(0, 0, 0, 1);
     Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
     // Clear the screen every loop

     spriteBatch.begin();
     textureSprite.draw(spriteBatch);
     spriteBatch.end();

}
dHoja
  • 206
  • 3
  • 10