0
votes

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

1
Too many ways to do this, you have any code examples? - Johnathon Havens
The problem isn't in texturepacker, the problem is in your knowledges of libgdx. Search for good tutorials. I bet that your camera settings are wrong. And remember: no code - no real help. - nikoliazekter
Thanks guys. I found the problem is the viewport setting incorrect - anh le

1 Answers

0
votes

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();

}