You are previewing iOS Game Development Cookbook.
O'Reilly logo
iOS Game Development Cookbook

Book Description

Want to build games with iOS technologies? This cookbook provides detailed recipes for a wide range of common iOS game-development issues, ranging from 2D and 3D math to Game Center integration, and OpenGL to performance. If you’re familiar with iOS and Objective-C, this is the problem-solving guide you want.

Table of Contents

  1. Preface
    1. Audience
    2. Organization of This Book
    3. Additional Resources
    4. Conventions Used in This Book
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgement
  2. 1. Laying Out a Game
    1. Laying Out Your Engine
    2. Creating an Inheritance-Based Game Layout
    3. Creating a Component-Based Game Layout
    4. Calculating Delta Times
    5. Detecting When the User Enters and Exits Your Game
    6. Updating Based on a Timer
    7. Updating Based on When the Screen Updates
    8. Pausing a Game
    9. Calculating Time Elapsed Since the Game Start
    10. Working with Blocks
    11. Writing a Method That Calls a Block
    12. Working with Operation Queues
    13. Performing a Task in the Future
    14. Storing Blocks in Objects
    15. Using a Timer
    16. Making Operations Depend on Each Other
    17. Filtering an Array with Blocks
    18. Loading New Assets During Gameplay
    19. Adding Unit Tests to Your Game
    20. 2D Grids
  3. 2. Views and Menus
    1. Working with Storyboards
    2. Creating View Controllers
    3. Using Segues to Move Between Screens
    4. Using Constraints to Lay Out Views
    5. Adding Images to Your Project
    6. Slicing Images for Use in Buttons
    7. Using UI Dynamics to Make Animated Views
    8. Moving an Image with Core Animation
    9. Rotating an Image
    10. Animating a Popping Effect on a View
    11. Theming UI Elements with UIAppearance
    12. Rotating a UIView in 3D
    13. Overlaying Menus on Top of Game Content
    14. Designing Effective Game Menus
  4. 3. Input
    1. Detecting When a View Is Touched
    2. Responding to Tap Gestures
    3. Dragging an Image Around the Screen
    4. Detecting Rotation Gestures
    5. Detecting Pinching Gestures
    6. Creating Custom Gestures
    7. Receiving Touches in Custom Areas of a View
    8. Detecting Shakes
    9. Detecting Device Tilt
    10. Getting the Compass Heading
    11. Accessing the User’s Location
    12. Calculating the User’s Speed
    13. Pinpointing the User’s Proximity to Landmarks
    14. Receiving Notifications When the User Changes Location
    15. Looking Up GPS Coordinates for a Street Address
    16. Looking Up Street Addresses from the User’s Location
    17. Using the Device as a Steering Wheel
    18. Detecting Magnets
    19. Utilizing Inputs to Improve Game Design
  5. 4. Sound
    1. Playing Sound with AVAudioPlayer
    2. Recording Sound with AVAudioRecorder
    3. Working with Multiple Audio Players
    4. Cross-Fading Between Tracks
    5. Synthesizing Speech
    6. Getting Information About What the iPod Is Playing
    7. Detecting When the Currently Playing Track Changes
    8. Controlling iPod Playback
    9. Allowing the User to Select Music
    10. Cooperating with Other Applications’ Audio
    11. Determining How to Best Use Sound in Your Game Design
  6. 5. Data Storage
    1. Saving the State of Your Game
    2. Storing High Scores Locally
    3. Using iCloud to Save Games
    4. Using the iCloud Key/Value Store
    5. Loading Structured Information
    6. Deciding When to Use Files or a Database
    7. Using SQLite for Storage
    8. Managing a Collection of Assets
    9. Storing Information in NSUserDefaults
    10. Implementing the Best Data Storage Strategy
    11. In-Game Currency
  7. 6. 2D Graphics and Sprite Kit
    1. Getting Familiar with 2D Math
    2. Creating a Sprite Kit View
    3. Creating a Scene
    4. Adding a Sprite
    5. Adding a Text Sprite
    6. Determining Available Fonts
    7. Including Custom Fonts
    8. Transitioning Between Scenes
    9. Moving Sprites and Labels Around
    10. Adding a Texture Sprite
    11. Creating Texture Atlases
    12. Using Shape Nodes
    13. Using Blending Modes
    14. Using Image Effects to Change the Way that Sprites Are Drawn
    15. Using Bézier Paths
    16. Creating Smoke, Fire, and Other Particle Effects
    17. Shaking the Screen
    18. Animating a Sprite
    19. Parallax Scrolling
    20. Creating Images Using Perlin Noise
  8. 7. Physics
    1. Reviewing Physics Terms and Definitions
    2. Adding Physics to Sprites
    3. Creating Static and Dynamic Objects
    4. Defining Collider Shapes
    5. Setting Velocities
    6. Working with Mass, Size, and Density
    7. Creating Walls in Your Scene
    8. Controlling Gravity
    9. Keeping Objects from Falling Over
    10. Controlling Time in Your Physics Simulation
    11. Detecting Collisions
    12. Finding Objects
    13. Working with Joints
    14. Working with Forces
    15. Adding Thrusters to Objects
    16. Creating Explosions
    17. Using Device Orientation to Control Gravity
    18. Dragging Objects Around
    19. Creating a Car
  9. 8. 3D Graphics
    1. Working with 3D Math
    2. Creating a GLKit Context
    3. Drawing a Square Using OpenGL
    4. Loading a Texture
    5. Drawing a Cube
    6. Rotating a Cube
    7. Moving the Camera in 3D Space
  10. 9. Intermediate 3D Graphics
    1. Loading a Mesh
    2. Parenting Objects
    3. Animating a Mesh
    4. Batching Draw Calls
    5. Creating a Movable Camera Object
  11. 10. Advanced 3D Graphics
    1. Understanding Shaders
    2. Working with Materials
    3. Texturing with Shaders
    4. Lighting a Scene
    5. Using Normal Mapping
    6. Making Objects Transparent
    7. Adding Specular Highlights
    8. Adding Toon Shading
  12. 11. Artificial Intelligence and Behavior
    1. Making an Object Move Toward a Position
    2. Making Things Follow a Path
    3. Making an Object Intercept a Moving Target
    4. Making an Object Flee When It’s in Trouble
    5. Making an Object Decide on a Target
    6. Making an Object Steer Toward a Point
    7. Making an Object Know Where to Take Cover
    8. Calculating a Path for an Object to Take
    9. Finding the Next Best Move for a Puzzle Game
    10. Determining if an Object Can See Another Object
    11. Using AI to Enhance Your Game Design
  13. 12. Networking and Social Media
    1. Using Game Center
    2. Getting Information About the Logged-in Player
    3. Getting Information About Other Players
    4. Making Leaderboards and Challenges with Game Center
    5. Finding People to Play with Using Game Center
    6. Using Bluetooth to Detect Nearby Game Players with the Multipeer Connectivity Framework
    7. Making Real-Time Gameplay Work with Game Kit and the Multipeer Connectivity Framework
    8. Creating, Destroying, and Synchronizing Objects on the Network
    9. Interpolating Object State
    10. Handling When a Player Disconnects and Rejoins
    11. Making Turn-Based Gameplay Work with GameKit
    12. Sharing Text and Images to Social Media Sites
    13. Implementing iOS Networking Effectively
    14. Implementing Social Networks Effectively
  14. 13. Game Controllers and External Screens
    1. Detecting Controllers
    2. Getting Input from a Game Controller
    3. Showing Content via AirPlay
    4. Using External Screens
    5. Designing Effective Graphics for Different Screens
    6. Dragging and Dropping
  15. 14. Performance and Debugging
    1. Improving Your Frame Rate
    2. Making Levels Load Quickly
    3. Dealing with Low-Memory Issues
    4. Tracking Down a Crash
    5. Working with Compressed Textures
    6. Working with Watchpoints
    7. Logging Effectively
    8. Creating Breakpoints That Use Speech
  16. Index
  17. Colophon
  18. Copyright