iPhone port of Box2D Testbed now available

Box2D (the great physics engine that looks after all those seesaws, pinwheels, catapults, and bombs that the Rolandos encounter ) is perfect for all those out there working on 2D games. When I started working on Rolando there were a few things that took me a little while to integrate, as the normal testbed would not compile on the iPhone, and the renderer was incompatible.

I’ve just added a port of the Box2D testbed to the project, which should hopefully help anyone that is planning on using it on their iPhone projects – you should be able to just build and go. Its got an OpenGLES renderer, and allows you to use the touchscreen and accelerometer to interact with the environment. Here’s some instructions on how to interact with it:

  • On the first screen, choose the test project that you would like to run.
  • Drag an object around the environment using your finger, or just drag on an empty part of the screen to pan around.
  • Tilt the iPhone to affect gravity.
  • Double tap to return to the projects list

I hope this of use to any budding iPhone developers out there!

You can download the Box2D engine (including the iPhone testBed) from here.

(note) For some reason the embedded video sometimes plays back at enormous speeds :/

36 Comments

matax  on January 15th, 2009

Thanks a lot.
For Rolando, that I didn’t play yet (my iPod Touch is in care from 3 month) and for this TestBend, very usefull for anyone that wants to start a 2D app

matax  on January 15th, 2009

I cant find iphone testbed in the link

handcircus  on January 15th, 2009

Ah yep you’ll need to grab it from the SVN repository:

https://box2d.svn.sourceforge.net/svnroot/box2d/

You’ll need a subversion client like Versions.app or TortoiseSVN

fazeaction  on January 15th, 2009

HandCircus thanks for sharing!!. It’s a great contribution for emerging iphone scene.

matax  on January 15th, 2009

Thanks

Ollie  on January 15th, 2009

That’s funny, I actually just got box2d running and rendering on the iphone only yesterday! Getting to that point was a great learning exercise for me, looking forward to checking out any differences in the way we’ve done it!

jon  on January 16th, 2009

Hmm… is this in the Examples directory somewhere in repository?

Thanks for releasing this (as soon as I find it)!

handcircus  on January 16th, 2009

The iPhone project is in Build/iPhone

jon  on January 16th, 2009

Got it. Thanks again!

ddavies  on January 17th, 2009

Awesome! I just downloaded Box2D a week ago and was testing it on Windows, but really wanted to do some iPhone development. Just downloaded on my Mac and running in the simulator. Nice. So this is what you used for Rolandos? Very good. Maybe an example of how to overlay the bitmaps on top of the vectored objects?

ddavies  on January 17th, 2009

One more question. Do I have to do anything special for OpenGL? Will it work on the simulator. Right now Box2D seems to be crashing quite often. I have not bought an iPhone or iTouch yet. Will I HAVE TO HAVE one or can I start development on the simulator? Thanks for contributing to the community.

développement de jeux sur iPhone | tweenpix  on January 18th, 2009

[...] Flash (encore un décidément !) mais surtout brillant auteur de Rolando vient de publier un portage du Testbed de Box2D. Ce portage en Cocoa Touch fonctionne sur iPhone et iPod Touch et prend en charge l’écran [...]

Ollie  on January 20th, 2009

Checked out your code, it’s almost identical to mine (which I find encouraging ;)

Just one question, in your version and the original version I made, there’s timer set to 1.0 / 60.0 which triggers a world step and screen redraw – this works as expected in the simulator, but when testing on the actual device, everything seems to run very slowly (approximately half speed from what I can tell)

How did you solve this issues in Rolando? I’ve managed to “fix” it by setting the world time step to 2.0 / 60.0 but this is just a hack and I’m not really sure why it works in the first place.

Anyway, thanks again for releasing your code :)

mattr  on January 24th, 2009

the box2d iphone testbed would be a top ten free app for sure! :)

TGL - TGL֥ : Box2D Physics Engine  on January 26th, 2009

[...] iPhone port of Box2D Testbed now available Box2D Physics Engine (0) [...]

SIGNAR | Blog » Box2d: Bringing 2D physics to screens everywhere  on January 27th, 2009

[...] These have all been done through porting box2d from C++ to Obj C. Which means writing their own renderers and touch listeners for interaction. Good times however, now there is a released port of the Box2d testbed with working interaction from the touch sensors and the accelerometer. Check out this post explaining things a little bit better here. [...]

Martin  on February 1st, 2009

Great thing! I’ve spent couple of days trying to figure out how to use it with apple’s Texture2d class which I use for rendering all graphics.
I guess I am just not very good with mixing Obj-C with C++ so if can someone provide a sample class that renders Texture2D objects, that would be awesome.
Cheers

Stephan  on February 2nd, 2009

I get an error when compiling:
‘b2random’ was not declared in this scope (related file: iPhoneTest.mm
And 13 x this error
‘RandomFloat’ was not declared in this scope (related to several files)
I’m not experienced with C++, could anybody help on this?

iPhoneDev. » 物理演算ライブラリBox2D公開  on February 2nd, 2009

[...] 物理演算ライブラリBox2DのiPhoneポーティングがオープンソースとしてsourceforgeで公開されています。 Rolandoなどを開発したHandCircus社のテストベットです。 iPhone port of Box2D Testbed now available [...]

handcircus  on February 3rd, 2009

OK – just committed some fixes for the latest SVN version

Manjit Bedi  on February 11th, 2009

Hi, I really appreciate the work you have done. I have got the latest build from SVN. When I do a build I am getting various errors like:

error: ‘class b2world’ has no member named ‘InRange’

It seems various source files are being referenced by the xcode project that are not in the distriubtion.

Thanks

イナヅマtvログ » iPhone で Box2D  on February 16th, 2009

[...] iPhone port of Box2D Testbed now available [...]

asmosdeus  on February 18th, 2009

i downloaded box2d but i can’t find the ipod file,whats file name?

Mobile Cheng  on February 28th, 2009

hello, there is a error: Request failed on ‘/svnroot/box2d/’, Server certificate verification failed: issuer is not trusted (https://box2d.svn.sourceforge.net) . I use the Subversion Mac client SCPlugin-0.7.2-1.4.6.
Look forward your reply, Thanks.

mike d’s » Blog Archive » iPhone and box2d  on March 10th, 2009

[...] been playing around with box2d on the iPhone using a port of the box2d library done by Hand Circus. Hand Circus created the iPhone mega-hit Rolando. With [...]

Manjit Bedi  on March 12th, 2009

Hello again,

I posted a few weeks ago that I could not build the iPhone test bed. Well, I am happy to say it is working now. I went and new checkout and it built this time and is working. Woot!

And I have been playing the game Rolando; boy, some of the levels are tricky and quite challenging.

Thanks again.

Mike  on March 31st, 2009

Hi Guys,

I worked with Box2D in Flash AS3 and are now trying to get it to work in iPhone SDK.

But everytime I try to “Debug and Go” the project (“Box2D.xcodeproj”)that are place in “Box2D”-”Build”-”Xcode” I get the error message:

No launchable executables present at path.
[...]/Box2D/Build/Xcode/build/Debug/HelloWorld

Any ideas?

Kcaz  on April 14th, 2009

Yes mike, you are using the Xcode project, but you want the iPhone project. If you got the folder off of svn then after Xcode there is another folder called iPhone, use that one. If you don’t know what svn is, google versions.app and download it. One of the comment on this forum had the svn link, so in versions click the top most bubble thing and add the URL in the correct feild. Sorry this isn’t that perfect, it’s only from memory becuase I’m on my touch right now.

Dustin James  on April 18th, 2009

How do you use sprites in place of box2D beautiful simulation graphics?

Resources: cocos2d at Under The Bridge  on May 17th, 2009

[...] with the engines of choice!” Well, here’s your followup: he ended up using cocos2d with the Box2d engine port! Over Easter I decided to drop a dimension in my iPhone project to go from a 3D evolution game [...]

Mick80234  on September 8th, 2009

Thanks very much for the iPhone port. I have just released my first iPhone game using Box2D after initially banging my head against the wall trying to do my own physics simulations and getting nowhere.

Spradan  on September 24th, 2009

I just downloaded the SVN verion of box2d, and I get 58 errors and 10 warnings when I try to build, mainly its the destructoid listener and the b2contact point, I dont know what is this, I tried cleaning and all, but Im still having problems with this, anybody had this?

Thanks

Spradan  on September 24th, 2009

Actually I was trying with the one in trunk/build, I tried again with the one in tags/… and it works, I guess thats the one were supposed to try then.

Thanks the examples are amazing, Ive worked with box2d in flash before, and with this you can do a lot for iphone, amazing, thanks a lot.

anonym  on October 17th, 2009

Can someone PLEASE upload this project somewhere on a filehoster? Im getting nuts with this reprository :(

MD  on October 25th, 2009

Hey Simon,

Is there any tutorials on how to start on some levels like in Rolando?
How would i make a level and say get a ball to roll around it, i have downloaded the testbed but don’t know what to so next to edit and play with it.. :(

Leave a Comment