I have three projects
- Game – Java Project
- GameAndroid – Android
- GameDesktop – Java Project
I want to access android.graphics.Color, but I’m in my Game project which is java, so i can’t do that. When I try to access Java.awt.Color insted, i’ll get java.lang.NoClassDefFoundError insted.
Is there a way to access any of these libraries ?
for example i would like to use this method:
Color.getHSBColor();
I generally recommend using
com.badlogic.gdx.graphics.Colorinstead.It has the advantage of being platform-agnostic – but do note the implementation differences between the analogues.
For example, compare Android’s implementation (AWT’s works in the same fashion) :
and the libgdx implementation:
As you can see, the ordering in the encoding is different. Here’s the source code
for reference.
If you’re looking for stuff such as HSB->RGB conversion, this can be implemented “manually”. See this answer, for example – but remember to use the libgdx implementation to generate the actual int from the RGB components!