views:

59

answers:

2

I am relatively new to doing graphics work on the iPhone and was hoping to get some guidance on which technology I should employ. The issue I am facing is that I need to create an iPhone app that will have a spinning wheel in it, think the Price Is Right wheel.

I am not looking for anyone to provide a detailed solution, that would spoil my fun! I would simply like to know would it be better to use straight Cocoa Animation and draw and move each cell by hand as the wheel spins, or should I attempt to use Core Animation Layers? I have also thought of using OpenGL ES and building a true cylinder in 3D and then rotating that, this seems the most logical to me but again I am new to all of this.

+1  A: 

For situations like this, I usually recommend looking first to Core Animation and only going to OpenGL ES if you can't get the kind of performance you need. Redrawing a wheel frame-by-frame using only Quartz will result in abysmal performance, so that's not really an option here.

Using Core Animation, you can perform complex animations, such as your rotation, without requiring much code. You also can leverage UIViews and other UIKit components to provide touch interaction easily. You don't even necessarily need to step down to using layers, as every UIView is layer-backed and they tend to be pretty lightweight.

OpenGL ES will give you the best possible performance, but I wouldn't think you'd run into a limitation when simply spinning a wheel using Core Animation, even on older devices. OpenGL ES will require a lot more code to achieve the same effect, and will be more difficult to integrate with any touch interaction you may wish to do.

Brad Larson
"OpenGL ES will give you the best possible performance" says who? UIKit uses CoreAnimation, and CoreAnimation is designed to provide decent animation performance even when your main thread is blocked; something OpenGL doesn't do so well unless you go through the trouble of making it threaded yourself.
tc.
@tc - True, the Core Animation server handles placing everything on a background thread, along with managing all the tweening for you, but it does add some overhead. If you handle all of that yourself, and you tune for your particular case, you can get better performance by dropping closer to the metal with OpenGL ES. I've heard from several developers who have had to do this to squeeze out those extra few FPS for intensive applications. However, OpenGL ES should be a last resort for 2-D animations because of all the code that you'll have to write to manage all this.
Brad Larson
A: 

Based on the feedback I have dug deeper into Core Animation and have been able to accomplish what I need using it. Thanks for all the advice.

B. Kohl
In that case you should accept Brad's answer - click the green tick mark by it.
walkytalky