1

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 use 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).

Community
  • 1
  • 1
Nick Bolton
  • 38,276
  • 70
  • 174
  • 242

4 Answers4

4

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.

Andy
  • 2,977
  • 2
  • 39
  • 71
  • Thanks. It looks to me like your advice is to *use LibGDX*. AndEngine is good for those who have not developed a game before, but because I have made games in the past, I personally found it quite limiting. Also, yes, AndEngine does use native Box2D (it actually uses the libgdx/badlogic Box2D library). – Nick Bolton Dec 26 '10 at 14:28
  • Look at the benchmarks between AndEngine and libGDX. LibGDX is far superior performance-wise. –  Aug 27 '11 at 00:14
1

Have you seen AndEngine? You can take a look at this app: Farm Tower. They used AndEngine to write it, and it uses physics.

Cristian
  • 198,401
  • 62
  • 356
  • 264
0

Cocos2Dx because of portability, effects and game performance

Duna
  • 1,564
  • 1
  • 16
  • 36
0

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.

ssantos
  • 16,001
  • 7
  • 50
  • 70