Sunday, October 2, 2011
The transition from AS3 to Cocos2d
It seems that the future of Flash is unclear. The debate around this is very intense but one thing is sure, there is a high level of competition among Flash studios with the consequence that prices are too low to produce original quality games.
With customers demanding cheap games rather than quality games we need to be able to develop our own products and explore alternative income sources.
A couple of months ago we started the development of our first iOS game. Working on this game has been very intense and although it's taking longer than originally expected we've finally found a cool gameplay.
We approached this new project with Cocos2D, which is a very useful framework based on Objective-C. Basically, Cocos2D makes the scene management easier and it wraps up the interaction with OpenGL.
Because AS3 and Objective-C are object oriented languages the transition wasn't as difficult as I expected. It's a matter of time to get used to a new sintax.
The logic behind Cocos2D is very simmilar to AS3. Graphic elements are added as nodes and instead tweens, actions are performed on those nodes to animate them. AS3 uses events for the communication between objects and Objective C uses delegates, which are more efficient and direct. On Objective-C memory management is a task of the programmer. Having a garbage collector is an advantage but the programmer has to be very careful removing all listeners when deleting objects to avoid mermory leaks.
I never liked movieclips. I recognize that they are great from a designer perspective but besides using a lot of computing time they don't integrate well on a pure code project. I don't miss the time line as none of our flash games was based on that.
The amount of available examples and tutorials in Flash is overwhelming. In comparison the lack of examples on Cocos2D is frustrating. However, you can extract a lot of information from the Cocos2D testbed.
But there is a thing on that transition that really made me happy: using a Mac to develop. Thanks Steve!