views:

1486

answers:

7

On an iPhone:

If I am writing a game that has multiple levels, with multiple animations (image sequences), jpg and png (transparent), some full screen and some not, some looped and some played once only. What is the best way of doing it? Each level might have up to 10MB of images. Add on to this music, and video (cut scenes). All 2D graphics, no 3D models.

Is OpenGL required? Or can this be achieved with Quartz or Core Animation?

+3  A: 

Most likely OpenGl.

A: 

I would suggest using Quartz. OpenGL ES is really best for 3d stuff. However both work fairly well, so if you already know OpenGL ES, it's fine to use that.

Zifre
Unfortuntely we don't have OpenGL ES experience :(
Ben X Tan
+5  A: 

I do similar using UIViews and a bit of Core Graphics (Quartz 2D) and it works fine. I've found the custom drawing in Core Graphics pushes it a bit further, tho - UIViews work best when given images rather than having to draw themselves. Also watch out for lots of transparencies. You'll probably find that large or long (many frame) animations will be the killer, though. There are some techniques for minimising the impact of the animations which involves allowing it to purge images from memory if not being immediately displayed (I forget the setting). This may result in your animations not being as smooth as you they would otherwise be (not sure if Open GL ES would help here, though).

You should probably prototype using UIViews, and decide then if it's worth doing the extra work for OpenGL ES. Also, if you're not already familiar with OpenGL/ Open GL ES it's a steep learning curve.

Phil Nash
I looked at Core Graphics and OpenGL and it looked like Core Graphics had the steeper learning curve to me.
Nosredna
I can't speak for your experience, Nosredna, but for me CG makes easy things fairly easy and harder things possible - as any good API should. With OpenGL/ES you have to read quite a lot just to get to grips with the core concepts before you can start doing anything
Phil Nash
I can see that. I did a 2D sprite game and used the texture2D wrapper, so I had stuff moving the first day I tried. But there is a lot to learn to do more.
Nosredna
@Phil Nash: OpenGL ES is very easy.
José Joel.
@José, my point is that you have to learn a lot before you can start with it. I'm sure once you are over that hump it is relatively easy (but as yet I've only tried some noddy examples).
Phil Nash
+4  A: 

I've used both Quartz and OpenGL to do graphics on the iPhone, and while OpenGL has a much higher learning curve, it gives much better performance than Quartz. Let's say you have a scene that involves drawing 6 large, semi-transparent images on top of each other. Quartz will do it, but you'll probably get 15fps at best. OpenGL takes advantage of the iPhone's PowerVR chip and the drawing is hardware accelerated - so you can load those images into OpenGL textures and render at 25-30fps no problem.

I would agree with Phil though - try doing it using Quartz and see if it meets your needs. OpenGL is extremely powerful but it's API lacks some of the convenience features of Quartz (such as saving/restoring graphics state).

One another note entirely, you might want to take a look at Unity's iPhone development tools (http://unity3d.com/#iphone). They leverage OpenGL but provide you with an IDE to create your game. It abstracts away all of the graphics-level code, so you can focus on the high-level gameplay. My brother uses it to write iPhone games, and it's extremely cool.

Ben Gotow
Thanks for the info Ben. If I could pick 2 responses as answers, I'd pick yours as well.Unity looks great...unfortunately also expensive :(
Ben X Tan
+3  A: 

I recommend having a look at Cocos2D iPhone.

cocos2d for iPhone is a framework for building 2D games, demos, and other graphical/interactive applications. It is based on the cocos2d design: it uses the same API, but instead of using python it uses objective-c.

epatel
Cheers. That was one of our possible options.
Ben X Tan
+2  A: 

One advantage of using OpenGL ES would be that the investment of time for learning the technology could be applied to other platforms/contexts and your game is potentially more port-friendly. These may not be important to you.

jmtd
A: 

You should consider using a lot of less resources in your game, Apple recommends not to use more than 10 mb in texture for openGL apps.

Try texture atlas, reuse graphics, tile based graphics...but avoid to use to much graphic assets.

José Joel.