私はlibgdxとそれを使ってscene2dを学び始めていますが、splashScreenに問題があります。フェード アクションは完全に機能しますが、イメージはスケーリングされません (コンストラクターにスケーリングを追加しても)...
実際の画像は 512x256 の png 512x512 から読み込まれたテクスチャ スプラッシュテクスチャがあるので、TextureRegion を作成します。これはすべて、私の show メソッドで行われます。
@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 クラス (実際には render 関数を持つ) を拡張するクラス SplashScreen 内の関数です。
@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();
}
どんなアイデアでも大歓迎です。私は何年にもわたって Javadocs を調べてきましたが、まだ解決策が見つかりません!
ありがとうございました、
ブヌナマク