By Andy Korth and Scott Lembcke. Howlingmoon Software.
Good news everyone! Cocos2Dv3 will have an official, fully integrated, Objective-C physics engine.
One of the big features that Lars wanted to implement for Cocos2Dv3 was an easy to use, integrated physics engine. Cocos2D has supported external physics engines and even provided some utility classes to work with them, but what if the physics was built in at a basic level and really easy to use? Cocos2D’s new physics API takes cues from Sprite Kit’s deep and easy integration.
Apportable is now sponsoring the Chipmunk2D developers to integrate physics into Cocos2D. Even better, the Objective-Chipmunk2D, the official Objective-C wrapper for the Chipmunk2D physics library is being open-sourced! Formerly a paid part of the Pro version of Chipmunk2D, it provides a pure, easy to use, Objective-C physics API. You’ll no longer need to write any C or C++ code to work with physics.
Cocos2D will expose a simple to use API for working with physics that is directly integrated into the basic classes like CCNode and CCScene. It will make it very easy to add things like gravity, collisions and joints to your game.
“Simple to use” is a phrase often used to describe something that isn’t very powerful or flexible. Sprite Kit’s physics certainly fits this. If CCPhysics turns out to be too simple to do what you need, you can always dig deeper and use the full power of the Objective-Chipmnk2D library and still write Objective-C physics code! Everything is open-source, and there will be no black boxes to keep you guessing how something works or that prevents you from doing what you need to do. It’s also in the plans that CCPhysics will provide a number of features that are curiously absent from Sprite Kit such as debug rendering, collision types, or a collision detection only mode.
So what’s next? Over the last couple of weeks, a lot of work has been put into implementing some of the features that were planned for Chipmunk 7 such as wildcard collision handlers, automatically creating convex polygons for shapes, automatic mass calculation and more. Work has also already begun on the CCPhysics implementation, and we should have something to demo in a week or two!