我有一个 480 * 800 的图像背景大小。我使用 texturepacker 创建 .pack 文件。我尝试在屏幕上显示背景,但背景显示非常小,不适合屏幕设备。请帮我正确显示背景。谢谢
问问题
103 次
1 回答
0
您需要简单地调整图像的大小:
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();
}
于 2015-02-12T23:58:43.340 回答