ebook img

etc. More iPhone Cool Projects: Cool Developers Reveal the Details of Their Cooler Apps and Discuss Their iPad Development Experiences PDF

362 Pages·2016·7.31 MB·English
by  Chin D.
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview etc. More iPhone Cool Projects: Cool Developers Reveal the Details of Their Cooler Apps and Discuss Their iPad Development Experiences

CYAN YELLOW SPOT MATTE MAGENTA BLACK PANTONE 123 C BOOKS FOR PROFESSIONALS BY PROFESSIONALS® Companion eBook Available M ore iPhone Cool Projects features ten projects from eleven cool iPhone M Cool Developers Reveal the Details of Their Cooler iPhone Apps developers spanning a wide range of topics. No matter what types of applications you are interested in writing, there is something in More iPhone and Discuss Their iPad Development Experiences Cool Projects that you will find valuable. o Each one of the authors loves the iPhone and wants to share their experiences so r that you will be able to create great apps! e • Danton Chin instructs you on the use of concurrency on the iPhone to help you speed up your apps. i • Claus Höfele helps you streamline your content pipeline with an FBX P model importer. • h Ben Kazez sheds some light on the process of finding and utilizing external data providers using his app FlightTrack as an example. o • Saul Mora shows you how to use unit testing to greatly improve your code stability and help speed up your iPhone development. n • Leon Palm introduces you to the exciting world of computer vision e and shows you how to integrate the very powerful OpenCV libraries into your applications. • Scott Penberthy shows you how to make font rendering in OpenGL C simple and easy. o • Ben Britten Smith introduces you to 3D game creation using the Unity3D engine. o • Chuck Smith gives an excellent tutorial on 2D game creation with the Cocos2d framework. l • David Smith discusses how to handle large audio files and how he P built his app: Audiobooks. • r Arne de Vries and Joost van de Wijgerd team up to tell you about their experiences integrating push notifications into their popular o More eBuddy application. j More iPhone Cool Projects is so chock-full of useful stuff you can enjoy it as a whole e or just grab the bits that appeal to you. There is something in here for every iPhone developer! c iPhone Cool Projects t s RELATED TITLES Danton Chin | Claus Höfele | Ben Kazez | Saul Mora | Leon Palm S Scott Penberthy | Ben Britten Smith | Chuck Smith m COMPANION eBOOK SEE LAST PAGE FOR DETAILS ON $10 eBOOK VERSION ISBN 978-1-4302-2922-3 it David Smith | Arne de Vries | Joost van de Wijgerd h 53999 US $39.99 Shelve in Mobile Computing SOURCE CODE ONLINE User level: www.apress.com Intermediate–Advanced 9 781430 229223 this print for content only—size & color not accurate Trim: 7.5 x 9.25 spine = 0.8125" 360 page count More iPhone Cool Projects Cool Developers Reveal the Details of Their Cooler Apps and Discuss Their iPad Development Experiences ■ ■ ■ Danton Chin Ben Britten Smith Claus Höfele Chuck Smith Ben Kazez David Smith Saul Mora Arne de Vries Leon Palm Joost van de Wijgerd Scott Penberthy i More iPhone Cool Projects: Cool Developers Reveal the Details of Their Cooler Apps and Discuss Their iPad Development Experiences Copyright © 2010 by Danton Chin, Claus Höfele, Ben Kazez, Saul Mora, Leon Palm, Scott Penberthy, Ben Britten Smith, Chuck Smith, David Smith, Arne de Vries, and Joost van de Wijgerd All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2922-3 ISBN-13 (electronic): 978-1-4302-2923-0 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. Publisher and President: Paul Manning Lead Editor: Clay Andres Development Editors: Douglas Pundick, Matthew Moodie, and Brian MacDonald Technical Reviewer: Ben Britten Smith Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editors: Candace English and Debra Kelly Copy Editor: Katie Stence Compositor: MacPS, LLC Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. ii My gratitude and thanks to Mom and Dad (they would have liked this), to my wife Carol for everything over the years, and to our wonderful and artistically, musically talented son Tim. Also, thanks to Robert and Elizabeth Bergenheim, Elise Falkinburg and Errol Frankel, and their wonderfully intelligent sons, John and James Frankel. —Danton Chin Thanks to my wife and daughters, who inspire me daily to help make the world a better place. And for letting me buy that awesome new MacBook Pro (you know which one). —Saul Mora To my mother, who taught me to pursue excellence, and to my father, who always inspired creativity in me. Also to Andrea Zemenides, for being cute and little. —Leon Palm To the beautiful women in my family: Lisa, Julia, and Taylor. Taylor insists I mention our dog, Jack, and Snickers too. —Scott Penberthy To my lovely wife Leonie. —Ben Britten Smith To my parents, who were always there for me and gave me the joy of reading. Also to my professor, Dr. Gene Chase, who always brought an incredible amount of enthusiasm to everything he taught, and made computer science inspiring. —Chuck Smith To my wife and best friend, Lauren. —David Smith iii Contents at a Glance ■Contents at a Glance...................................................................................................iv ■Contents.......................................................................................................................v ■Preface.........................................................................................................................x ■Acknowledgments......................................................................................................xi ■Introduction...............................................................................................................xii Danton Chin....................................................................................................................1(cid:1) ■Chapter 1: Using Concurrency to Improve the Responsiveness of iPhone and iPad Applications...............................................................3(cid:1) Claus Höfele.................................................................................................................57(cid:1) ■Chapter 2: Your Own Content Pipeline: Importing 3D Art Assets into Your iPhone Game............................................................................59(cid:1) Ben Kazez....................................................................................................................89(cid:1) ■Chapter 3: How FlightTrack Uses External Data Providers to Power This Best-Selling Travel App........................................................91(cid:1) Saul Mora, Jr.............................................................................................................107(cid:1) ■Chapter 4: Write Better Code and Save Time with Unit Testing..............................109(cid:1) Leon Palm..................................................................................................................135(cid:1) ■Chapter 5: Fun with Computer Vision: Face Recognition with OpenCV on the iPhone...........................................................................137(cid:1) Scott Penberthy.........................................................................................................161(cid:1) ■Chapter 6: How to Use OpenGL Fonts without Losing Your Mind............................163(cid:1) Ben Britten Smith.......................................................................................................189(cid:1) ■Chapter 7: Game Development with Unity..............................................................191(cid:1) Chuck Smith...............................................................................................................249(cid:1) ■Chapter 8: Cocos2d for iPhone and iPad; It Is Easier than You Think....................251(cid:1) David Smith................................................................................................................287(cid:1) ■Chapter 9: Creating an Audio-Centric App for the iPhone with AVAudioPlayer..............................................................................289(cid:1) Joost van de Wijgerd and Arne de Vries....................................................................309(cid:1) ■Chapter 10: Implementing Push Notifications at eBuddy.......................................311(cid:1) ■Index.......................................................................................................................577 iv Contents ■Contents at a Glance.......................................................................................iv(cid:1) ■Contents..........................................................................................................v(cid:1) ■Preface............................................................................................................x(cid:1) ■Acknowledgments..........................................................................................xi(cid:1) ■Introduction...................................................................................................xii(cid:1) Danton Chin........................................................................................................1(cid:1) ■Chapter 1: Using Concurrency to Improve the Responsiveness of iPhone and iPad Applications....................................................3(cid:1) Prepare for Concurrency.........................................................................................................................................3(cid:1) Non-Responsive User Interfaces.............................................................................................................................6(cid:1) Building the Interestingness User Interface.......................................................................................................7(cid:1) Adding A JSON Parsing Framework to the Interestingness App......................................................................10(cid:1) Composing a RESTful Request for a List of Interestingness Images...............................................................10(cid:1) Using the RESTful Request and the JSON Parser to Parse the Response.......................................................12(cid:1) Implementing the UITableViewDataSource Protocol Methods to Display the Results.....................................14(cid:1) Concurrency Landscape.......................................................................................................................................16(cid:1) Considerations When Using Concurrent Solutions................................................................................................17(cid:1) Concurrency with NSThread and NSObject..........................................................................................................19(cid:1) Concurrency with Operation Objects....................................................................................................................24(cid:1) NSOperationQueue...........................................................................................................................................25(cid:1) NSOperation and NSInvocationOperation........................................................................................................26(cid:1) Concurrency with Operation Objects and Blocks..................................................................................................45(cid:1) Blocks..............................................................................................................................................................46(cid:1) Summary..............................................................................................................................................................53(cid:1) Resources.............................................................................................................................................................54(cid:1) Apple and Apple-related News........................................................................................................................54(cid:1) Apple Documentation.......................................................................................................................................54(cid:1) v ■ CONTENTS Blocks and Grand Central Dispatch.................................................................................................................55(cid:1) General.............................................................................................................................................................56(cid:1) JSON................................................................................................................................................................56(cid:1) POSIX Threads.................................................................................................................................................56(cid:1) Claus Höfele......................................................................................................57(cid:1) ■Chapter 2: Your Own Content Pipeline: Importing 3D Art Assets into Your iPhone Game.....................................................59(cid:1) Starting an iPhone Game......................................................................................................................................59(cid:1) Why Write Your Own Tools?..................................................................................................................................60(cid:1) Creating a Flexible Content Pipeline.....................................................................................................................61(cid:1) The Tools Problem...........................................................................................................................................61(cid:1) Data Exchange vs. In-Game File Formats........................................................................................................63(cid:1) Outline of the Example Code.................................................................................................................................64(cid:1) Exporting 3D Models.............................................................................................................................................65(cid:1) Reading FBX files.............................................................................................................................................66(cid:1) Traversing the Scene Contents.............................................................................................................................69(cid:1) Distinguishing between Different Types of Scene Nodes.....................................................................................70(cid:1) OpenGL Triangle Data......................................................................................................................................71(cid:1) Converting FBX Models into Triangle Data......................................................................................................73(cid:1) Converting Triangle Data into an In-Game Format..........................................................................................76(cid:1) Handling Textures.................................................................................................................................................79(cid:1) Image Compression vs. Texture Compression.................................................................................................79(cid:1) Imagination’s PVRTC Format...........................................................................................................................80(cid:1) Reading PNG Images.......................................................................................................................................82(cid:1) Converting Images into the PVRTC Format......................................................................................................84(cid:1) Rendering the Converted Data on the iPhone.......................................................................................................86(cid:1) Running the Converter Tool.............................................................................................................................86(cid:1) Creating the iPhone Project.............................................................................................................................86(cid:1) Summary..............................................................................................................................................................87(cid:1) Ben Kazez.........................................................................................................89(cid:1) ■Chapter 3: How FlightTrack Uses External Data Providers to Power This Best-Selling Travel App........................................91(cid:1) Choosing a Data Source........................................................................................................................................92(cid:1) API Design........................................................................................................................................................93(cid:1) Data Coverage and Accuracy...........................................................................................................................94(cid:1) Economics.......................................................................................................................................................95(cid:1) Trials................................................................................................................................................................96(cid:1) Source-Driven User Interface Design....................................................................................................................96(cid:1) Challenges.......................................................................................................................................................97(cid:1) Techniques from FlightTrack...........................................................................................................................98(cid:1) Design Patterns for Data Source Consumption.....................................................................................................99(cid:1) Direct-Client Consumption...............................................................................................................................99(cid:1) Server-Intermediary Consumption.................................................................................................................100(cid:1) Data-Driven Cocoa App Architecture..................................................................................................................101(cid:1) Data Model Design.........................................................................................................................................101(cid:1) Connecting Data to UI....................................................................................................................................102(cid:1) vi ■ CONTENTS Choosing an Approach...................................................................................................................................104(cid:1) Release!..............................................................................................................................................................105(cid:1) FlightTrack Today...............................................................................................................................................105(cid:1) Saul Mora, Jr..................................................................................................107(cid:1) ■Chapter 4: Write Better Code and Save Time with Unit Testing..................109(cid:1) Mock Objects.................................................................................................................................................120(cid:1) Testing Your Core Data Models......................................................................................................................127(cid:1) Summary............................................................................................................................................................134(cid:1) Leon Palm.......................................................................................................135(cid:1) ■Chapter 5: Fun with Computer Vision: Face Recognition with OpenCV on the iPhone........................................................137(cid:1) What Is Computer Vision?...................................................................................................................................140(cid:1) Why do Computer Vision on an iPhone?.............................................................................................................141(cid:1) Your Project: Creating a Face Detector...............................................................................................................142(cid:1) Setting Up OpenCV.........................................................................................................................................142(cid:1) Setting Up XCode...........................................................................................................................................145(cid:1) Adding Image Conversion Functions..............................................................................................................147(cid:1) Creating a Simple GUI....................................................................................................................................149(cid:1) Loading Images from the Photo Library.........................................................................................................151(cid:1) Loading the Haar Cascades...........................................................................................................................152(cid:1) Performing Face Detection............................................................................................................................154(cid:1) Bonus.............................................................................................................................................................156(cid:1) Performance Tweaking.......................................................................................................................................157(cid:1) Going Further......................................................................................................................................................159(cid:1) Summary............................................................................................................................................................160(cid:1) Scott Penberthy..............................................................................................161(cid:1) ■Chapter 6: How to Use OpenGL Fonts without Losing Your Mind................163(cid:1) History.................................................................................................................................................................164(cid:1) Terminology........................................................................................................................................................165(cid:1) Pragmatic Fontery...............................................................................................................................................167(cid:1) fCookie................................................................................................................................................................167(cid:1) Creating a Font’s Texture Atlas...........................................................................................................................168(cid:1) Texture Mapping............................................................................................................................................171(cid:1) Opening Your App..........................................................................................................................................173(cid:1) The Fontery Classes............................................................................................................................................173(cid:1) APGlyph..........................................................................................................................................................174(cid:1) APChar...........................................................................................................................................................175(cid:1) APText............................................................................................................................................................177(cid:1) Putting It All Together.........................................................................................................................................179(cid:1) Setting Up the Display.........................................................................................................................................181(cid:1) Creating Your Fortune.........................................................................................................................................182(cid:1) Displaying the Fortune........................................................................................................................................184(cid:1) Summary............................................................................................................................................................187(cid:1) vii ■ CONTENTS Ben Britten Smith...........................................................................................189(cid:1) ■Chapter 7: Game Development with Unity...................................................191(cid:1) What Is Unity?.....................................................................................................................................................192(cid:1) Why Use Unity?...................................................................................................................................................193(cid:1) Exploring the Unity Interface...............................................................................................................................195(cid:1) The Scene View.............................................................................................................................................196(cid:1) The Game View..............................................................................................................................................197(cid:1) The Project View............................................................................................................................................198(cid:1) The Hierarchy View........................................................................................................................................198(cid:1) The Inspector View........................................................................................................................................198(cid:1) How the Pipeline Flows..................................................................................................................................198(cid:1) The Transform: Everybody Has One...............................................................................................................199(cid:1) Meshes, Renderers, and Materials................................................................................................................200(cid:1) Importing Assets............................................................................................................................................204(cid:1) Custom Scripting...........................................................................................................................................205(cid:1) Playing Your Game.........................................................................................................................................208(cid:1) Coroutines Not Updates.................................................................................................................................209(cid:1) The Game View..............................................................................................................................................210(cid:1) Adding Lights.................................................................................................................................................213(cid:1) Using the iPhone as a Game Pad...................................................................................................................214(cid:1) Your Game..........................................................................................................................................................215(cid:1) Adding a Base to Work From.........................................................................................................................216(cid:1) The Main Character........................................................................................................................................218(cid:1) Inputs and Colliders.......................................................................................................................................224(cid:1) Your First Design Iteration.............................................................................................................................228(cid:1) Adding More Touchable Objects....................................................................................................................230(cid:1) Prefabs...........................................................................................................................................................231(cid:1) Animations.....................................................................................................................................................232(cid:1) Animation Import Settings.............................................................................................................................233(cid:1) Interacting with Something Besides the Floor...............................................................................................237(cid:1) User Interface................................................................................................................................................240(cid:1) Multiple Cameras...........................................................................................................................................241(cid:1) 3D Objects As GUI Items................................................................................................................................243(cid:1) Building for Your Device................................................................................................................................247(cid:1) Summary............................................................................................................................................................248(cid:1) Chuck Smith...................................................................................................249(cid:1) ■Chapter 8: Cocos2d for iPhone and iPad; It Is Easier than You Think.........251(cid:1) Origins of Cocos2d..............................................................................................................................................251(cid:1) Why Use Cocos2d?.............................................................................................................................................252(cid:1) Getting Started with Cocos2d.............................................................................................................................252(cid:1) Installing Cocos2d..........................................................................................................................................254(cid:1) Configuring Sample Code..............................................................................................................................254(cid:1) Installing the XCode Project Templates.........................................................................................................255(cid:1) Starting a New Project...................................................................................................................................256(cid:1) Introduction to Video Poker.................................................................................................................................257(cid:1) Making a Scene..................................................................................................................................................258(cid:1) Creating a Game Menu..................................................................................................................................260(cid:1) viii

Description:
Издательство Apress, 2010, -362 pp.This is the fifth in the Apress series of iPhone Projects books and the first to have the word iPad mentioned. To say that we’re all hyperaware of the iPad and all that it promises is something of an understatement; will eBooks and Apple’s new iBook
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.