Category Archives: box2d

Cocos2d-x and Box2D using LevelHelper


Coding a complicated physics game without the right tools is tedious and slow.  Fortunately there is a tool that makes this work easy and fast so you can concentrate on creating a great game.

LevelHelper along with SpriteHelper are excellent tools for creating sprite sheets and generating usable physics code.  The author of this tool, Vladu Bogdan, is constantly improving the tools allowing you to easily create levels for your games complete with physics working with your sprite sheets taken from SpriteHelper.  The tool allows instant testing of the physics using the built in Scene Tester.

The software only works for the MAC and it is well worth purchasing a MAC just for this tool as it will save weeks and months of work for your development project.  The author supports cocos2d-x which can be run on several platforms.

The software can be purchased in the Apple App store, more information can be found at

Ray Wenderlich has excellent tutorials for cocos2d and Vladu has contributed an excellent tutorial series using LevelHelper and SpriteHelper.

Part 1

Part 2:

Part 3:

Part 4:

The final code for this tutorial series has been converted to cocos2d-x and will be posted soon.  Using cocos2d-x and Marmalade SDK it was an easy task to get the finished game onto the Kindle Fire.


Cocos2d to Cocos2d-x

The difference between the Objective-C and C++ code can be viewed here and can be used as an aid to converting between the languages for cocos2d to cocos2d-x conversions.


Radial Gravity with Cocos2d-x


A simple but interesting demo of using Cocos2d with Box2D physics can be found at

The Objective-C code using Cocos2d can be found at that link.

Converting it to Cocos2d-x and C++ was very easy and provides another good example of porting existing Cocos2d code to various platforms using C++.

Most of the code on this blog can also be deployed using the native code from Cocos2d-x or Marmalade SDK  for those that are targeting multiple platforms.  Just look for the include “mkb” file.


The only part about this post that was tricky was doing the Box2d debug draw but luckily the code is included in the Box2d test code in Cocos2d-x.  The extra files required were GLES-Render.cpp and GLES-Render.h and they are included.

The source code can be found at:

You will need to have the cocos2d-x development environment.  Load the cocos2d-win32.vc2008.sln (for example) and just add the  RadialGravity.win32.vcproj to the solution.

The code has been updated and tested with cocos2d-1.01-x-0.11.0 release that includes and updated version of Box2D.