我有一个480 * 800大小的图像背景。我使用texturepacker来创建.pack文件。我尝试将背景显示到屏幕中,但背景显示非常小,不适合屏幕设备。请帮我正确显示背景。谢谢
发布于 2015-02-13 07:58:43
您只需调整图像的大小:
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();
}https://stackoverflow.com/questions/28415013
复制相似问题