简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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