我開始學習libgdx和它的scene2d,但是我的splashScreen一直有問題。我的淡入淡出的動作完美,但圖像沒有被縮放(即使當我添加一個縮放到構造函數)...Scene2d圖像不會縮放
我有一個紋理splashTexture從PNG 512x512加載,其中真正的圖像是512x256 ,所以我創建了一個TextureRegion。 所有這一切都在我的表演方式完成:
@Override
public void show() {
super.show(); //sets inputprocessor to stage
splashTexture = new Texture(SPLASHADR);
// set the linear texture filter to improve the stretching
splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashTextureRegion = new TextureRegion(splashTexture, 0, 0, 512, 256);
}
然後來到我的大小調整方法如下:
@Override
public void resize(int width, int height) {
stage.clear();
Drawable splashTextureDrawable = new TextureRegionDrawable(
splashTextureRegion);
Image splashImg = new Image(splashTextureDrawable);
splashImg.getColor().a = 0f;
splashImg.addAction(Actions.sequence(Actions.fadeIn(0.5f),
Actions.delay(2f), Actions.fadeOut(0.5f)));
stage.addActor(splashImg);
}
這些都是在一個延伸的AbstractScreen類的類閃屏功能(實際上有渲染功能):
@Override
public void render(float delta) {
stage.act(delta);
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
}
任何想法是受歡迎的,我一直在尋找通過的Javadoc年齡,並沒有找到一個解決辦法!
謝謝
bnunamak
謝謝!那正是我需要的! – bnunamak