I have managed to make a hello world JBox2D application, and it works (I have some bouncing balls). However, I just read a comment on a forum post, which claims that JBox2D produces a lot of garbage, and so causes animation to be poor. Is this true?
If yes, then what other 2D engines are available to me? I would very much like to us开发者_JS百科e a physics engine for my 2D game, even if it's just a very simple one.
Update:
Just tried running the JBox2D bouncing balls demo on my phone, and the performance was terrible. Looks like libgdx is the way to go for physics, since I think it comes with a native version of Box2D that works well on Android. As for AndEngine, this is a game engine and not a physics engine, but I may use it in conjunction with libgdx to give myself a head start.
Update 2:
I've had a quick play with libgdx and AndEngine. I've found that they're both Android game engines, but AndEngine has a less steep learing curve at the cost of being more limiting. So if you want to build a serious game, you probably want to use libgdx as it will allow you to do more (but is harder to use).
JBox2D is a port from the native version called Box2D. The native version obviously didn't need to worry about garbage collection as it was written for a language which used manual memory management (C++ I think).
The problem comes as the port for Java JBox2d hasn't been optimised, and as of such, lots of temporary variables are created which triggers garbage collections a lot and consequently really slows the framerate.
As Cristian suggested, you could try AndEngine. I can't remember if this uses JBox2d though or the native Box2D.
I would personally suggest the engine by BadLogicGames called LibGDX here:
http://code.google.com/p/libgdx/
It definitely uses Box2D natively and has the option of developing your whole application on your desktop and only porting to android occasionally for testing. Porting only needs a few lines of code and there are a couple of example apps so its not too tricky! :)
It is also very well maintained, updates are being made to it all the time!
Anyway, Hope this helps!
Andy.
Have you seen AndEngine? You can take a look at this app: Farm Tower. They used AndEngine to write it, and it uses physics.
Cocos2Dx because of portability, effects and game performance
I'd definitely recommend LibGdx
. It includes Box2d
indeed, and an easy way to build for desktop which comes in handy for quick testing. Well documented and a great community behind.
精彩评论