Box2D Test iOS Application

So I started learning some Box2D to improve my skills in game programming. Box2D is a physics engine written in C++. Many games use a graphics engine but not a physics engine. The graphics engine usually accelerates the GPU graphics, but what makes movements look realistic is the physics engine.

Because Box2D is written in C++, you cannot simply use it in your iOS project, but thanks to Objective-C++ support, you can change your file extensions to .mm and then simply use C++ in your Objective-C project.

In this example, I’m not using a graphics engine, only Box2D and basic UIKit elements (UIView). The next step would be to do a similar example using a graphics engine like Cocos2D.

Source code:

4 thoughts on “Box2D Test iOS Application”

  1. Hi Dimme,

    I got your source code and tested it on iPhone 5,when I stopped accelerating for over 3 seconds,the uiviews all did not move any more,I NSLog’ed ,the accelerometer and tick functions were still working ,could you please tell me why it happened ?



Leave a Comment