Open Source Library For Easy Box2D Collisions In Cocos2D-iPhone Games (Uses Physics Editor)

Some time ago I wrote about the excellent Physics Editor tool, a highly polished editor allowing you to automatically trace objects and export the resulting vertex information for use in a number of game development frameworks such as Cocos2D-iPhone.

In order to use the vertex data for collision detection in Cocos2D you will need to set it up as a Chipmunk or Box2D application, set up your world, and collision bodies.

Today I came across a library that allows you to bypass all that – you no longer will need to set up your Cocos2D game as a Box2D game to get Box2D based collisions.

As stated in the readme for the library:

  • Use PhysicsEditor to trace out the lowest resolution sprites used in your project. It’s important to use your low-res sprites to ensure PESprite works properly.
  • Set each sprite’s anchor point in PhysicsEditor, which will be used automatically by PESprite. Ignore the other properties.
  • Set PhysicsEditor’s Exporter to “Box2D generic (PLIST)” and export the plist file to your Resources folder.
  • Then just write some code…

You can find the library from Fly Guy developer Jay Eleraj  on Github here.

Examples are included.

A very handy bit of Cocos2D code.

 

©2012 iPhone, iOS 5, iPad SDK Development Tutorial and Programming Tips. All Rights Reserved.

.

DeliciousTwitterFacebookLinkedInEmail


Leave a Reply

Your email address will not be published. Required fields are marked *