Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Cocos over UI Kit for a 2D iPhone game?

I have been building a game in cocos for a while now I it has just occurred to me that it might just be a whole lot easier to use UIKit.

Could you please help me weight up the pros and cons, and share some experiences you have.

Here is my basic list of advantages for each. I feel I dont know enought about cocos to make a informed decision which is best.

Cocos

  • Game engine comes for free. Pause / resume callbacks every frame
  • Sprite animations
  • Uses open GL (is this true? is this an advantage?)
  • ...Help me think of some more!

UI Kit

  • Far more Help / Documentation / Sample Code
  • Familiar for iPhone programmers
  • Easy to handel touch
  • Easy view animations
  • Easy to customise
  • Faster loading times? (is this true?)

Any feedback would be great!

EDIT: I have just seen a developer video (on an open GL game called Quest) where they used UI Kit for the UI elements, drawn over the top of the GL View. Is this possible / practical with cocos?

like image 894
Robert Avatar asked Dec 10 '22 10:12

Robert


2 Answers

  1. Cocos2d uses OpenGL for drawing its sprites, movements, and particles. Trying to use Quartz/Core Graphics (which is NOT accelerated!) is fundamentally much slower and power hungry.
  2. Cocos2d is a sprite library with a scenegraph first and foremost. You would be duplicating effort to make a scenegraph using UIKit.
  3. There are lots of nice freebies that work within Cocos which you would have to develop from the ground up.

So, in short: It draws way faster than CPU bound drawing calls, it provides 95% of what most sprite based games need without reinventing the same thing over and over, and is free.

like image 70
Yann Ramin Avatar answered Dec 22 '22 23:12

Yann Ramin


Although UIKit is incredibly useful for gaming, Cocos2D offers a variety of easier ways to accomplish many common game-making operations. For instance, it has the ability to create easy scrolling-tile games (very common and very popular) using a simple few lines of code to import a "Tiled" map set. In terms of some of the benefits of UIKit over Cocos2D that you mentioned, they are very easy to accomplish in Cocos2D, as well.

Touch handling: This is as easy as replacing the "touchesBegan" method of UIKit with "ccTouchesBegan" and setting self.isTouchEnabled = YES in the init method.

Animations: This is so much easier in Cocos2d, mainly because frame rate and animation issues are solved. In UIKit, you cannot use CoreAnimation to move an object while still implementing collision detection. You would have to animate the object with an NSTimer. In Cocos2d, you can easily animate objects (called sprites) and still use collision detection and interaction with the object.

More Help/Documentation: Cocos2D offers an incredible amount of documentation and, even more so, examples of code! If you can't find it there, there is a growing number of iPhone game developers who implement Cocos2D in their apps and are willing to help many problems.

If you are planning on developing games for iPhone, and not just general apps for productivity, music, etc., I highly suggest Cocos2D. Remember, you can always still find ways to combine this and UIKit for many operations! Those operations aren't completely lost!

like image 39
Noah Golmant Avatar answered Dec 22 '22 23:12

Noah Golmant