Quick links

^ Back Home

36

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 :/

«

»

Comments

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

I cant find iphone testbed in the link

  • matax

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

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

  • fazeaction

Thanks

  • matax

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!

  • Ollie

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

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

  • jon

The iPhone project is in Build/iPhone

Got it. Thanks again!

  • jon

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?

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.

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 :)

  • Ollie

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

  • mattr

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

  • Martin

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?

  • Stephan

OK – just committed some fixes for the latest SVN version

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

  • Manjit Bedi

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

  • asmosdeus

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.

  • Mobile Cheng

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.

  • Manjit Bedi

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?

  • Mike

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.

  • Kcaz

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

  • Dustin James

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.

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

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.

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

  • anonym

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.. :(

[...] 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 [...]

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

[...] 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. [...]

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

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

[...] 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 [...]

[...] 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 [...]

Leave a Comment

Your email is never shared.