簡體   English   中英

libgdx階段不繪制拉伸圖像

[英]libgdx stage doesn't draw stretched image

我正在使用libgdx'階段來繪制背景。 背景圖像應該伸展以適合所有尺寸的手機和平板電腦。 但圖像僅顯示為小圖像,不會拉伸。 有什么想法嗎?

@Override
public void show() {
      stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
      batch = new SpriteBatch();
      Assets.load();
      Image img = new Image(new TextureRegion(Assets.background));
      stage.addActor(img);  
      Table table = new Table(skin);
      stage.addActor(table);
}

@Override
public void render(float delta) {
     Gdx.gl.glClearColor(1, 1, 1, 1);
     Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
     stage.act(delta);
     stage.draw();  
}

@Override
public void resize(int width, int height) {
    stage.setViewport(width, height, true);
}

這樣可以解決問題:

img.setFillParent(true);

參考: Widget#setFillParent

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM