0

过去,我总是制作自己的精灵表,只是让它们透明。但我总是看到以粉红色作为背景的精灵表。您将如何在游戏中将其键入?

还有哪个更好?使用透明的 .png 文件?或具有纯色背景色?

在此处输入图像描述

如果有人想知道,我使用 BufferedImage 类和 getSubImage。

4

2 回答 2

2

通常有三种方法可以使精灵透明,使用单独的 Alpha 通道、使用单独的位掩码或仅使用透明颜色。后者通常与索引颜色一起使用,因为它就像用透明度替换索引之一(在您的情况下为粉红色)的颜色一样简单。

我看到这种技术的唯一优点是保留内存。但是我没有制作很多游戏,所以这样做可能还有其他原因.. ;-)

于 2013-08-23T09:00:39.713 回答
0

If you dont mind using a library, i use lwjgl,and make spritesheets using texturepacker.

Texturepacker generates xml files for textures automatically, and places the textures all on one png.

Once i do that, i use gimp, and just use the eraser tool until the background is transparent.

Then in your program you just have to type

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

and the transparency should work automatically, its a bit more of a pain to actually set up accessing the spritesheets and such though

于 2013-08-23T02:28:59.693 回答