Core Animation is a topic that I’ve brought up a few times showing some code snippets for simple animation effects, and talking about how it could be used in simple games. Unfortunately the amount of material available covering Core Animation has been somewhat lacking, and nothing especially specifically covering iPhone OS 3. Fortunately Core Animation: Simplified Animation Techniques For Mac And iPhone Development was released in Late 2009 that covers this topic in more depth.
Now as the title suggests this book teaches you the techniques for performing animation using Apple’s Core Animation libraries. If you’d like to know specifically what is in the book you can go here and use the search inside this book link to search the book and read the table of contents. The book teaches you through a series of examples that perform specific tasks. I liked the straightforwardness of the approach, but I would say that this isn’t a book for beginners. At the very least you will want to have a good understanding of Objective-C, and a basic understanding of the patterns used in Cocoa and Cocoa Touch. I liked the layout and organization book which makes it useful as a reference. Something to note is that this book is not specifically an iPhone book, and most of the examples use the Mac and some Mac only topics such as Core Image are covered in the book.
- Well laid out, makes a good reference book
- Covers differences between Mac and iPhone Core Animation
- Examples are very goal oriented which is good if you have a specific task to perform
- Not specifically an iPhone book
- Requires knowledge of Objective-C and Mac or iPhone programming
- Some more comments in the code examples would be nice
Overall, I’d say that this is a good Core Animation reference book, or for teaching yourself the principles of Core Animation. If you’re an absolute beginner you’ll want to make sure you have a thorough understanding of Objective-C and the basics of using Cocoa Touch. The examples are very well thought out, and if you’re looking to do something specific you’ll probably find it in this book along with some sample code. The fact that most of the examples are Mac isn’t really a big deal, in the future the extra pages on topics like Core Image may turn into a positive if those libraries are added to the iPhone OS.
I’ve made quite a few posts about OpenGL ES, and the available game engines on the iPhone, and I’d like to iterate that you do not need to use OpenGL ES or any game engine. Core Animation can be used for iPhone game development, and if you’re used to Objective-C/Cocoa it may be the easiest route.
There are some caveats to using Core Animation, for one, you can get better performance from using raw OpenGL ES, and it can be somewhat tedious to use in instances where you may want to micromanage the animation of a graphical object. Also, while there are 3D transformations available Core Animation is designed for 2D graphics. All this being said, Core Animation is great for games such as card games, and board games. A huge advantage of Core Animation is that you can lay out your components using interface builder which can be a real time saver, as all the graphical components are inherited from UIView.
You wil want to check out the manual on Apple’s official Core Animation Programming Guide here:
Core Animation Programming Guide
While much of that guide is for Mac, you can also check out the Core Animation Cookbook:
Core Animation Cookbook
As far as code samples go the best example I’ve seen is the fantastic Geek Game Board, and an iPhone compatible version with some updates beyond the Mac version available at the Apple site is here:
and for those who have trouble downloading the source can find it here:
Geek Game Board From Bit Bucket
I was able to get this example compiling to iPhone OS 3.0 straight out.
What makes the GeekGameBoard example so good is that it includes board games, and card games (specifically Go, TicTacToe, Hex, and Klondike) that you can use as a framework which includes cards, boards, and pieces that you can use in iPhone game development. This should get you off to a very fast start.
I saw an interesting question being asked by an aspiring iPhone game developer, "Should I use CoreAnimation or OpenGL ES?".
Core Animation is fine for games where performance is not critical, and for new programmers will likely be easy to use, OpenGL is needed for anything else.
Core Animation utilizes OpenGL ES, it is high level, and in my testing works fine in situations where performance is critical.
OpenGL ES is an open standard that is used on a growing number of devices created by a wide variety of companies, and because CoreAnimation is a higher level framework built atop OpenGL ES it cannot provide nearly the same performance.
My opinion is that Core Animation is likely the appropriate choice for games where performance is not critical such as simon says type games, card games, and trivia games. Some might argue that OpenGL ES is easier to use, and it likely is if you’ve studied say.. DirectX.. but Core Animation (and Quartz 2D for that matter) is much easier to do simple effects in, and can be used with existing UIViews.
OpenGL ES is your choice for performance critical games. Which is essentially anything but simple mostly static games like the ones mentioned I above such as first person shooters, flight simulators and the like. You also get the added benefit of potentially being able to port your games to a device other than the iPhone, and there is alot of existing game code in OpenGL that can be converted the other way. That being said for simple, static games for a newcomer to graphics programming my choice would be Core Animation although if you can wrap your head around the tutorials and frameworks on my OpenGL ES resources page OpenGL ES may be for you.
I hope this provides answer for anyone trying to decide whether they should program in OpenGL ES, any opinions from those who have done more with Core Animation than I have would be greatly appreciated.