简体   繁体   English

如何在Slick2D中使子画面具有透明背景?

[英]How do I make my sprites have transparent backgrounds in Slick2D?

I've used GIMP to create a sprite using a transparent background. 我已经使用GIMP使用透明背景创建了一个精灵。 Once I put it in the Image Packer the transparent background disappears and the whole image is messed up. 一旦将其放入Image Packer中,透明背景就会消失,整个图像会混乱。 After a bit of googling without finding a single useful thing I decided to use a pink background, but I can't find support for setting a pixel to alpha (I can read the pixel's color though!) 经过一番谷歌搜索后,我没有找到任何有用的东西,所以我决定使用粉红色的背景,但是我找不到将像素设置为alpha的支持(尽管我可以读取像素的颜色!)

How do I fix this and have a transparent background in my sprite (org.newdawn.slick.Image to be precise)? 我该如何解决这个问题,并在子画面(准确地说是org.newdawn.slick.Image)中具有透明背景?

Useful links: None as far as I can remember. 有用的链接:据我所知,没有。 Took me 45 minutes to jump to this site for help, so there's either pretty much nothing or literally no support. 我花了45分钟跳到该站点寻求帮助,所以几乎没有任何帮助,或者根本没有任何支持。

Are you sure the image is saved in a format that supports the transparency? 您确定图像以支持透明度的格式保存吗? For example JPG does NOT support transparency. 例如,JPG不支持透明度。 PNG does. PNG可以。

Also are you sure that when saving the picture the background is indeed transparent and not white? 您还确定在保存图片时背景确实是透明的而不是白色的吗? To double check the background is transparent the majority of image editors will display a grey and white checked grids to show transparency. 要仔细检查背景是否透明,大多数图像编辑器将显示灰色和白色的选中网格以显示透明度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM