Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overlay color on texture in libgdx?

I'm using texture and textureAtlas in libgdx. This textures loads images of white circle.

How can I overlay its color with another color? Or maybe their is another approach for this?

private final static TextureAtlas textureAtlas = new TextureAtlas(Gdx.files.internal("spritesheet.atlas"));
private final static TextureAtlas.AtlasRegion texture = textureAtlas.findRegion("Bubble.001");

EDIT: As I said I have a white circle and I want to make it red (without the need for another image with a red circle)

like image 738
Alex Kapustian Avatar asked Oct 21 '22 05:10

Alex Kapustian


1 Answers

You can use the lerp method in Color class.

actor.setColor(Color.WHITE.cpy().lerp(tintingColor, .5f));

lerp changes your Color object, so use the cpy command before it to preserve the original color. In this case I use WHITE as my original color, which preserves the color of your Actor's texture. lerp will overlay the tintingColor with a strength of 50% in this case.

like image 133
Jose Martinez Avatar answered Oct 23 '22 21:10

Jose Martinez