Box2D rope, Javascript vs Objective-C

167 Views Asked by At

I had a question for the experienced fellers. I'm trying to produce a game where you move an object with a chain hanging below it, I'm using Box2DWeb and EaselJS with HTML5/CSS and I plan on wrapping it with PhoneGap once I get it running properly. I've been testing on OSX Google Chrome which works great, and iOS Safari and have found I am already running into a performance issue on the iPhone with the chain - having profiled it, it is the biggest culprit.

It is a series of 25 small bodies linked together by revolute joints. I've played with a ton of different methods (including rope joints) and this is the way I get the least stretch and bounce (I want it to be a rope). I wondered for a start - does anybody know of a better way to produce rope with Box2D? And for two, other than reducing step iterations, reducing link bodies etc, is there any way to do it without sucking performance?

And my MAIN question for the guys who know a bit about PhoneGap/JS games - is a 25body chain at 30fps asking too much of this implementation? Or might I get away with it?

I know AS3.0 well and JS 'OK', I think starting over in ObjectC/C++ will turn this into a year long project as I don't even know the first thing to ask Google...

Thanks in advance! Josh

1

There are 1 best solutions below

0
On

I have found in our own projects ( C++ based ) that amount of vertices on dynamic bodies heavily affect the performance ( iOS devices are not between the best performing ones ). In your case I assume its going to be 25 square bodies (4 vertices each), plus the body at the end of the chain, which are all active at the same time. All that is going to affect the performance quite a bit.

I would try to fiddle around with rope joint instead. The only other thing I can think of is if you are using squares as a links in the chain, try using circles. I found that they are much better in performance, but the behavior of the chain will change. You can put limits on the revolute joints to contols that through.