Groovy Android and libgdx

I am trying to get libgdx to work with Groovy for Android ( groovy-android-gradle-plugin ).

I successfully received a test project that compiles and runs, but when the game loads, it crashes due to the lack of the y property in the Rectangle class.

When I first tried this, the game crashed while accessing the static fields of the Gdx class. For instance. when I tried to access the gl field via Gdx.gl.glClearColor(0, 0, 0.2f, 1) . I solved this problem by adding @CompileStatic to all classes.

However, as I said, this does not seem to solve all the problems.

I'm not sure if this is a problem with Groovy, because the fields are public , but also have getters and setters (the latter returns a Rectangle object) or a problem with the Groovy Android plugin. Any help here would be greatly appreciated.

Please note that I know how to get around the problem by changing the broken line: raindrop.y -= 200 * Gdx.graphics.getDeltaTime() to raindrop.y = raindrop.y - 200 * Gdx.graphics.getDeltaTime() , but to me Still, I would like to know why this breaks down, so I can avoid future problems.

+6
source share

Source: https://habr.com/ru/post/978881/


All Articles