AS3 Box2d on mobile

To say the least I am disappointed. I have tried box2dflash, I tried quickbox2d, quickb2, wck and all do not perform well on mobile devises using air for android.

My closest and best results were with quickb2, but once I added skins(actors) to the mix. Rather they were sprites, movieclips, sprites cached for bitmap. It all slowed down and I have bad frame drops.

I'm at the point were tonight I am going to try Corona Anasca and see how the physics are handled there and if I get better performance. I;m just not happy about having to get use to different tools and a new syntax. However, I have to give it a try...
In my opinion, Flash isn't fast enough to do a very complicated physics-based mobile game, except maybe on the very latest smart phones, and even then, it's tough. I don't think physics processing is the main problem, but your absolute best physics performance will be from using Alchemy Box2d directly. QuickB2 and WCK add another API layer to Box2d-Alchemy, but I don't think either of them add very significant overhead.

Graphics is the main problem though. I would suggest looking at cacheAsBitmapMatrix (http://help.adobe.com/en_US/FlashPlatfo ... bject.html) as a first step. Your other option that is coming soon is the Molehill API (http://labs.adobe.com/technologies/flas ... ehill.html), which will provide a hardware-accelerated graphics context.
I looked at cacheAsBitmapMatrix and did some gpu and cpu test. Still a no go.

I'll check out molehill though for sure and see if I can start working with it and by the time the game is done maybe release.

However, I may just work with Anasca Corona as I did some test and the test came out nice. Handles physics very well. Problem is that now its more money to dish out to use the tools.


AAAHHHH!!!
I take it you're testing on a Android phone? then try downloading the latest AIR 2.6 and Flash Player 10.3 from the Android Market, both came out very recently (within the last week i think) and have performance enhancements.

I've not tried the others but i can get WCK running well. With the demo file thats included with WCK nearly all demo's run at a constant 30FPS. I publish using Flash CS5.5 with GPU acceleration enabled.
This is on a Samsung Galaxy S2 though, it's the fastest phone around at the moment with a dualcore 1.2GHz CPU. I would only try Box2D physics in Flash on the very latest phones with dualcore CPU's 1GHz or higher, anything else just dont have the processing speed.
Beany wrote:I take it you're testing on a Android phone? then try downloading the latest AIR 2.6 and Flash Player 10.3 from the Android Market, both came out very recently (within the last week i think) and have performance enhancements.

I've not tried the others but i can get WCK running well. With the demo file thats included with WCK nearly all demo's run at a constant 30FPS. I publish using Flash CS5.5 with GPU acceleration enabled.
This is on a Samsung Galaxy S2 though, it's the fastest phone around at the moment with a dualcore 1.2GHz CPU. I would only try Box2D physics in Flash on the very latest phones with dualcore CPU's 1GHz or higher, anything else just dont have the processing speed.


Absolutely. I just published out the WCK demo to my OG droid 1 and just about fell over laughing. 5 - 11 fps w/ GPU and the whole nine yards. Obviously, WCK is not usable for the foreseeable future considering a huge portion of my app sales and downloads thus far have been Android 2.2 on mid-range devices. I would strongly suggest (not to sound all preachy) if you are going to use WCK, get in there and modify the heck out of the XML so that a very select range of devices can even download your app. Otherwise you'll get a lot of bad reviews right out of the gate which are very hard to recover from.
This is all very disappointing to read.

I don't personally use WCK, I use the box2d 2.1a hard-code method, and am currently deploying to a nexus S for testing. I don't have anything skinned at the moment, so obviously there is a lot of the FPS taken up there, but I'm currently getting pretty good FPS out of the nexus, I realise that's a fairly new device and all, and I'm running with the latest AIR and Flash Player (out this week just passed.)

The thing that I think will kill most developers for Android is skinning and the like, because I'm doing some pretty technical physics stuff and I'm not really finding there to be much of a performance hit. I'll try a little more tonight to see what sort of level I have to get to before it starts to struggle with the amount of calculation.

I'll get back to you.
I recent bought a modest android phone.
I test my game Color Infection 3 on it: http://www.tapirgames.com/Games/ColorInfection3.
For most levels, the fps is acceptable.
But for some complex scene levels, such as the water level, the fps is not good, about 6 fps I think.
The fps is worse if there are many movable shapes.

Some facts:
- My new phone is equipped with a MSM7230 800Mhz CPU and a separated graphics card.
- Flash player 10.3 for android is installed.
- The game doesn't use bitmap images. So maybe it will be little slower when bitmaps are used. I have heard that in recent months, flash player for android has been improved much. So I doubt using bitmaps will decrease fps too much.
- The game uses fbox2dr143. (r143 is the revision of the c++ version)
- The game simulates 2 physics steps per graphics step. So for the water level, it is able to get a higher fps, at least 10 I think. If you use box2dflash 2.01, the fps would be even better, I think it will be 15-20 fps. For most coming new android phones and iPhone 5, a separated graphics will be equipped and the CPU will be about 2x1.5Ghz. For flash can only use one CPU, So it is expected the water level could get a 20-40 fps later. I think the water level is more complex than most physics levels in all the pc flash physics games I have ever played.

btw, I have synchronized fbox2d with c++ from r143 to r197, but there is no fps improvement.
We are running box2D on Android in our game and would like to port to BADA platform, which is Flashlite 4.0.
Does anyone know how we can compile the Box2D.swc as a flashlite 4.0 file?

Since this in an include, the current Box2D.swc is compiled as flash 10.0 which is not supported on BADA.

-harper
I'm using a Stage3D (aka Molehill) framework called Starling for a game I'm working on at the moment. I updated QuickBox2d so it is compatible with this framework and uses the Box2d Alchemy port. As already mentioned, I think most of the performance issues are related to skinning and not Box2d. I've had trouble getting decent fps on mobile with any flash project, including those without Box2D. It is basically a no-go until Stage3D for mobile is released and then something like the solution I'm working on will *hopefully* run like butter. Correct me if I'm wrong but I don't think there is a release date for this yet, though they are working on it and it should be out beginning to middle of 2012.
I have found that if you package your game SWF file into an Ipa using Flash Builder, it can improve performance and compile things better!

SWF to Iphone Flash Builder Tutorial:
http://renaun.com/blog/2011/05/using-flash-builder-4-5-to-package-arbitrary-swfs-for-ios-android-and-playbook/

Hope that helps! I packaged it for the iPhone but I haven't tried android or playbook.

Original thread: https://box2d.org/forum/viewtopic.php?t=6890