0

Wrapping Box2D Debug into a Cocos2D Layer

-

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.

(more...)

0

How To Make a Catapult Shooting Game with Cocos2D and Box2D Part 1

-

In this tutorial series we’ll build a cool catapult type game from scratch using Cocos2D and Box2D!

We’ll use the art created 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 Intro to Box2D with Cocos2D Tutorial: Bouncing Balls Tutorial 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 (part 1 and part 2).

(more...)

0

Tutorial: Using Cocos2D iPhone and Box2D To Easily Create A Platform Game

-

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.

 

Tutorial: Using Cocos2D iPhone and Box2D To Easily Create A Platform Game | iPhone, iOS 4, iPad SDK Development Tutorial and Programming Tips.