by Mohammed El-Serougi - Feb 23

Cocos2D is an open-source framework for creating 2D games and interactive applications. I've made mention of it in two other posts, but this one serves an overall review. Written in Objective-C, Cocos2D combines:
- Ease of use
- Speed through the use of OpenGL ES
- Flexibility and simple integrations such as Box2D- and Chipmunk-based physics
- Support from a large, friendly community
The most recent version of the framework at the time of this writing is 0.99, which adds support for Apple iPad alongside iPod touch and iPhone.
An impressive list of games using the framework, some available on the Apple Store already, can be found here.
Before I provide my review, I'll give a rundown of the four components that form the framework's basic architecture:
1. Sprites
Sprites are 2D images which can be moved, rotated, scaled, etc. The parent/child hierarchy exists and follows the rule that if the parent is transformed (for example, by moving it) then the transformation is applied to all children sprites.
2. Layers
Layers are where most of a programmer's time will be spent. A layer is the entire drawable area. It is also capable of drawing itself. One example of layers is a menu. A menu could consist of three layers: the background layer holding an image; the actual menu layer containing the various options (Start, Exit, etc.); and a user interaction layer that handles specific screen touches.
3. Scenes
Scenes can be thought of as "stages" or independent pieces of functionality. A scene consists of several layers, and an application can contain of several scenes. However, only one scene is active at a time. Going back to our example of a menu, the scene is the menu itself.
4. Director
Director takes care of going back and forth between scenes, controlling and initializing the main screen.
Review
I have found Cocos2D's component-based architecture extensible and simple to use. It doesn't sacrifice quality or encourage bad design practices. All elements are layered on top of each other and controlled by their parent(s). Take a look at the following sample game project architecture and notice how the components that make up the Cocos2D framework fit perfectly:
Cocos2D framework
However, one thing I did not like when I started working with Cocos2D was that I had many questions that weren’t answered by the available documentation. I had to search the community forum to get answers. Having to search may not be as bad as it sounds, but I would rather have solid documentation catering to my needs and let the forum be a discussion place for specialized needs. On the bright side however, the forum indeed is comprehensive, and I got my questions answered there with a couple searches. If the valuable parts of the forum would be marked for inclusion in documentation, we'd be on the right track. However, when it comes to open-source, there is always a trade off, and you can’t expect everything to be readily available for you.
If you are looking for a solid framework for your game or interactive project and support from a large community, then Cocos2D will definitely meet your expectations and go beyond. Notice how I did not specify “2D project” or "3D project". That’s because a post on the official Cocos2D Website covers the integration points to have Cocos2D sit atop SIO2. SIO2 is an open-source 3D engine for the iPod touch, iPhone, which has added iPad support as well. Learn Cocos2D and you could be on your way to a 3D game as well. Talk about extensibility!

Comments
Post new comment