Android 有没有像样的物理引擎?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1034253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there any decent physics engines for Android?
提问by Marc
I've looked around for a physics engine that will play nicely with Android, but I've only been disappointed.
我四处寻找可以与 Android 完美配合的物理引擎,但我只感到失望。
In terms of performance, I had heard that jbox2d was the best bet, but (from my understanding) ever since Android SDK V1.0, the Dalvik VM's verifier has become very strict and rejects some of the key classes and refuses to run. This problem persists after using the dx tool (although I might be using the tool improperly).
在性能方面,我听说jbox2d是最好的选择,但是(根据我的理解)从Android SDK V1.0开始,Dalvik VM的验证器变得非常严格,拒绝一些关键类并拒绝运行。使用 dx 工具后此问题仍然存在(尽管我可能未正确使用该工具)。
I know that the AndroidBox2D porting project exists to optimize jbox2d for the Android garbage collector, but the project page doesn't have any downloads and the gpl license isn't as attractive as the zlib license of the original.
我知道 AndroidBox2D 移植项目的存在是为了优化 Android 垃圾收集器的 jbox2d,但是项目页面没有任何下载,并且 gpl 许可证不如原始的 zlib 许可证有吸引力。
Does anyone have any tips for making jbox2d work in Eclipse, or have any recommendations for where I should start looking?
有没有人有让 jbox2d 在 Eclipse 中工作的任何提示,或者对我应该从哪里开始寻找有任何建议?
采纳答案by sehugg
I don't know why Dalvik would reject classes unless they were obfuscated with some tool. Did you try recompiling Box2d from source?
我不知道为什么 Dalvik 会拒绝类,除非它们被某种工具混淆了。您是否尝试从源代码重新编译 Box2d?
The only other Java lib I've seen is http://www.cokeandcode.com/phys2d/
我见过的唯一其他 Java 库是http://www.cokeandcode.com/phys2d/
回答by John
I am getting good results with the Java version of APE using Fixed Point math rather than floats.
我在 Java 版本的 APE 上使用定点数学而不是浮点数获得了很好的结果。
回答by Michiel
I have done an implementation of the APE engine now using (mostly) fixed point math and it is without garbage collection. Its a pretty nice engine to do stuff with constraints but seems less suited for really rigid bodies.
我现在使用(主要是)定点数学完成了 APE 引擎的实现,并且它没有垃圾收集。它是一个非常好的引擎,可以做有约束的事情,但似乎不太适合真正的刚体。
http://code.google.com/p/ape-physics-for-android/
http://code.google.com/p/ape-physics-for-android/
You could also look into the NDK port of Chipmunk (download link on youtube page)
您还可以查看 Chipmunk 的 NDK 端口(youtube 页面上的下载链接)
回答by sehugg
Also look @ Glaze which is optimized for arrays .. might not be a horrible port to Java from AS3 (it was ported to Haxe also)
也看看针对数组优化的@ Glaze .. 可能不是从 AS3 到 Java 的可怕端口(它也被移植到 Haxe)
回答by deneb
I am not sure, if jBox2D is really suitable for smartphones. I would rather look at J2ME engines, as they are highly optimized for performance- E.g: http://emini.at
我不确定 jBox2D 是否真的适合智能手机。我宁愿看 J2ME 引擎,因为它们针对性能进行了高度优化 - 例如:http: //emini.at
Also you should have no problems with integration.
此外,您应该没有集成问题。
回答by Brad
Libgdxhas JBox2Dbuilt in and is cross platform (Android, Java Desktop, GWT Web) like Unity, tho it's free and open source.
Libgdx有JBox2D内置的,是跨平台(Android,Java桌面,GWT的Web)一样团结,寿它的免费和开源。
I got it set up in 15 minutes and was creating physics bodies in no time. The Libgdx physics manualhelps from there. Good luck!
我在 15 分钟内就设置好了,很快就创建了物理实体。该Libgdx物理学手动从那里帮助。祝你好运!