简体   繁体   English

删除Sprites颜色键libGDX

[英]Removing a Sprites Color Key libGDX

I am trying to remove the color key from a sprite. 我试图从精灵中删除颜色键。 In this case my sprite backgrounds are purple. 在这种情况下,我的精灵背景是紫色的。 I have tried using the spritebatch setColor() function, but that turns the whole screen to the sprites background color. 我已经尝试使用spritebatch setColor()函数,但这会将整个屏幕变为精灵背景颜色。 does anyone have a solution on how to remove the color? 有没有人有解决方法如何删除颜色?

Thanks for any help 谢谢你的帮助

I don't think libGDX (or OpenGL ES) support "colorkey" transparency. 我不认为libGDX(或OpenGL ES)支持“colorkey”透明度。 As far as I know, everyone just uses an alpha (transparency) channel in the image. 据我所知,每个人都只在图像中使用alpha(透明度)通道。 (In addition to red, green blue, each pixel has an alpha value representing its transparency.) (除了红色,绿色,每个像素都有一个代表其透明度的alpha值。)

If you remove the background color in an offline tool and save the image with transparency information you should be fine. 如果在离线工具中删除背景颜色并使用透明度信息保存图像,则应该没问题。 (And I believe this is what most existing libGDX apps do.) (我相信这是大多数现有的libGDX应用程序所做的。)

Alternatively, you can probably do this at runtime by defining a shader that converts colorkey pixels into transparent pixels. 或者,您可以在运行时通过定义将colorkey像素转换为透明像素的着色器来执行此操作。

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

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