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:
You can find the tutorial in 3 parts here – full source code is provided so you can jump right to the second part if desired:
Pt.1 How To Use SpriteHelper And LevelHelper
Pt.2 Intermediate Box2D Physics
Pt 3. How To Create A HUD Layer With Cocos2D
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.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.
The resources we feel will appeal to our readers the most will be posted on the front page.