Beginning iPhone Games Development -  Peter Bakhirev,  PJ Cabrera,  Ian Marsh,  Stuart Marsh,  Scott Penberthy,  Ben Smith,  Roderick Smith,  Eric Wing

Beginning iPhone Games Development (eBook)

eBook Download: PDF
2010 | 1st ed.
728 Seiten
Apress (Verlag)
978-1-4302-2600-0 (ISBN)
Systemvoraussetzungen
34,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

iPhone games are hot! Just look at the numbers. Games make up over 25 percent of total apps and over 70 percent of the most popular apps. Surprised? Of course not! Most of us have filled our iPhone or iPod touch with games, and many of us hope to develop the next best-selling, most talked-about game.

You've probably already read and mastered Beginning iPhone 3 Development; Exploring the iPhone SDK, the best-selling second edition of Apress's highly acclaimed introduction to the iPhone and iPod touch by developers Dave Mark and Jeff LaMarche. This book is the game-specific equivalent, providing you with the same easy-to-follow, step-by-step approach, more deep technical insights, and that familiar friendly style.

While games are all about fun, at the same time, they're serious business. With this Beginning iPhone Games Development book, you're going to roll up your sleeves and get your hands dirty with some hardcore coding. While you may have written games before, this book will take you further, immersing you in the following topics:

  • Game graphics and animation with UIKit, Quartz, Core Animation, and OpenGL ES
  • Game audio with OpenAL, MediaPlayer Framework, AV Foundation, and AudioSession
  • Game networking with GameKit, Bonjour, and Internet sharing

For those looking for iPad game development coverage and/or iOS 5 SDK specific game coverage, check out the published Beginning iOS 5 Games Development by Lucas Jordan from Apress.



PJ Cabrera is a software engineer with more than 12 years of experience developing information systems in various industries, programming in C, C++, Java, PHP, Python, and Ruby. But his real passion for many years has been hacking gadgets (i.e., turning a Sega Dreamcast into a NetBSD router, or running Android and Debian GNU/Linux on a Palm TX) and making home-brewed games for consoles such as Dreamcast, PlayStation 2, GameBoy Advance, and PSP. He is very excited that he can finally share his creative side on iPhone and XBox 360 with the general public through the App Store and XNA Community Games.
iPhone games are hot! Just look at the numbers. Games make up over 25 percent of total apps and over 70 percent of the most popular apps. Surprised? Of course not! Most of us have filled our iPhone or iPod touch with games, and many of us hope to develop the next best-selling, most talked-about game.You’ve probably already read and mastered Beginning iPhone 3 Development; Exploring the iPhone SDK, the best-selling second edition of Apress’s highly acclaimed introduction to the iPhone and iPod touch by developers Dave Mark and Jeff LaMarche. This book is the game-specific equivalent, providing you with the same easy-to-follow, step-by-step approach, more deep technical insights, and that familiar friendly style.While games are all about fun, at the same time, they’re serious business. With this Beginning iPhone Games Development book, you’re going to roll up your sleeves and get your hands dirty with some hardcore coding. While you may have written games before, this book will take you further, immersing you in the following topics: Game graphics and animation with UIKit, Quartz, Core Animation, and OpenGL ES Game audio with OpenAL, MediaPlayer Framework, AV Foundation, and AudioSession Game networking with GameKit, Bonjour, and Internet sharing For those looking for iPad game development coverage and/or iOS 5 SDK specific game coverage, check out the published Beginning iOS 5 Games Development by Lucas Jordan from Apress.

PJ Cabrera is a software engineer with more than 12 years of experience developing information systems in various industries, programming in C, C++, Java, PHP, Python, and Ruby. But his real passion for many years has been hacking gadgets (i.e., turning a Sega Dreamcast into a NetBSD router, or running Android and Debian GNU/Linux on a Palm TX) and making home-brewed games for consoles such as Dreamcast, PlayStation 2, GameBoy Advance, and PSP. He is very excited that he can finally share his creative side on iPhone and XBox 360 with the general public through the App Store and XNA Community Games.

Title Page 
1 
Copyright Page 
2 
Contents at a Glance 4
Table of Contents 
5 
About the Authors 13
About the Technical Reviewer 
15 
Acknowledgments 16
Introduction 17
Chapter 1 A Revolutionary Gaming Platform: Games for Everyone, Anytime, Anywhere 
18 
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 
27 
Summary 28
Chapter 2 Developing iPhone Games: Peeking Inside the iPhone Toolbox 
29 
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 
36 
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! 
94 
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 
152 
Core Animation Sample Project Overview 153
Animating UIViews 155
Simple Movement 158
Animation Curves 159
Reverse and Repeat 161
Delay, Ease-In, and Ease-Out 163
UIView Transforms 164
UIView Transitions 166
Animating Core Animation Layers 168
Implicit Animations 169
Timing Functions 169
Layer Animation Transitions 170
Fade 171
Move In, Push, and Reveal 173
Summary 174
Chapter 6 OpenGL Basics: Wrapping Your Head Around the OpenGL API 
175 
What Is OpenGL ES and Why Do I Care? 175
Understanding the 3D World 176
Matrix Basics: Taking the Red Pill 178
Bringing It All Together 181
Matrix Types 181
The Model and the Model Matrix 182
The View Matrix 182
The Projection 182
The Viewport 182
Stateful API 182
Rendering Basics 183
The Basic Game Template 184
Wrapping the CAEAGLLayer in a View: EAGLView 186
First Steps: The Init Method 187
Frame Buffers, Render Buffers, and Depth Buffers 189
Seeing into the OpenGL World 192
Drawing and Rendering 197
How to Draw Stuff with OpenGL 198
The Scene and Mesh Objects 198
Pushing and Popping Matrixes 201
Putting Your Objects in the Scene 201
Moving Objects 201
Scaling Objects 202
Spinning Objects 202
Defining Your Object in 3D Space 204
Vertex and Color Information 204
Understanding Triangles 206
The Game Loop and the Timer 208
The Input Controller 213
The App Delegate 214
Summary 214
Chapter 7 Putting It Together: Making a Game in OpenGL 
216 
Space Rocks! Game Design 216
Getting Started with the Template 218
Rotation Makes the World Go 'Round 219
3D Point Upgrade 222
Adding Buttons 224
Creating a Button Object 225
Working with Vertex Data 226
Storing Buttons 228
Detecting Touches 231
Wiring Up the Buttons 236
Building a Better Spaceship 237
Going Mobile 237
Adding the Spaceship 237
Adding and Removing Scene Objects 240
Falling Off the Edge of the Screen 242
Space Rocks! 243
Adding Missiles 247
Firing Missiles 247
Removing Unwanted Missiles 248
Making Nicer Buttons 249
Collision Detection 251
What Is a Collision? 251
Collision-Detection Techniques 252
Optimized Collision Detection 253
Radius-to-Radius Collision Check 254
Collisions on the Rocks 257
Centroid and Radius 257
Colliders and Collidees 259
Take the Red Pill: The Transform Matrix 259
The Collider Object 261
The Collision Controller Object 263
Back to the Scene Controller 264
Scene Object Updates 265
Collision Checking Redux 268
Summary 271
Chapter 8 The Next Steps: Atlases, Sprites, and Particles—Oh My! 
273 
Textures and Texture Atlases 273
What Is a Texture Anyway, and Why Do I Care? 274
Getting Image Data into OpenGL 275
Binding Textures 279
UV Is Not Bad for Your Skin 280
You Get a Textured Quad! 281
Say Hello to the Texture Atlas 284
Switching the Old and Busted for the New Hotness 288
A Nicer User Interface 288
Colors with Textures 290
Sprite Animation 292
Frame Rate Independence 294
Animations for Everything 298
From 2D to 3D 299
It’s Only One More D—What’s the Big Deal? 300
Where Do 3D Models Come From? 301
From Modeler to Screen 302
What Is Normal? 303
Standardizing on GL_TRIANGLES 303
Textures Plus Models 305
Shadows Define Shape 307
Depth Buffer and Face Culling 310
Collision Detection Tweaks 312
Particle Systems Add Life to Your Game 313
What Is a Particle System? 313
A Lot of Random Numbers 314
The Nitty-Gritty of a Particle System: Particles 315
Particle Emitters and You 316
Tuning Our System 323
Particle Systems for Everything 324
What the Future Holds: Shaders 325
Summary 325
Chapter 9 Introduction to Core Audio 
327 
Audio Services Provided by Core Audio 327
Audio Units 328
Audio File Services 329
Audio File Stream Services 329
Audio Conversion Services 329
Extended Audio File Services 329
Audio Session Services 330
System Sound Services 330
Audio Queue Services 330
AVFoundation 331
OpenAL 331
The Core Audio Frameworks 332
Codecs and File Formats 333
Codecs Supported by Core Audio 334
File Formats Supported by Core Audio 335
Using afconvert to Convert Between Formats 336
Hardware-Accelerated Codecs: Restricted and Unrestricted Codec Groups 
337 
Codec and File Format Suggestions 338
Alerts and Vibration: Introducing System Sound Services 
339 
The Case Against System Sound Services for General Sound Effects 
340 
A System Sound Services Example 341
A Comment on Asynchronous Playback 347
Setting Policies for Your Audio: Introducing Audio Session Services 
348 
Boilerplate Code and Procedures for Using Audio Session Services 
350 
Detecting Hardware and Getting Properties 352
Easy Audio Playback in Objective-C with AVFoundation 
353 
Mission Complete…but Our Princess Is in Another Castle! 
363 
Chapter 10 Making Noise with OpenAL 
365 
OpenAL Overview 366
What OpenAL Supports 366
Some History of OpenAL 366
My Story and Goals for Audio Coverage 370
Roadmap for the Audio Coverage 371
Setting Up Basic Sound in OpenAL 372
Setting Up an Audio Session 373
Opening a Device 374
Advanced OpenAL Tip: Specifying OpenAL Devices 375
Creating a Context 377
Advanced Tip: Using Attribute Lists 377
Activating the Context 378
Generating Sound Sources 379
Generating Data Buffers 380
Loading Sound Data from Files 380
Submitting Sound Data to OpenAL Data Buffers 384
Advanced OpenAL Tip: The alBufferDataStatic Extension 384
Attaching a Data Buffer to a Sound Source 386
Playing Sound 386
Shutting Down and Cleaning Up 387
Cow Launched! 388
Exposing Flaws and the Missing Details 388
Adding More Sounds 390
Problems to Notice 394
OpenAL Error Checking 395
Audio Session Interruptions 396
OpenAL Extensions for iPhone OS 400
Performance Notes 400
OpenAL Source Limits: “It’s a Secret to Everybody” 402
Sound Resource Manager: Fixing the Design 404
Overview of the Resource Manager 405
Initial Cleanup 407
The Sound File Database (Cache System) 412
OpenAL Source Management (Reserving and Recycling) 416
Integration with Space Rocks! 420
SoundDidFinishPlaying Callbacks 424
Final Integration Steps for Space Rocks! 426
Handling When All Available Sources Are Exhausted 431
Final Demo Embellishments 431
Save Point Reached 434
Chapter 11 3D Audio—Turning Noise into Game Sounds 
435 
The Design of OpenAL: Sources, Buffers, and Listeners 
435 
Limits of 3D Audio in OpenAL 438
Integrating the Listener into Space Rocks! 438
Creating the Listener Class 439
Picking the Designated Driver 440
Adding Positions to Sounds 441
Handling Initial Positioning on Creation 443
Disabling Distance Attenuation 444
Working Around an alDistanceModelBug: Disabling Attenuation on a Per-Source Basis 
445 
Listener Orientation 446
Right-Handed Coordinate Systems and the Right-Hand Rule 446
Unit Circle, Polar-to-Rectangular Coordinates, Phase Shifting, and Trigonometric Identities 
449 
Integration into Space Rocks! 451
Source Direction and Cones 453
Inner Cone, Outer Cone, and Transitional Zone 453
Implementation Time 455
Velocity and the Doppler Effect 456
Velocities and Scaling Factors 458
Doppler Effect Example Time 459
Distance Attenuation 460
Attenuation Models 461
Inverse Distance 461
Inverse Distance Clamped 462
Linear Distance 462
Linear Distance Clamped 463
Exponential Distance 464
Exponential Distance Clamped 465
Distance Attenuation Parameters 466
Picking a Distance Model 467
Back to Space Rocks! 468
Using Relative Sound Properties to Selectively Disable 3D Effects 
471 
Achievement Unlocked: Use All OpenAL 3D Features 473
Chapter 12 Streaming: Thumping, Pulse-Quickening Game Excitement 
475 
Music and Beyond 475
iPod Music Library (Media Player Framework) 478
Playing iPod Music in Space Rocks! 480
Adding a Media Item Picker 482
Shake It! (Easy Accelerometer Shake Detection) 485
Audio Streaming 486
AVFoundation-Based Background Music for Space Rocks! 487
The Playback Sound Controller 488
Integration into Space Rocks! 491
OpenAL Buffer Queuing Introduction 493
Initialization 495
Unqueuing 497
Queuing 498
Buffer Underrun 499
Pausing 500
Fast Forwarding and Rewinding 500
Startup Number of Buffers and Filling the Queue 500
How to Choose the Number and Size of Buffers 501
OpenAL-Based Background Music for Space Rocks! 502
A New Buffer Data Class for Streaming 502
Unqueue the Processed Buffers 507
Queue a New Buffer If Necessary 508
Handle a Buffer Underrun 509
Handle EOF and Finished Playing 509
OpenALSoundController Changes 510
BBSceneController Integration 513
Analysis: Number of Buffers and Buffer Sizes 514
Star Power Ready! 515
OpenAL Speech for Space Rocks! 515
EWSoundSourceObject: Finishing the implementation 517
BBSceneController: Adding a New UFO 517
UFO: Taunting and Callbacks 518
The alBufferDataStatic Crashing Bug 521
Work-Arounds 523
Audio Queue Services Based Background Music for Space Rocks! 
525 
Rewind and Looping 526
Audio Session Interruptions 527
Perfect Full Combo! 528
Audio Capture 528
Audio Capture APIs 530
AVFoundation: File Recording with AVAudioRecorder 531
OpenAL: Capture Oscilloscope 536
The Capture APIs 539
ALC Device Enumeration 539
Capturing Audio 540
Back to OpenGL 543
Vertex Buffer Objects 543
Some Notes on OpenGL and OpenAL Optimization 545
The End of the Audio Road 547
Chapter 13 Networking for iPhone Games: Introduction 
549 
Meet the Network 549
Network Interfaces 550
TCP/IP 550
Bonjour 552
iPhone SDK and Networking 552
Sockets and Connections 552
BSD Socket API 553
CFNetwork 553
NSNetServices 553
GameKit 
553 
Summary 554
Chapter 14 Going Head to Head 
555 
Hello Pong! 555
Using Peer Picker to Find a Human Opponent 556
What Does It Look Like? 561
How Does It Work? 564
Making the Connection 565
Sending and Receiving Messages 568
Rolling the Dice 569
Ready…Set…Go! 577
Hits and Misses 579
The Paddle Comes Alive 587
Game Over: Handling Disconnects 592
Summary 593
Chapter 15 Party Time 
595 
8 x 3 = ? 595
Starting Point 595
Where Are We Going? 598
What’s in the Structure? 599
Making Connections 601
Introducing the Connection and Stream Objects 601
Connection Initialization 603
Closing and Cleanup 604
Reading Data 605
Writing Data 608
Handling Stream Events 609
The Complete Picture 609
Socket Servers 610
The SocketServer Class 610
Socket Server Initialization 611
Publishing via Bonjour 614
Starting and Stopping 615
Finding Servers via Bonjour 616
Looking for Servers 617
Connecting to Servers 619
Final Details 621
Implementing the Game Client 625
Tracing the Logic 625
Choosing the Network Message Format 628
Making It Talk 630
Hooking It Up 633
Implementing the Game Server 634
Managing Players 635
Laying It Out 637
Initialization 642
Players Joining and Leaving 643
Starting and Stopping Game Rounds 644
Collecting and Processing Answers 647
Hooking It Up 648
Summary 648
Chapter 16 Connecting with the Outside World 
649 
Challenges 649
Au Revoir, Bonjour! 649
No GameKit Peer-to-Peer for You! 650
Server, interrupted 650
Lag 651
It’s All Greek to Me… 651
And a Bunch More 652
Basics of Online Game Play 653
Client/Server Games 653
Connecting to a Game Server Without Bonjour 654
Peer-to-Peer Games 655
Something About Reinventing the Wheel 656
Like a Drop in the Ocean 657
Making Games More Social 657
Sharing High Scores Online 657
Chasing Ghosts 659
Chatting 659
Summary 660
Chapter 17 Putting It All Together: Now Comes the Fun Part 
661 
What We’ve Covered 661
Some Game Design Tips 662
Wrapping It Up 663
Index 664

Erscheint lt. Verlag 3.8.2010
Zusatzinfo 728 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Informatik Betriebssysteme / Server iOS
Informatik Betriebssysteme / Server Macintosh / Mac OS X
Informatik Programmiersprachen / -werkzeuge Mac / Cocoa Programmierung
Informatik Software Entwicklung Mobile- / App-Entwicklung
Informatik Software Entwicklung Spieleprogrammierung
Mathematik / Informatik Informatik Theorie / Studium
Informatik Weitere Themen Smartphones / Tablets
Schlagworte Animation • Apple iOS • Apple iPad • Apple iphone • graphics • Ios • iOS 5 • iPad • iPhone • Sound
ISBN-10 1-4302-2600-5 / 1430226005
ISBN-13 978-1-4302-2600-0 / 9781430226000
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 12,6 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Für Einsteiger ohne Vorkenntnisse

von Daniela Eichlseder; Anja Schmid

eBook Download (2023)
BILDNER Verlag
9,99
Unlock the world of iOS development with Swift 5.9, Xcode 15, and iOS …

von Ahmad Sahar

eBook Download (2023)
Packt Publishing (Verlag)
32,39