Beginning iOS Game Development
Buy Rights Online Buy Rights

Rights Contact Login For More Details

  • Wiley

More About This Title Beginning iOS Game Development

English

Get in the game and start building games for the iPhone or iPad!

Whether you only have a little experience with iOS programming or even none at all, this accessible guide is ideal for getting started developing games for the iPhone and iPad. Experienced developer and author Patrick Alessi presents the iOS system architecture, gives you the step-by-step of game development, and introduces the languages used to develop games. From the basic building blocks to including drawing, responding to user interaction, animation, and sound, this book provides a one-stop-shop for getting your game up and running.

Explores the tools and methodology used to develop games for the iPhone and iPadRequires no previous experience with building a game for the iOS platformDetails how iOS games require different considerations than other applicationsAddresses working with the Xcode programming environment, how to draw with the Quartz 2D API, ways to handle user input, and techniques for incorporating animation with Core Animation and sound with Core Audio

If you're ready to jump on the gaming app bandwagon, then this book is what you need to get started!

English

Patrick Alessi has built data-centric applications for clients ranging from small business databases to large-scale systems for the United States Air Force. He is the developer of several applications in the iTunes store, and is the author of Professional iPhone and iPad Database Application Programming. He has also developed a variety of real-time systems, graphics intensive desktop applications, and games. Currently, he is focused on developing connected applications and games for mobile devices such as the iPhone and iPad.

English

INTRODUCTION xxi

PART I: THE TOOLS TO GET STARTED

CHAPTER 1: GAMES ON IOS 3

What Makes a Good iOS Game? 4

Device Usage 4

Use Unique Features of iOS 4

Make Your Game Fun 5

Graphics and Design 6

Developing Your Idea 6

Documenting Your Game 6

Prototyping Your Game 7

Preparing to Code 8

Game-Related Frameworks 9

Cocoa 9

Drawing: UIKit and Core Graphics 11

User Interaction: Cocoa Touch 12

Animation: Core Animation 12

Sound: Core Audio 13

Game Kit 14

Summary 14

CHAPTER 2: THE XCODE PROGRAMMING ENVIRONMENT 17

The Coding Environment 18

Creating a Project 19

Navigating Your Project 22

The Navigator Area 22

Navigating by Symbol 23

Searching Your Code 23

Viewing Code Issues 24

Examining Logs 24

Editing Your Code 25

Code Coloring 25

Indentation and Snippets 26

Fix-it 28

Integrated Help 28

Using the Jump Bars 29

The Assistant Editor 30

Xcode Debugging Tools 31

Breaking and Stepping through Your Code 31

Additional Breakpoint Features 35

Building a Simple Interface 36

Summary 42

CHAPTER 3: THE C PROGRAMMING LANGUAGE 45

Introducing C 45

Variables and Expressions 46

Data Types 46

Variables 47

Base Data Types 47

Generating Output and Accepting Input 47

Extending the Data Types 50

Operators 51

Assignment Operators 52

Arithmetic Operators 54

Relational Operators 54

Logical Operators 55

Scope 55

Structures 56

Arrays 61

Loops 64

for Loops 64

while and do…while Loops 67

break and continue 72

Execution Flow and Decisions 73

The if Statement 73

The Conditional Operator 74

Choosing an Option with switch 75

Breaking Up Code with Functions 77

Pointers 82

A Game Example 85

Summary 91

CHAPTER 4: THE OBJECTIVE-C PROGRAMMING LANGUAGE 95

Classes and Objects 96

Instance Variables 97

Methods and Messages 98

Managing Memory 104

Automatic Reference Counting 106

Inheritance 107

Building Subclasses from a Base Class 107

Overriding Base Class Methods 110

Polymorphism 111

Building a Game in Objective-C 114

Exposing Class Data with Properties 115

Declaring a Property 115

Accessing a Property 117

Class Methods 117

Implementing the MindPlayer 119

Building the Game Loop 127

Summary 134

CHAPTER 5: THE COCOA FOUNDATION FRAMEWORK 137

Model-View-Controller Architecture 138

Your First iOS Game 138

Building the UI 140

Outlets and Actions 140

Handling Text with NSString 144

NSString Methods 144

Mutable and Immutable Types 144

String Comparison 145

Collecting Objects with NSArray 146

NSArray Methods 146

Modifying Arrays by Using NSMutableArray 147

Wrapping Numbers with NSNumber 147

Other Collection Classes 148

NSSet 148

NSDictionary 148

Building the Game Model 157

Periodic Events and Timers 162

Summary 169

PART II: GAME BUILDING BLOCKS

CHAPTER 6: DRAWING WITH UIKIT AND CORE GRAPHICS 173

Introducing the Drawing Frameworks 173

UIKit 174

Core Graphics 175

The Drawing Environment 175

The Graphics Context 175

The UIView Coordinate System 176

The drawRect: Method 176

Drawing Shapes with UIBezierPath 177

Specifying Colors with UIColor 178

Advanced Drawing with Core Graphics 186

Shadows 186

Gradients 188

Starting the Blocker Game with the BlockView 192

Working with Images 197

The Image Classes 198

The View Hierarchy 199

Animation and Timing with CADisplayLink 206

Finishing the Blocker Game 215

Summary 217

CHAPTER 7: RESPONDING TO USER INTERACTION 219

Events in iOS 219

The Event Architecture 220

Event Objects 221

Handling Multitouch Events 222

Building a Simple Touch-Based Game: Simon Says 225

Responding to Motion with the Accelerometer 241

Recognizing Gestures 247

Summary 248

CHAPTER 8: ANIMATING YOUR GRAPHICS 251

Animating Images with UIImageView 252

Introducing Core Animation 255

A Brief Introduction to Blocks 255

Animating UIView Properties and Transitions 256

Property Animations 256

Transition Animations 267

Core Animation Basics 276

Layer Layout 277

Animatable Properties 277

Layer Trees 283

Summary 286

CHAPTER 9: MAKING NOISE WITH IOS AUDIO APIS 289

Playing Simple Sounds with the System Sound Services 290

Playing Sounds with the AV Foundation Framework 291

The AVAudioPlayer Class 291

Format and Performance Considerations 292

Confi guring the Audio Session 293

Playing Multiple Sounds Simultaneously 313

Looping Sounds 313

Media Player Framework 322

Summary 330

CHAPTER 10: BUILDING A NETWORKED GAME WITH GAMEKIT 333

Introducing GameKit 333

Starting Out 334

Networking Your Game 351

NSData and NSCoding 352

Converting Classes to Data with Archives 353

Connecting and Sending Data 354

Running the Game 364

Summary 366

APPENDIX: ANSWERS TO EXERCISES 369

INDEX 385

loading