1

背景テクスチャがあり、それを別の背景テクスチャに変更したいと考えています。背景テクスチャに関するいくつかのサンプルを読んでテストしましたが、2 番目の背景が表示されません。

これは私が変更しようとした最後のコードです...誰か助けてくれますか? ありがとう

    Scene scene1 = new Scene();
    ITexture backgroundTexture1 = null;
    try {
        backgroundTexture1 = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
            @Override
            public InputStream open() throws IOException {
                return getAssets().open("gfx/crackedscreen.png");
            }
        });
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    backgroundTexture1.load();
    this.mBackgroundTextureRegion1 = TextureRegionFactory.extractFromTexture(backgroundTexture1);
    Sprite backgroundSprite = new Sprite(0, 0, this.mBackgroundTextureRegion1, getVertexBufferObjectManager());
    scene1.attachChild(backgroundSprite);
    scene1.setBackgroundEnabled(true);
    return scene1;
4

1 に答える 1

2

スプライトを使用して背景を変更するのにも問題がありました。私はついに SpriteBackground を使用して成功しました。スプライトから作成するだけです:

SpriteBackground background = new SpriteBackground(backgroundSprite);

attachchild を呼び出す代わりに、setBackground を呼び出します。

scene.setBackground(background);
于 2013-04-04T14:14:38.730 に答える