首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >libgdx使用texturepacker显示背景

libgdx使用texturepacker显示背景
EN

Stack Overflow用户
提问于 2015-02-10 00:53:51
回答 1查看 101关注 0票数 0

我有一个480 * 800大小的图像背景。我使用texturepacker来创建.pack文件。我尝试将背景显示到屏幕中,但背景显示非常小,不适合屏幕设备。请帮我正确显示背景。谢谢

EN

回答 1

Stack Overflow用户

发布于 2015-02-13 07:58:43

您只需调整图像的大小:

代码语言:javascript
复制
 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();

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28415013

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档