iPhone Game Development - Chris Craft [139]
While you should always make an effort to include sound in your applications, you should also always include an easy way for your users to disable any audio you have in your app. While audio is a great feature for your applications to have, sometimes users don't want the extra attention it brings, or they may find it distracting. Make sure to always keep your application's user in charge.
You should be very excited to know that developers now have the ability to use music and playlists from the device iPod library in iPhone OS 3.0. This is a huge and largely untapped feature that would be a great advantage for your next game.
OpenGL ES
OpenGL ES (OpenGL for Embedded Systems) is a subset of the OpenGL 3D graphics API. All versions of the iPhone support OpenGL ES, but only the iPhone 3GS supports the latest version, OpenGL ES 2.0. This new version runs two to four times faster than OpenGL ES 1.1 on the previous models of the iPhone.
You can see the sample OpenGL ES application that Apple makes available in Figure 10.5. It may appear to be a simple shape, but many computer-generated images, especially in games, are built up from simple shapes like triangles. Like most things in math, once you master the basics you can do so much more.
Once again you may find yourself facing a dilemma. If you are considering doing any 3-D development for the iPhone using OpenGL ES and you want to support all devices, your application should target OpenGL ES 1.1. If you need the new texture and shading features of OpenGL ES 2.0 or the increased performance it allows, you will have to limit your application to the iPhone 3GS.
Transitions
One simple thing you can do to make all of your applications better is to take advantage of transitions. You'll notice that in almost all of the built-in iPhone applications, any time you go from one screen in an application to another, some sort of transition is fired. Maybe the next screen slides in from the right, or the screen curls up to reveal the screen behind it, as shown in Figure 10.6. But generally there is some eye candy to keep the user's attention and focus. You should want the same for your application's users.
FIGURE 10.5
Apple's OpenGL ES demo application
The UIViewAnimation Transitions that are available in the iPhone SDK include the following:
UIViewAnimationTransitionNoneThis skips showing a transition and immediately shows the next screen instead.
UIViewAnimationTransitionFlipFromLeftThis transition flips the screen from left to right vertically.
UIViewAnimationTransitionFlipFromRightThis transition flips the screen from right to left vertically.
UIViewAnimationTransitionCurlUpThis transition curls the view up from the right.
UIViewAnimationTransitionCurlDownThis transition curls the view down from the top.
FIGURE 10.6
UIViewAnimationTransitionCurlUp being used to curl up view to reveal screen underneath
Xcode tools
Even the best carpenter in the world would have a hard time without the right tools. Make sure to take advantage of all the great tools you have available to you as an iPhone application developer. Here are some of the most important ones:
Xcode. Xcode (Figure 10.7) is the development environment for iPhone applications.
Interface Builder. Interface Builder is a visual design tool you use to create the user interfaces of your iPhone applications.
Dashcode. This allows for the creation of Web pages that are optimized for Safari on the iPhone.
Organizer. You use the Organizer to add Provisioning Profiles to your development device.
Debugger. The Xcode Debugger window offers a traditional but rich GUI debugging experience.
Console. This allows you to interact with the Debugger on the command line.
Research Assistant. The Research Assistant shows the selected symbol's declaration or availability information. You can also find sample code and related documents.
Shark. Shark is