You are previewing iPhone® Game Development.
O'Reilly logo
iPhone® Game Development

Book Description

New Apple Developer Series!

A technical and business guide to creating and selling iPhone games

If you've always wanted to develop a cool iPhone game application and sell it for big bucks, this book is for you. iPhone Game Development covers all technical and commercial bases, from how to sign up for the Apple Development Program, master the development tools in the iPhone SDK, publish your game to the App Store, and convince people to buy it.

You'll find full coverage of Cocoa Touch and other great features of the iPhone SDK, plus pages of real-world examples with step-by-step explanations. The book also includes loads of royalty-free code you can use for commercial development.

  • Apple's iPhone is not only a mobile phone, it's also a game platform rivaling big names like Nintendo and Sony; anyone can sign up for the Apple Developer Program and publish their works to the App Store

  • This hip book written by two successful gamers with over a decade of game development experience will teach you both the technical and business aspects of developing and publishing a game to the App Store, plus how to convince end-users to buy it

  • Includes examples with step-by-step explanations of actual games and apps currently on the App Store

  • A Companion Web site provides royalty-free code from the samples in the book, which you can use to jumpstart your own game development

Save weeks of development time with the expert guidance you'll find in iPhone Game Development!

Table of Contents

  1. Copyright
  2. About the Authors
  3. Credits
  4. Acknowledgments
  5. Introduction
    1. How This Book Is Organized
      1. Part I: Beginning iPhone Programming
      2. Part II: Creating Simple iPhone Applications
      3. Part III: Shall We Play a Game?
      4. Part IV: Advanced Technical and Business Programming Concepts
      5. Part V: Appendixes
    2. Icons Used in This Book
  6. I. Beginning iPhone Programming
  7. 1. Getting Started
    1. 1.1. Appreciating the History of Mobile Devices
    2. 1.2. Introducing the iPhone SDK
    3. 1.3. Introducing the iPhone Developer Program
      1. 1.3.1. The cost of getting started
      2. 1.3.2. Signing up to be an iPhone Developer
    4. 1.4. Un-Boxing Your iPhone Developer Tools
      1. 1.4.1. iPhone Dev Center
      2. 1.4.2. iPhone Developer Program Portal
      3. 1.4.3. iTunes Connect
      4. 1.4.4. iPhone Developer Support Center
    5. 1.5. Testing Applications on Your Device
      1. 1.5.1. Generate and install a Development Certificate
        1. 1.5.1.1. Using the iTunes Developer Program Portal to generate your Development Certificate
        2. 1.5.1.2. Exporting your private key
      2. 1.5.2. Register iPhone and iPod touch Device IDs
      3. 1.5.3. Create an App ID to identify your application
      4. 1.5.4. Generate and install a Development Provisioning Profile
      5. 1.5.5. Configure the Code Signing Identity of your application
      6. 1.5.6. Build and test your application on your development device
    6. 1.6. Summary
  8. 2. Creating Your First App: Hello World
    1. 2.1. Setting Up Your Environment
    2. 2.2. Getting the iPhone SDK
      1. 2.2.1. Registering for the tools
      2. 2.2.2. Downloading the tools
      3. 2.2.3. Installing the iPhone SDK
        1. 2.2.3.1. Uninstalling previous versions of the iPhone SDK
    3. 2.3. Test-Driving the SDK
      1. 2.3.1. Getting a sample app to try out
      2. 2.3.2. Running the sample in the iPhone Simulator
      3. 2.3.3. Running the sample on your iPhone or iPod touch
    4. 2.4. Programming: Hello World
      1. 2.4.1. Defining your goals
      2. 2.4.2. Examining your options
        1. 2.4.2.1. Xcode
        2. 2.4.2.2. Interface Builder
        3. 2.4.2.3. Generating code
      3. 2.4.3. Coding the application
        1. 2.4.3.1. About Us screen
        2. 2.4.3.2. Application icon
    5. 2.5. Summary
  9. II. Creating Simple iPhone Applications
  10. 3. Constructing Puzzle Apps
    1. 3.1. Reviewing Famous Examples
    2. 3.2. Understanding Game Design: Presenting Challenges
      1. 3.2.1. Create time pressure
      2. 3.2.2. Limit number of turns
      3. 3.2.3. Limit space
    3. 3.3. Embracing Multi-Touch
      1. 3.3.1. Leveraging a new style of input
      2. 3.3.2. Learning the technology
        1. 3.3.2.1. Responding to touchesBegan
        2. 3.3.2.2. Responding to touchesMoved
        3. 3.3.2.3. Responding to touchesEnded
        4. 3.3.2.4. Responding to touchesCancelled
    4. 3.4. Envisioning Animations
    5. 3.5. Programming: AmuckSlider
      1. 3.5.1. Defining your goals
      2. 3.5.2. Examining your options
      3. 3.5.3. Coding the application
        1. 3.5.3.1. Creating the project
        2. 3.5.3.2. Putting info in the Info View
        3. 3.5.3.3. Managing level data
          1. 3.5.3.3.1. Examining the Game class in detail
          2. 3.5.3.3.2. Examining supporting Game classes and more
        4. 3.5.3.4. Building the Menu View
        5. 3.5.3.5. Polishing the Menu View
        6. 3.5.3.6. Programming the Game View
          1. 3.5.3.6.1. Reviewing the TileView class
          2. 3.5.3.6.2. Understanding the magic behind the MainViewController
          3. 3.5.3.6.3. Initializing the display
          4. 3.5.3.6.4. Responding to touches
          5. 3.5.3.6.5. Reviewing the utility methods
          6. 3.5.3.6.6. Polishing the Game View
    6. 3.6. Analyzing Business Aspects
    7. 3.7. Summary
  11. 4. Building Novelty Apps
    1. 4.1. Programming: iFlame
    2. 4.2. Programming: iDrum
    3. 4.3. Programming: Bonfire
    4. 4.4. Analyzing Business Aspects
    5. 4.5. Summary
  12. III. Shall We Play a Game?
  13. 5. Producing Action Games
    1. 5.1. Reviewing Famous Examples
    2. 5.2. Understanding Game Design: Excitement and Achievement
      1. 5.2.1. Enjoying the benefits of competition
      2. 5.2.2. Creating sprites
      3. 5.2.3. The online marketplace
        1. 5.2.3.1. Open Clip Art Library
          1. 5.2.3.1.1. Puzzle game
          2. 5.2.3.1.2. Real-time strategy game
          3. 5.2.3.1.3. The Lost Garden
          4. 5.2.3.1.4. 99 Designs
      4. 5.2.4. Creating sounds
    3. 5.3. Programming: AmuckRacer
      1. 5.3.1. Defining your goals
      2. 5.3.2. Examining your options
      3. 5.3.3. Coding the application
        1. 5.3.3.1. Creating the project
        2. 5.3.3.2. Wiring up the user interface
        3. 5.3.3.3. Removing the Status Bar
        4. 5.3.3.4. The basics of collision detection
    4. 5.4. The Road Ahead
      1. 5.4.1. Full-screen animation
        1. 5.4.1.1. The game loop
          1. 5.4.1.1.1. Random numbers
          2. 5.4.1.1.2. Animating the road
          3. 5.4.1.1.3. Tiling an image
      2. 5.4.2. Putting the player in charge
        1. 5.4.2.1. Updating the player's score
          1. 5.4.2.1.1. Staying alive
    5. 5.5. What's Next?
    6. 5.6. Analyzing Business Aspects
    7. 5.7. Summary
  14. 6. Building Community with Facebook
    1. 6.1. Getting to Know Facebook
    2. 6.2. Connecting to Facebook Accounts
      1. 6.2.1. Download the Facebook Connect for iPhone SDK
      2. 6.2.2. The Facebook Connect sample project
      3. 6.2.3. Registering as a Facebook developer
    3. 6.3. Creating a Facebook application
      1. 6.3.1. Setting the Facebook API key and application secret
      2. 6.3.2. Creating a feed template
      3. 6.3.3. Creating a new Facebook Connect application
      4. 6.3.4. Working with sessions
      5. 6.3.5. Learning more about delegates and protocols
      6. 6.3.6. Creating alert views
      7. 6.3.7. Logging in
      8. 6.3.8. Getting extended permissions
      9. 6.3.9. Publishing feed stories
    4. 6.4. Using the Facebook Platform API
    5. 6.5. Analyzing Business Aspects
    6. 6.6. Summary
  15. 7. Connecting Players in Real Time
    1. 7.1. Facing the Challenges of Real-Time Multiplayer Games
      1. 7.1.1. Network latency
      2. 7.1.2. Lost packets
    2. 7.2. Understanding Game Design: Competition
      1. 7.2.1. Practice makes perfect
      2. 7.2.2. Extending the learning curve
    3. 7.3. Choosing Your Connection Options
    4. 7.4. Hooking Up with Your Peers
      1. 7.4.1. Running and reviewing P2P Chat
      2. 7.4.2. Dissecting the code behind P2P Chat
        1. 7.4.2.1. Introducing the GKPeerPickerController
        2. 7.4.2.2. Introducing GKSession
        3. 7.4.2.3. Researching performance
    5. 7.5. Programming: AmuckPuck
      1. 7.5.1. Making a good first impression
      2. 7.5.2. Understanding the data
        1. 7.5.2.1. What is needed to draw the hockey table
        2. 7.5.2.2. What is needed to communicate and control the hockey table
      3. 7.5.3. Focusing on the details
        1. 7.5.3.1. Setting up a hockey table
        2. 7.5.3.2. Using Core Animation
        3. 7.5.3.3. Calculating believable physics
        4. 7.5.3.4. Separating logic for host, client, and head-to-head
        5. 7.5.3.5. Adding a splash of glitz
        6. 7.5.3.6. Reviewing the last pieces
      4. 7.5.4. Connecting to players with peer-to-peer
        1. 7.5.4.1. Sending and receiving messages
        2. 7.5.4.2. Establishing a connection between peers
    6. 7.6. Analyzing Business Aspects
    7. 7.7. Summary
  16. 8. Taking Turns with Other Players
    1. 8.1. Examining Turn-Based Game Play
      1. 8.1.1. Reviewing the game flow
      2. 8.1.2. Understanding the stages
    2. 8.2. Understanding Game Design: Strategy
    3. 8.3. Choosing Your Connection Options
      1. 8.3.1. Head-to-head
        1. 8.3.1.1. Pros
        2. 8.3.1.2. Cons
      2. 8.3.2. Peer-to-peer
        1. 8.3.2.1. Pros
        2. 8.3.2.2. Cons
      3. 8.3.3. Web services
        1. 8.3.3.1. Pros
        2. 8.3.3.2. Cons
      4. 8.3.4. Push notification
        1. 8.3.4.1. Pros
        2. 8.3.4.2. Cons
    4. 8.4. Finding Friends to Compete Against
      1. 8.4.1. Connecting players with Web services
        1. 8.4.1.1. Connecting players with the application installed
        2. 8.4.1.2. Connecting players without the application installed
      2. 8.4.2. Adding push notification to the process
    5. 8.5. Programming: Amuck-Tac-Toe
      1. 8.5.1. Designing the application
      2. 8.5.2. Abstracting for separation and reuse
      3. 8.5.3. Examining the details
        1. 8.5.3.1. Presenting options with a table view
      4. 8.5.4. Making calls to Web services
        1. 8.5.4.1. Accepting messages from Apple Push Notification
    6. 8.6. Analyzing Business Aspects
    7. 8.7. Summary
  17. IV. Advanced Technical and Business Programming Concepts
  18. 9. Grasping Advanced Programming Topics
    1. 9.1. Exploring the Camera
    2. 9.2. Getting Oriented with the Compass
    3. 9.3. Turning Up the Audio
      1. 9.3.1. Playing simple sounds with AudioToolkit
      2. 9.3.2. Making some "real" noise with OpenAL
    4. 9.4. Looking into Video
    5. 9.5. Discovering Geolocation
    6. 9.6. Stepping into the Third Dimension
      1. 9.6.1. Analyzing the OpenGL ES template
      2. 9.6.2. Drawing a cube with volume
    7. 9.7. Summary
  19. 10. Understanding the Business of Software
    1. 10.1. Learning Marketing Strategies
      1. 10.1.1. App Store reports
        1. 10.1.1.1. Financial reports
        2. 10.1.1.2. Sales/trend reports
      2. 10.1.2. App Store statistics
      3. 10.1.3. Application size
      4. 10.1.4. Application price
      5. 10.1.5. Refunds
      6. 10.1.6. Parental controls
        1. 10.1.6.1. App ratings
        2. 10.1.6.2. Restriction settings
      7. 10.1.7. Quality control
    2. 10.2. Making the Best Apps
      1. 10.2.1. Using sound
      2. 10.2.2. OpenGL ES
      3. 10.2.3. Transitions
      4. 10.2.4. Xcode tools
        1. 10.2.4.1. Development Provisioning Assistant
        2. 10.2.4.2. Apple Bug Reporter
      5. 10.2.5. iPhone 3GS features
      6. 10.2.6. iPhone OS 3.0 features
      7. 10.2.7. iPhone SDK 3.0 features
        1. 10.2.7.1. Simulator vs. device
      8. 10.2.8. Worldwide Developers Conference
        1. 10.2.8.1. Apple Developer Connection (ADC) memberships
      9. 10.2.9. Apple Developer Forums
      10. 10.2.10. Apple Push Notification service
      11. 10.2.11. Product icons
      12. 10.2.12. Supporting different iPhone OS versions
    3. 10.3. Exploring App Store Concepts
      1. 10.3.1. Supply and demand
      2. 10.3.2. Promo codes
      3. 10.3.3. Contests
      4. 10.3.4. App Store rejections
      5. 10.3.5. App Store custom backgrounds
      6. 10.3.6. Top free and paid applications
      7. 10.3.7. iTunes Deep Links
      8. 10.3.8. Worldwide distribution
      9. 10.3.9. App Store Logo License Program
      10. 10.3.10. iTunes Affiliates Program
    4. 10.4. Customer Reviews
      1. 10.4.1. Feedback
      2. 10.4.2. Review sites and testimonials
        1. 10.4.2.1. Customer ratings
    5. 10.5. Using App Store Search Secrets
      1. 10.5.1. Keywords
      2. 10.5.2. App Store application description
      3. 10.5.3. On sale
      4. 10.5.4. Videos
      5. 10.5.5. Maximum number of applications
      6. 10.5.6. App Store application categories
      7. 10.5.7. App Store approval wait times
    6. 10.6. Marketing Yourself
      1. 10.6.1. Social networking
      2. 10.6.2. In-app marketing and advertising
      3. 10.6.3. Competition
      4. 10.6.4. Testing
      5. 10.6.5. In App Purchases
      6. 10.6.6. Blogs
      7. 10.6.7. Lite version
      8. 10.6.8. App updates
      9. 10.6.9. Ad Hoc beta testing
      10. 10.6.10. Application names
      11. 10.6.11. Application piracy
      12. 10.6.12. Screen shots
    7. 10.7. Summary
    8. 10.8. Epilogue: Looking Ahead
      1. 10.8.1. Refining your skills
      2. 10.8.2. Answering the question: Is there more?
      3. 10.8.3. Where to learn more
      4. 10.8.4. Preparing for the future
        1. 10.8.4.1. Building apps with change in mind
        2. 10.8.4.2. Predicting the future
  20. V. Appendixes
  21. A. Resources
    1. A.1. Useful Links
      1. A.1.1. 71squared
      2. A.1.2. 148Apps.biz
      3. A.1.3. AppsAmuck
      4. A.1.4. How to make iPhone Apps
      5. A.1.5. iCodeBlog
      6. A.1.6. iDevGames
      7. A.1.7. iLounge
      8. A.1.8. iPhone Dev Center
      9. A.1.9. iPhone Dev SDK
      10. A.1.10. iPhone SDK Articles
      11. A.1.11. Mobile Orchard
      12. A.1.12. The Unofficial Apple Weblog
      13. A.1.13. Wiley's Developer Reference Series
    2. A.2. Books
      1. A.2.1. Cocoa Touch for iPhone OS 3.0
      2. A.2.2. iPhone 3GS Portable Genius
      3. A.2.3. iPhone Fully Loaded
    3. A.3. Certification and Training
      1. A.3.1. Certificate in iPhone and Cocoa Development
      2. A.3.2. Stanford University's iPhone Application Programming Class
      3. A.3.3. WWDC 2009 Session Videos
  22. B. 31 Days of iPhone Apps
    1. B.1. Day 1: Minutes to Midnight
    2. B.2. Day 2: Bonfire
    3. B.3. Day 3: openURL
    4. B.4. Day 4: What Is My IP?
    5. B.5. Day 5: Count Me In
    6. B.6. Day 6: Reaction Time
    7. B.7. Day 7: Speed Dial
    8. B.8. Day 8: Flickr KML
    9. B.9. Day 9: Snow Fall
    10. B.10. Day 10: Where Am I?
    11. B.11. Day 11: Plumb Bob
    12. B.12. Day 12: U Decide
    13. B.13. Day 13: My Google
    14. B.14. Day 14: Sleep Sound
    15. B.15. Day 15: ZipWeather
    16. B.16. Day 16: World Tour
    17. B.17. Day 17: Fireball
    18. B.18. Day 18: Homeland Security
    19. B.19. Day 19: Altimeter
    20. B.20. Day 20: Temperature Converter
    21. B.21. Day 21: iDrum
    22. B.22. Day 22: Pumpkin Face
    23. B.23. Day 23: Hypno
    24. B.24. Day 24: AmuckColors
    25. B.25. Day 25: Sierpinski
    26. B.26. Day 26: LavaFlow
    27. B.27. Day 27: PhotoFrame
    28. B.28. Day 28: DigiClock
    29. B.29. Day 29: Password Generator
    30. B.30. Day 30: DeathCalc
    31. B.31. Day 31: Moolah
  23. Glossary