where to start for game development? UIKit vs Core Animation vs QuartzCore vs OpenGL vs cocos2D
Asked Answered
R

1

16

If I was interested in getting across game development on the iPhone/iPAD any suggestions on which technology(s) to start looking into? In fact just a simple bullet on each of these technologies that highlight how it fits into typical game development would be great, as the reason for this question was me not understanding how these fit together. So in this case it's where do these roughly fit in here:

  • UIKit
  • Core Animation
  • QuartzCore
  • OpenGL
  • cocos2D

I was getting the impression that cocos2D would be the way to go, and it seems to be a simpler wrapper for OpenGL? Not sure where that leaves UIKit vs Core Animation vs QuartzCore then?

Roma answered 21/11, 2011 at 20:38 Comment(0)
B
39

Ok well I will try to make a rather lengthy answer short: it depends.

Now for a few longer thoughts and explanations - this is long. If you won't read it to the end, make sure you read the last few sentences.

First I need to clarify that the "technologies" or API's you have listed are mostly concerned solely with graphics (except UIKit which also handles input) and that is ok as long as you understand that the graphics is only a part (and as of my experience I might add "minor") of a whole game.

Besides the graphics, there will be quite a bit more to handle when doing a real game. In order not to get a away from the question too much let me just throw in a few buzzwords: game logic, AI, resource management, physics, interaction, networking (possibly), sound, etc. My recommendation is to get a good book on the topic and dive in [1,2].

Now that I skimmed that, back to your question:

Basically, OpenGL and QuarzCore are the core technologies to "get something drawn on the screen". All other technologies are built on top of that. So in theory, if you want to go that way, you can implement everything related to graphics output with OpenGL or QuarzCore alone (whereas you will have to account for the fact that QuarzCore is 2D drawing only, whereas OpenGL supports 3D also and 2D is really just a special case of 3D). I actually believe that Quarz is also built on top of OpenGL, but I'm unsure about that.

UIKit is built on top of those and using it does basically two things: a) avoid re-inventing the wheel and b) make creation of user interfaces easier, faster and more robust. Of course you could draw every button itself by specifying the coordinates of a quad and sending that to OpenGL for processing. Then you would have to check every user input if it hits your button and call an associated handler. However, just creating an UIButton instance (maybe even in IB) and specifying an on-click handler does remove quite a lot of work.

Bottom line: UIKit is perfectly suited for creating user interfaces. Plus it can be used together with OpenGL and QuarzCore. I use it for the user interface on iOS even in games.

Regarding Cocos2D: This one is a "game engine" built on top of OpenGL. As such it includes quite a lot of the stuff you would have to handle yourself when rolling your own OpenGL-based engine, i.e. scene management, sprites, texturing, meshes, resources etc. I believe it also has connections to physics and collision detection libraries. In order to understand what happens there, however, requires to learn how computer graphics and games work[1,2,3].

Bottom line: you would use Cocos2D for your (2D) game graphics and UIKit to do the user interface.

CoreAnimation then is for animating CoreGraphics stuff. It provides an easy interface, e.g. for smoothly sliding or rotating stuff around, encapsulating all the required calculations (interpolations, redrawing etc). Will not work with OpenGL - but I think Cocos2D will also have a wrapper for that.

Bottom line: Use for fancy user interface animations.

Having said all that and just merely skimming the top I didn't want to frighten you in the first place.

For your special game (and every game is special) you might well get away with just UIKit and CoreAnimiation for the graphics and it might well make a blockbuster game. They allow a lot of drawing to take place with an easy to use interface plus they don't require too deep background knowledge and are sufficiently performant for small projects.

If you have a great game idea, use the simplest possible graphics solution that will satisfy you and your players and realize it. Once you got it going, you can still improve it if necessary.

[1]http://www.mcshaffry.com/GameCode/

[2]http://www.gameenginebook.com/

[3]http://www.opengl.org/documentation/red_book/

Betel answered 21/11, 2011 at 21:22 Comment(5)
excellent - thanks for the overview - I'll check out the references. by the way, any reason why one wouldn't go for cocos2d over Core Animation? i.e. do you know if cocos2d can do what Core Animation can do plus more?Roma
I'm not really into Cocos2D but I think it can do what CA can do and more, but in terms of OpenGL rather than Quarz. So UIKit and Quarz animations will go with CA, everything else with Cocos - but as I said, I am not sure what they provide (but usually any decent game engine has quite a good math library to back it up).Betel
And yeah well what comes to mind is that the difference is that Cocos2D is a (i read fully fledged but I cannot confirm) "game engine" and CA is just a simple way to add animations to UI elements - so that's certainly a difference.Betel
You said that 2D is a special case of 3D when working with OpenGL. So in case we want to manipulate a per pixel level an image (ex. a background), what do you think it's better to use, OpenGL or QuartzCore?Sphagnum
Again the answer depends (on your experience, on what you already have, on what you know better, etc. ...). QuarzCore might be easier to start with when you start from scratch. Don't know if you can do everything with it that you could do using OpenGL. And well yes, in OpenGL 2D is a scene where all z-coordinates have the same fixed value (usually, but not necessarily 0).Betel

© 2022 - 2024 — McMap. All rights reserved.