LibGDX - Conditionally use java or android classes

前端 未结 1 676
甜味超标
甜味超标 2021-01-28 19:24

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 androi

相关标签:
1条回答
  • 2021-01-28 19:57

    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.

    0 讨论(0)
提交回复
热议问题