When I first started integrating Box2D into my Cocos2D project, I found the whole process a little jarring. While I’d used C++ before, this was the first time I’d seen it mixed with Objective-C. This code snippet simply wraps the standard Box2D Debug calls from GLES-Render.h (included with Cocos2D) in it’s own CCLayer, so that you can implement it quickly and easily. It also allows you to turn the layer on an off easily as you would any other CCLayer.
In this tutorial series we’ll build a cool catapult type game from scratch using Cocos2D and Box2D!
We’ll use the by Ray’s lovely and talented wife Vicki to create a game about catapults, acorns, dogs, cats, and angry squirrels.
In this tutorial series, you’ll learn:
How to use rotation joints
How to use weld joints
How to have the camera follow a projectile
How to use a collision’s impact ‘force” to decide if it should eliminate an enemy
And tons more!
This tutorial series assumes that you’ve already gone through the or have equivalent knowledge. It also uses a bunch of concepts found on the How To Create A Breakout Game with Box2D and Cocos2D Tutorial ( and ).
Box2D is a great physics engine, but while there are some iOS code examples out there – there really aren’t too many tutorials around utilizing the iOS platform that also demonstrate the fundamental principles used by the engine.
I’ve found one tutorial that does a great job of explaining some of the more intermediate Box2D tutorial topics utilizing Cocos2D iPhone – specifically addressing Forces, Ray Casts and Sensors. I previously mentioned the first part of this tutorial which was created using LevelHelper and SpriteHelper (which are not required for this portion of the tutorial).
The tutorial demonstrates the creation of a Kid Icarus style platform game, and utilizes sensors and ray casts so the enemies can attack the game character with intelligence, and applies forces to keep the enemies floating in the air. The tutorial also demonstrates how to create a HUD overlay in Cocos2D for the game menu, and life tracker.
Here’s a video demonstrating the tutorial in action:
Overall, I think it’s a great tutorial on building a platformer. Personally I really never thought of using Box2D for some of the functionality it’s used for in the tutorial, but it definitely makes things easier once you have a basic understanding.
Recent Comments