This native application uses the accelerometer to determine the direction of gravity for the Box2D physics engine. It performs quite well given the number of computations and could probably be optimized considerably. Check out the video for a demo on the phone!
Porting the code was the easy part. Configuring Adobe Flash and setting up the Android SDK was a bit more work. Check out Lee Brimelow’s awesome tutorial on http://www.gotoandlearn.com/. If you run into problems finding your device with the adb devices command than check out my previous post. We are going to see some pretty exciting stuff around the corner with Adobe AIR for mobile devices!
Full source code can be found here. You’ll need to run through Lee Brimelow’s tutorial to configure Flash before you get started.
Tags: Accelerometer, Android, Box2d







Jon Rexeisen
July 13th, 2010
What kind of file sizes are you getting for these apps?
Tweets that mention Chris Black | blackcj.com: Box2D on the Nexus One with Adobe AIR -- Topsy.com
July 13th, 2010
[...] This post was mentioned on Twitter by Christopher Black and Ultra Red. Ultra Red said: Box2D on the Nexus One with Adobe AIR: This native application uses the accelerometer to determine the direction o… http://bit.ly/cmgvhv [...]
Chris Black
July 13th, 2010
The app from the video is 144KB. The Box2D SWC for Flash is 165KB. I’m going to work on optimizing the performance of the app but file size is looking pretty good. Do you know if there are any good comparable Android 2D engines?
Flex learner | Blog | Chris Black | blackcj.com: Box2D on the Nexus One with Adobe AIR
July 13th, 2010
[...] Follow this link: Chris Black | blackcj.com: Box2D on the Nexus One with Adobe AIR [...]
Jay
July 14th, 2010
What kind of framerates are we talking here? Have you tried running stock box2d testbed on android and comapring that to a pc in terms of fps?
Chris Black
July 14th, 2010
In the demo it runs at an average of 20fps. With two cubes it runs at 30fps but adding 3+ drops it down to 20fps. You can add up to 10 cubes before the frame rate will dip below 20fps. Static boundaries don’t seem to have an effect on the frame rate so a maze game where one object is moving and the rest are static would work well. Porting a game over from a PC version won’t perform as well. For comparison my PC can handle about 100 objects before dropping down to 20fps.
Jay
July 14th, 2010
Ouch, that is pretty terrible. I was really looking forward to doing some games with Flash box2d port for android, but 20fps with such a simple example means a “no go”.
Thanks for the reply.
Scott Janousek » Blog Archive » Community Flash Video of a BOX 2D experiment on Adobe AIR for Android
August 18th, 2010
[...] Chris posted an experiment of Box 2D leveraged with Adobe AIR for Android on a Google Nexus one. [...]