8

2枚の画像にテクスチャ描画を使用しましたが、背景画像が黒くなります。ソース画像はpngで、透明です。どうすればこれを解決できますか?

元の画像を透明にレンダリングするにはどうすればよいですか?

4

2 に答える 2

32

これを試して:

            spriteBatch.begin();
            //background
            seaTexture = new Texture(px);
            Color c = spriteBatch.getColor();
            spriteBatch.setColor(c.r, c.g, c.b, 1f); //set alpha to 1
            spriteBatch.draw(seaTexture, 0, 0, 480, 320);
            //foreground
            c = spriteBatch.getColor();
            spriteBatch.setColor(c.r, c.g, c.b, .3f);//set alpha to 0.3
            spriteBatch.draw(blockTexture, 50, 100, 120, 120);

            spriteBatch.end();
于 2012-10-25T23:01:22.843 に答える
2

spritebatch.enableBlending()以前に無効にしたことがある場合は試してください。ただし、デフォルトで有効にする必要があります。

于 2012-06-30T15:29:21.257 に答える