3D Apple Games by Tutorials (Up to Date for Ios 10, Xcode 8 and Swift 3) [Englishonlineclub.Com].Pdf
Total Page:16
File Type:pdf, Size:1020Kb
3D iOS Games by Tutorials 3D Apple Games by Tutorials Chris Language Copyright ©2016 Razeware LLC. Notice of Rights All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner. Notice of Liability This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software. Trademarks All trademarks and registered trademarks appearing in this book are the property of their own respective owners. raywenderlich.com 2 3D iOS Games by Tutorials Dedications "To my wife Corné and my daughter Marizé. Thank you for your patience, support, belief, and most of all, your love. Everything I do, I do for you." — Chris Language raywenderlich.com 3 3D iOS Games by Tutorials About the author Chris Language is a seasoned coder with 20+ years of experience. He has fond memories of his childhood and his Commodore 64; more recently he started adding more good memories of life with all his iOS devices. By day, he fights for survival in the corporate jungle of Johannesburg, South Africa. By night he fights demons, dragons and angry little potty-mouth kids online. For relaxation he codes. You can find him on Twitter @ChrisLanguage. Forever Coder, Artist, Musician, Gamer and Dreamer. About the editors Toby Stephens is a tech editor for this book. Toby has been a software developer for over 25 years, working mainly in the financial sector. He is now Head of Development for Fuse, based in the UK. In his spare time he tinkers with writing iOS games, drawing Manga and creating music. You can follow him on Twitter @tjshae. Ken Woo is a tech editor for this book. Ken is an iOS developer with a passion for teaching. He loves building apps and wants to enable others to do the same. Deep down, he truly believes everyone can learn to code. He spends his time hacking at ideas, changing his daughter’s diapers and converting his wife to a boardgamer. You can follow his adventures on his blog at ikenwoo.com. Chris Belanger is an editor of this book. Chris is the Book Team Lead and Lead Editor for raywenderlich.com. If there are words to wrangle or a paragraph to ponder, he’s on the case. When he kicks back, you can usually find Chris with guitar in hand, looking for the nearest beach, or exploring the lakes and rivers in his part of the world in a canoe. Wendy Lincoln is an editor for this book. Wendy is a full-time project manager (PMP, actually) developing content by day and editing tutorials by night. She has an unusual background that involves a cooking show, coffee, a culinary degree and thousands of miles walked as a political activist. Occasionally, she closes her Mac to help her husband with home improvement projects or to get down with some serious yoga routines. raywenderlich.com 4 3D iOS Games by Tutorials Tammy Coron is the final pass editor of this book. Tammy is an independent creative professional and the host of two podcasts — Roundabout: Creative Chaos and Invisible Red. She’s also the founder of Just Write Code, a small independent production company based in West Tennessee. Find out more at TammyCoron.com. raywenderlich.com 5 3D iOS Games by Tutorials Table of Contents: Overview Introduction................................................................................ 15 Section I: Hello, SceneKit!............................................. 28 Chapter 1: Scenes ........................................................... 30 Chapter 2: Nodes............................................................ 39 Chapter 3: Physics........................................................... 58 Chapter 4: Render Loop ................................................ 70 Chapter 5: Particle Systems .......................................... 79 Section II: The SceneKit Editor...................................... 99 Chapter 6: SceneKit Editor.......................................... 100 Chapter 7: Cameras..................................................... 115 Chapter 8: Lights........................................................... 133 Chapter 9: Geometric Shapes ................................... 148 Chapter 10: Basic Collision Detection....................... 171 Section III: Intermediate SceneKit............................... 194 Chapter 11: Materials................................................. 195 Chapter 12: Reference Nodes ................................... 211 Chapter 13: Shadows .................................................. 224 Chapter 14: Intermediate Collision Detection......... 245 Chapter 15: Motion Control........................................ 263 Section IV: Cross Platform Games ............................. 279 Chapter 16: macOS Games....................................... 282 raywenderlich.com 6 3D iOS Games by Tutorials Chapter 17: tvOS Games........................................... 304 Chapter 18: watchOS Games.................................... 319 Section V: Advanced SceneKit ................................... 333 Chapter 19: Transitions................................................ 335 Chapter 20: Advanced Scene Creation ................... 359 Chapter 21: Actions...................................................... 382 Chapter 22: Advanced Collision Detection.............. 410 Chapter 23: Audio........................................................ 434 Section VI: Bonus Chapter.......................................... 447 Chapter 24: 3D Art for Programmers ...................... 448 Conclusion ............................................................................... 466 raywenderlich.com 7 3D iOS Games by Tutorials Table of Contents: Extended Introduction................................................................................ 15 A history of SceneKit......................................................................................................... 16 What you need.................................................................................................................. 17 Who this book is for.......................................................................................................... 17 How to use this book ......................................................................................................... 17 What’s ahead: an overview ............................................................................................ 18 Section I: Hello, Scene Kit!................................................................................................ 19 Section II: The Scene Kit Editor........................................................................................ 20 Section III: Intermediate SceneKit ................................................................................... 21 Section IV: Cross Platform Games .................................................................................. 22 Section V: Advanced SceneKit......................................................................................... 24 Section VI: Bonus Chapter ................................................................................................ 25 Book source code and forums ......................................................................................... 25 Book updates...................................................................................................................... 26 License.................................................................................................................................. 26 Acknowledgements............................................................................................................ 27 Section I: Hello, SceneKit!............................................. 28 Chapter 1: Scenes ................................................................... 30 Getting started .................................................................................................................. 30 The game project............................................................................................................... 31 Challenge ............................................................................................................................ 34 Cleaning up the game project ........................................................................................ 34 Setting up SceneKit ........................................................................................................... 35 Where to go from here? .................................................................................................. 38 Chapter 2: Nodes.................................................................... 39 Getting started .................................................................................................................. 39 Asset catalogs .................................................................................................................... 41 The SceneKit coordinate system...................................................................................... 47 Cameras .............................................................................................................................