Our feature this week is from Alejandro Reyero, one of our Dad developers based in Spain. Alejandro runs a company called Todo Jeugos, and writes about how he started to develop mobile apps on Apple’s iOS. He shares his experience about using Cocos2D, a game engine for apps on the iPhone, iPad, or iPod touch. If there are other developers reading this who have experience with Cocos2D, we invite you to leave a comment to build out the conversation with your own opinions.
What would the iPhone-indie-game-developers’ world be without Cocos2D?
I am the owner of TodoJuegos.com, a prominent gaming news website based in Spain. As a game critic for more than 13 years, I always wanted to make my own games.
I decided to make an app using my experience and resources in the gaming world, which is how “Achievements & Trophies” was born (an app to connect to PlayStation Network and Xbox Live to see your games, friends and achievements). I launched it initially on Android because of my experience in Java and the development tools were free. I planned a port to iOS hoping to find a nice development environment and a rich ecosystem. The ecosystem is great, but what a letdown using XCode and Objective-C. After years of Eclipse and Visual Studio, developing in XCode was like going back to vi (ok, I know that’s an exaggeration, but you get the point). And don’t make me start with Objective-C (no garbage collector for iOS, really?). I made a partial port of the app while learning about provisioning, interface builder, and Memory Leak Finder tools, reminding me of Purify on a Solaris.
During a conversation with my close colleague about mobile phones and tablets, we thought about making a game for our children. Apple’s iOS was not an option for me at the beginning. Making a game was hard enough, and my experience with Java and Android was much more substantial. Then I started to look for Android 2D frameworks, and found almost nothing free, full-featured, and with a great community. Making a 2D engine from scratch, even with a very limited set of features, was ambitious. I tried some samples for Cocos2D (Ray Wenderlich – his tutorials are a heaven-sent) and was amazed. The engine is easy to learn, the API made a lot of sense, and the community and samples are GREAT. I was able to make a prototype of the puzzle and match games in just one week, with a very little experience in Objective-C.
The more I explored Cocos2D, the more impressed I became. Do you want to access the photo library? No problem, here is your example. But, accessing the photo Library on an iPad doesn’t work! No problem, use a UIPopoverController to display your UIImagePickerController like this. Every problem that I faced was already resolved by someone in StackOverflow or in Cocos2D forums, what else could I ask for?
In the development of my children’s game, Sage Kids, I only faced two issues of minor annoyance: iPad support and API version upgrades.
Cocos 2D has a great support for Retina Display. From version 0.99.5, you make high resolution assets and Cocos2D uses them depending on the device, with the coordinate system automatically translated for you. Everything that you move, or position, on a Retina Display is translated with zero effort in non-retina devices. In my source code there is not a single line of code that refers to Retina Display, other than the one to enable its support.
iPad support is more troublesome. I understand that the aspect ratio is different from the iPhone, and that an automated system that works 100% is not possible. But at least have something that uses Retina assets and adjusts to the iPad screen for apps that don’t need pixel perfect translations. Having your code full of “if iPad do this if not do that” is ugly and the maintenance is a nightmare.
The API version upgrades is not 100% hassle-free either. The documentation of changes between versions is not as complete as should be, and the process of migration is basically “remove old API directory. Add new one. Compile. Pray.” Backwards compatibility is not assured (not that I have a problem with that, but the amount of source code of Sage Kids is not as big as other projects out there) – so keep that in mind.
I have a problem nowadays: I don’t know how to “live” without Cocos2D. I want to migrate Sage Kids to Android and Windows Phone 7, but I don’t know where to start. There is a project to migrate Cocos2D to Android, but right now it’s not really usable.
Develop my own little Engine? Yeah, right, I’d rather make another game with Cocos2D for iPhone in less than half the time it would take me to have a version of Sage Kids in Android.
So there you have it: Being an indie developer is easy with these tools and frameworks, but once you try it, it’s tough to live without it.