| Title Page | 375 |
|---|
| 1 | 375 |
|---|
| Copyright Page | 375 |
|---|
| 2 | 375 |
|---|
| Contents at a Glance | 4 |
|---|
| Table of Contents | 4 |
|---|
| 5 | 4 |
|---|
| About the Authors | 13 |
|---|
| About the Technical Reviewer | 13 |
|---|
| 15 | 13 |
|---|
| Acknowledgments | 16 |
|---|
| Introduction | 17 |
|---|
| Chapter 1 A Revolutionary Gaming Platform: Games for Everyone, Anytime, Anywhere | 17 |
|---|
| 18 | 17 |
|---|
| The Ever-Present iPhone | 18 |
| Mass Appeal There s a Gamer Born Every Minute | 19 |
| User Interfaces Death of the D-Pad | 21 |
| Connectivity Plays Well with Others | 22 |
| User Data This Time It s Personal | 23 |
| Device Performance A Multimedia Powerhouse | 25 |
| Dev Kit? You re Holding It! | 26 |
| Innovation Good Things Come from Small Developers | 26 |
| 27 | 26 |
|---|
| Summary | 28 |
| Chapter 2 Developing iPhone Games: Peeking Inside the iPhone Toolbox | 28 |
|---|
| 29 | 28 |
|---|
| Development Tools and Environment | 29 |
| UIKit | 30 |
| Quartz 2D and Core Animation | 31 |
| OpenGL ES | 32 |
| Audio APIs | 33 |
| Networking | 34 |
| Summary | 35 |
| Chapter 3 Moving Images on a Small Screen UIKit Controls | 35 |
|---|
| 36 | 35 |
|---|
| A Quick Introduction to Cocoa Touch | 36 |
| The Objective-C Language | 37 |
| A Brief Objective-C Example | 37 |
| Using an Objective-C Class | 41 |
| Memory Management in Objective-C | 43 |
| Cocoa Touch and the UIKit Framework | 44 |
| Introducing UIView | 45 |
| The Frame Property | 45 |
| The Background Color and Alpha Properties | 47 |
| The Center Property | 47 |
| Building a Simple Game | 48 |
| Creating an Xcode Project | 48 |
| Creating the IVBricker User Interface | 50 |
| Examining the Main Window File | 50 |
| Examining the View Controller File | 52 |
| Setting View Properties | 52 |
| Adding Components to the View | 53 |
| Adding Code to the View Controller | 55 |
| Connecting a Property with a Component | 56 |
| Snazzy Graphics Make the Grade | 57 |
| Adding the Image | 57 |
| The Illusion of Motion | 59 |
| Rocking and Grooving with User Input | 61 |
| Handling Accelerometer Input | 63 |
| Handling Touchscreen Input | 64 |
| When Objects Collide | 65 |
| Failure Conditions | 66 |
| Winning Conditions | 72 |
| Loading and Displaying Images Programmatically | 72 |
| Creating the Grid of Bricks | 74 |
| Detecting image View Collisions | 76 |
| Changing the Timer to CADisplayLink | 79 |
| The End? | 81 |
| Application Delegate Events | 82 |
| Application Termination | 82 |
| Application Interruptions | 83 |
| Low Memory Warnings | 83 |
| Saving and Loading Game State | 84 |
| Managing Memory with a Custom Image Loader | 86 |
| Animating Images | 87 |
| Using the UIImageView Animation Properties | 87 |
| Using NSTimer for Animation | 89 |
| Using CADisplayLink for Animation | 90 |
| Summary | 93 |
| Chapter 4 She Shoots, She Hits, She Scores! | 93 |
|---|
| 94 | 93 |
|---|
| Quartz 2D Game Overview | 94 |
| Every Artist Needs a Canvas | 96 |
| Your First Graphic with Quartz 2D | 104 |
| Saving and Restoring the Context | 105 |
| Adding Color | 107 |
| Sprites | 108 |
| Creating the Sprite Class | 108 |
| Using the Sprite Class | 114 |
| Which Way Is Up? | 117 |
| Changing to Landscape Orientation | 117 |
| Centering the Origin | 119 |
| Vector Art | 120 |
| Creating the VectorSprite Class | 121 |
| Using the VectorSprite Class | 124 |
| Flipbook Animations | 127 |
| Creating the AtlasSprite Class | 128 |
| Modifying the Sprite Class | 133 |
| Using the AtlasSprite Class | 134 |
| Heads-Up Displays | 138 |
| Creating the TextSprite Class | 138 |
| Using the TextSprite Class | 144 |
| Asteroids Game Architecture | 145 |
| The Asteroids Game Loop | 145 |
| The Asteroids Model | 146 |
| The Asteroids View | 148 |
| The Asteroids Game Controller | 149 |
| Conclusion | 151 |
| Chapter 5 Flipping Out and Sweeping Away with Core Animation | 151 |
|---|
| 152 | 151 |
|---|