Search code examples
colorslibgdxactor

apply mixed colors to actor libgdx


I am developing game in that many of balloons having different colors. I am applying color to them dynamically.

Now the problem is I am using

public Color(float r,
 float g,
 float b,
 float a)

Constructor, sets the components of the color Parameters: r - the red component g - the green component b - the blue component a - the alpha component

copied from color document

here when I am using Color constructor by passing value like

color = new Color(1,0,0,1);

it works,,

but when I am passing values to get mixed color like

 color = new Color(123,118,221,1);

this time this is not working....

please identify the problem


Solution

  • The constructor expects floats values between 0 and 1 so divide ur integer RGB by 255 to get the answer (0-255 is the range for rgb).

    Color = new Color(123/255f,118/255f,221/255f,1);

    this solves ur problem