Removing a Sprites Color Key libGDX

心已入冬 提交于 2019-12-08 09:33:55

问题


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. does anyone have a solution on how to remove the color?

Thanks for any help


回答1:


I don't think libGDX (or OpenGL ES) support "colorkey" transparency. As far as I know, everyone just uses an alpha (transparency) channel in the image. (In addition to red, green blue, each pixel has an alpha value representing its transparency.)

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.)

Alternatively, you can probably do this at runtime by defining a shader that converts colorkey pixels into transparent pixels.



来源:https://stackoverflow.com/questions/13363353/removing-a-sprites-color-key-libgdx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!