Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (653)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Physics on Android  (Read 7895 times)
0 Members and 1 Guest are viewing this topic.
Offline hell32.dll

Senior Newbie

« Posted 2009-11-02 13:23:29 »

did some physics libraries have ported to android?
what is better for perfomance? (2d)

Sorry i'm bad speak English =)
Offline badlogicgames

« JGO Bitwise Duke »

Medals: 75
Projects: 2

« Reply #1 - Posted 2010-03-18 21:21:58 »

I know this is an old topic but i thought i'd resurect it to offer some useful info.

For fun i tried JBullet on Android. The good: no garbage collection issues! The bad: it's bat shit slow. You can find a demo of it at I also did a quick JNI binding for the native lib and it has much better performance.

JBox2D is completely unusable as it produces so many short term objects that the GC goes crazy. The only way to get a proper and fast enough physics simulation up and running at the moment is to write JNI bindings to your favorite native physics library like Box2D, chipmunk or Bullet. - musings on Android and Java game development
Offline martineriksen

Junior Devvie

« Reply #2 - Posted 2010-03-31 08:19:11 »

Hmmm but there are some games out there using Box2D or similar. Anyone knows how they are made? JNI bindings to Box2D? Camel Games has a few games like that - ShootU, Blow it Up, Crayon Physics clone. Any ideas?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline badlogicgames

« JGO Bitwise Duke »

Medals: 75
Projects: 2

« Reply #3 - Posted 2010-04-05 09:13:50 »

Camel Games simply wrapped Box2D via JNI. There's sadly no alternative to this in pure Java given the weak Dalvik VM. - musings on Android and Java game development
Offline Mr EEK

Senior Newbie

« Reply #4 - Posted 2010-08-09 10:07:57 »

I tried using the (most excellent) phys2d library during the early stages of writing Word Drop.  It ran very slowly, with the main culprit seeming to be garbage collection.  If I ever really needed 2D physics for a new game, I will definitely take a look at it again - maybe with a few object pools it would start to look pretty workable.

P.S. Sorry for reviving a long-dead thread!
Offline ewjordan

Junior Devvie

« Reply #5 - Posted 2010-08-10 18:13:40 »

For 2d physics, what we're using at the moment is the Emini engine (, which seems to run pretty well (it was originally developed for J2ME, so it's garbage-free and written using fixed point math).  The only problem is that it costs money to use in a game, so I know that might be a show-stopper for some.  It also doesn't have as many features as most of the Box2d-inspired engines, and as we all probably know (maybe we've blocked it out of our memories by now?), dealing with fixed point math in Java is a major pain in the ass because of the limitations of the language.

And yes, I do notice the irony that as one of the developers on JBox2d I'm going to be paying to use a closed source engine with fewer features, and I'm not terribly pleased about that, but it's the shortest path to market at the moment... Smiley

The JNI bindings to Box2d seem decent, AndEngine ( has all of that set up inside the engine if you're interested.  You can get a sense of performance here:

For us that's not an option because we're using a different framework that for various reasons makes using JNI very tricky.

@Mr EEK: I'm not sure if a few object pools will be enough, sadly.  Locally I've gotten JBox2d down to almost zero garbage (I probably chopped away 99% of the allocations in the entire engine), and it's still not as fast as I'd like, even on my Nexus One.  With 100 stacked objects, I'm ending up with about 20 fps, which is half the frame rate that AndEngine gets with the native binding (though to be fair, the drawing method that I've been using during debugging is extra slow b/c it's not using OpenGL, and I have no idea what sort of test config AndEngine uses, it might not be a full pile-up like I've been testing).

I think one of the problems is that the performance characteristics of Dalvik are very different from Hotspot, which we've gotten used to optimizing for over the years.  In particular, things like getters/setters which are almost free on Hotspot are very costly on Dalvik ( - there's a 3x speed penalty on crappy phones w/o JITs, and a 7x penalty on the ones with JITs!  I suspect this might be a large part of the reason that the native bindings work faster, the compiled code doesn't pay these penalties.

I'm going to see if JBox2d does any better when I pull out the getters/setters, but I'm not overly confident at the moment about finding any magic bullets for this...profiling seems to show no serious unexpected bottlenecks, compute time is pretty well distributed across the engine in proportion to where the actual work needs to happen, which leads me to think that without some major by-hand optimizations specific to Android (possibly including moving some code to use fixed point...blech), I may just be up against a performance wall.
Offline Mr EEK

Senior Newbie

« Reply #6 - Posted 2010-08-13 12:42:19 »

Thanks ewjordan, really interesting post and links...sounds like I was having a fit of ludicrous overconfidence with the "a few object pools" remark  Smiley
Offline hell32.dll

Senior Newbie

« Reply #7 - Posted 2010-09-17 10:01:20 »

Hi there  Grin

i'm back to develop android game with physics but for this moment i'm need a 3d physics engine (like ode) for android. the game scene will be not so big : <35 objects like primitive cylinders. But i'm looking for a faster engine for android  (also not eating much memory)

What the engine will be better?

Sorry i'm bad speak English =)
Offline zammbi

JGO Coder

Medals: 4

« Reply #8 - Posted 2010-09-17 15:06:16 »

But i'm looking for a faster engine for android  (also not eating much memory)
Tried JPCT ? The only one I know of that works quite good.

Current project - Rename and Sort
Offline hell32.dll

Senior Newbie

« Reply #9 - Posted 2010-09-21 14:56:58 »

Tried JPCT ? The only one I know of that works quite good.

Wow, looks pretty nice, and i will don't need to make bicycles bymyself =) but as i see it uses jBullet?

Sorry i'm bad speak English =)
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

SHC (27 views)
2015-08-01 03:58:20

Jesse (19 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (36 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (30 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!