0

I am using Libgdx for the first time and wondering what is wrong with this GLClearColor statement:

 Gdx.gl.glClearColor(Color.BLACK.getRed(), Color.BLACK.getGreen(),
 Color.BLACK.getBlue(), Color.BLACK.getAlpha());

This does not compile on HTML5, however:

Gdx.gl.glClearColor(0,0,0,1);

Does work. Why is that?

ArK
  • 20,698
  • 67
  • 109
  • 136
John Davis
  • 13
  • 4

1 Answers1

0

The Color class has not methods like getRed() or getGreen() - take a look at the reference of Color.

Instead of this it has public fields like r or g. So you should use

    Gdx.gl.glClearColor(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, Color.BLACK.a);

You should always start with analysing stacktrace - I'm pretty sure that this info is there. Take a look at:


EDIT:

due to Big Tony.D comment - if you are using awt's Color class just use LibGDX's one

Community
  • 1
  • 1
m.antkowicz
  • 13,268
  • 18
  • 37
  • 1
    It wasn't specified which Color is he using. There are these method in java.awt.Color https://docs.oracle.com/javase/7/docs/api/java/awt/Color.html#getRed%28%29 – Tony Danilov Jun 02 '16 at 08:42
  • yup that's true - then answer is to use LibGDX's one :) – m.antkowicz Jun 02 '16 at 08:44
  • Thank you.. that was the right answer.. AWT's was inadvertently being used in the tutorial I was following.. changing to .r .g .b and using libgdx's was correct. – John Davis Jun 02 '16 at 19:11