5
votes

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)

1
You need to clarify what you mean by overlay. Very vague word.Tenfour04
you can use spriteBatch.setColor to set a tint-color. Everything drawn with the spritebatch will then be tinted.Robert P
It doesn't work on white color...Alex Kapustian
If you are using Sprites instead of manually submitting texture regions to the sprite batch, then use sprite.setColor instead. If that doesn't work, you need to explain exactly what you're using for the texture. A PNG file with alpha channel?Tenfour04
Did you ever find a solution to this? I have the same problemJose Martinez

1 Answers

3
votes

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.