Crispy91
Crispy91

Reputation: 77

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

Upvotes: 1

Views: 1726

Answers (1)

P.T.
P.T.

Reputation: 25177

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.

Upvotes: 2

Related Questions