问题描述
当尝试从该库中初始化BodyEditorLoader时出现此错误 http://www.aurelienribon.com/blog/projects/physics-body-editor/
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)
我该如何解决?
推荐答案
基于此 https://github.com/libgdx/libgdx/issues/2393 问题是因为在创建形状之前未加载本机.
Based on this https://github.com/libgdx/libgdx/issues/2393 the problem is because natives aren't loaded before creating shape.
有两种解决方案:
首先是在创建任何形状之前创建World
实例.
First is creating World
instance before creating any shapes.
第二个在创建任何形状之前调用Box2D.init();
.此方法是首选方法,因为您无需创建World
实例,而且更明显.
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.
使用此版本 https://gist.github.com/grulg/8691e7ee7709367ce165 代替Google代码中的版本.
Use this version https://gist.github.com/grulg/8691e7ee7709367ce165 instead of version from Google Code.
这篇关于物理主体编辑器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!