Skip to content Skip to sidebar Skip to footer

Libgdx - Conditionally Use Java Or Android Classes

I'm using bezier curves in my libgdx project. I was testing the desktop version using java.awt.geom with GeneralPath but when I went to test on android, it raised an error saying t

Solution 1:

Android does not have an AWT implementation, so references to those classes won't work on Android. (On the desktop you're getting those classes from the JDK.)

Technically, you can put code that depends on AWT in your desktop Libgdx backend, and put code that depends on Android's GeneralPath in your Android Libgdx backend, and then create an interface that provide access to the right implementation from your common code. See https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code for some details. That seems like a lot of work, but it may make sense for your setup.

Alternatively, you could use the Libgdx equvialents for generic points and paths. I think Polygon and Vector2 in the Libgdx Math Package may be what you want.

Post a Comment for "Libgdx - Conditionally Use Java Or Android Classes"