Physics Body Editor error

女生的网名这么多〃 提交于 2019-12-02 17:58:05

问题


I get this error when trying to initialize BodyEditorLoader from this library http://www.aurelienribon.com/blog/projects/physics-body-editor/

    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape()J
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
    Caused by: java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape()J
        at com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape(Native Method)
        at com.badlogic.gdx.physics.box2d.PolygonShape.<init>(PolygonShape.java:29)
        at aurelienribon.bodyeditor.BodyEditorLoader.<init>(BodyEditorLoader.java:31)

How can i fix it?


回答1:


to see the code where it is called, but I venture to say that the problem is the call to your world this must be called before here's an example:

This a example compile good:

    oWorld = new World(gravedad, dormir);
    loader = new BodyEditorLoaderNewW(
             Gdx.files.internal("data/test.json"));

This a example not compile good:

    loader = new BodyEditorLoaderNewW(
             Gdx.files.internal("data/test.json"));
    oWorld = new World(gravedad, dormir);

recive this:

java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape () J

note the difference in the world is called one after so gives:

it is possible that in the future can, need this: BodyEditorLoader - noSuchMethod

but if this is not the solution you could put some of the code, I hope you help




回答2:


Based on this https://github.com/libgdx/libgdx/issues/2393 the problem is because natives aren't loaded before creating shape.

There are two solutions:

First is creating World instance before creating any shapes.

Second is calling Box2D.init(); before creating any shapes. This method is preferred because you don't need to create World instance and it's much more obvious.

Use this version https://gist.github.com/grulg/8691e7ee7709367ce165 instead of version from Google Code.



来源:https://stackoverflow.com/questions/29831011/physics-body-editor-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!