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
Asked
Active
Viewed 111 times
0
-
Too many ways to do this, you have any code examples? – Johnathon Havens Feb 09 '15 at 17:44
-
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 Feb 09 '15 at 21:26
-
Thanks guys. I found the problem is the viewport setting incorrect – anh le Feb 12 '15 at 09:18
1 Answers
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