ebook img

2D Apple Games by Tutorials (3rd Edition) - 2017 PDF

722 Pages·010.991 MB·English
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 2D Apple Games by Tutorials (3rd Edition) - 2017

2D Apple Games by Tutorials 2D Apple Games by Tutorials Caroline Begbie, Mike Berg, Michael Briscoe, Ali Hafizji, Marin Todorov and Ray Wenderlich Copyright ©2017 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 2D Apple Games by Tutorials Dedications "For my mum, who frequently challenges and always inspires me; also for Muffin, my patient and loyal puppy." — Caroline Begbie "To my wonderful wife and family, who make it possible to do what I do." — Mike Berg "To my father who ignited my love of computers. To my daughters Meghan and Brynne, and all six of my grandchildren. And to Lindsay for all the love and support." — Michael Briscoe "To my wife for always being supportive and to our bun in the oven, your parents await your arrival." — Kauserali Hafizji (a.k.a. Ali) "To my father." — Marin Todorov "To the authors, editors and leads at raywenderlich.com. Teamwork lets you dream bigger!" — Ray Wenderlich raywenderlich.com 3 2D Apple Games by Tutorials About the authors Caroline Begbie is living the dream as an indie iOS developer, educator and explorer. She loves the graphics and animation side of iOS and watches Disney movies "for research." Mike Berg is a full time game artist who is fortunate enough to work with many different indie game developers from all over the world. When he’s not manipulating pixel colors, he loves to eat good food, spend time with his family, play games and be happy. Michael Briscoe is an independent software developer with over 30 years of programming experience. Learning BASIC on a Commodore 64 way back in 1984, he’s been hooked on coding ever since. He enjoys creating simulations and games for all Apple platforms. You can visit his website at skyrocketsoftware.wordpress.com. Kauserali Hafizji (a.k.a. Ali) is a freelance software developer. He is fortunate to have worked on several large projects. He loves creating software that people use everyday whether it’s on the web, watch, phone or tv. A good read, cool dip in the pool and a hot cheesy meal would be the perfect end to his weekend. You can find out more about Ali on his website at: alihafizji.com. Marin Todorov is a part of Realm and raywenderlich.com. He’s also the author of books and apps. You can find out more at www.underplot.com. Ray Wenderlich is part of a great team — the raywenderlich.com team, a group of over 100 developers and editors from across the world. He and the rest of the team are passionate both about making apps and teaching others the techniques to make them. When Ray’s not programming, he’s probably playing video games, role playing games, or board games. raywenderlich.com 4 2D Apple Games by Tutorials About the editors Kyle Gorlick is the tech editor of this book. Kyle creates mobile apps and games. He likes to play volleyball and watch basketball. More info at kylegorlick.com. Chris Belanger is the 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. Tammy Coron is the final pass editor of this book. Tammy is an independent creative professional and the host of Roundabout: Creative Chaos. She’s also the co-founder of Day Of The Indie and the founder of Just Write Code. For more information visit TammyCoron.com. About the artists Mike Berg created the artwork for most of the games in this book. Mike is a full time game artist who is fortunate enough to work with many different indie game developers from all over the world. When he’s not manipulating pixel colors, he loves to eat good food, spend time with his family, play games and be happy. Vinnie Prabhu created all the music and sounds for the games in this book. Vinnie is a music composer/software engineer from Northern Virginia who has created music and sound work for concerts, plays and video games. He’s also a staff member on OverClocked ReMix, an online community for music and video game fans. You can find Vinnie on Twitter as @palpablevt. raywenderlich.com 5 2D Apple Games by Tutorials Vicki Wenderlich created many of the illustrations in this book and the artwork for Drop Charge. Vicki is Ray’s wife and business partner. She is a digital artist who creates illustrations, game art and a lot of other art or design work for the tutorials and books on raywenderlich.com. She also runs gameartguppy.com, which is a website where she creates free and inexpensive art assets for game developers to use in their games. When she’s not making art, she loves hiking, a good glass of wine and attempting to create the perfect cheese plate. raywenderlich.com 6 2D Apple Games by Tutorials Table of Contents: Overview Introduction ............................................................. 18 Section I: Getting Started................................... 33 Chapter 1: Sprites ............................................ 34 Chapter 2: Manual Movement ......................... 58 Chapter 3: Actions ........................................... 85 Chapter 4: Scenes.......................................... 116 Chapter 5: Camera ......................................... 127 Chapter 6: Labels........................................... 138 Section II: Physics and Nodes .......................... 154 Chapter 7: Scene Editor ................................. 155 Chapter 8: Beginning Physics ....................... 186 Chapter 9: Intermediate Physics ................... 212 Chapter 10: Advanced Physics ..................... 250 Chapter 11: Crop, Video, and Shape Nodes . 290 Section III: Tile Maps......................................... 319 Chapter 12: Beginning Tile Maps .................. 320 Chapter 13: Intermediate Tile Maps .............. 352 Chapter 14: Saving and Loading Games....... 381 Section IV: Juice ............................................... 413 Chapter 15: Making Drop Charge.................. 414 raywenderlich.com 7 2D Apple Games by Tutorials Chapter 16: Particle Systems ........................ 456 Chapter 17: Juice Up Your Game .................. 485 Section V: Other Platforms............................... 513 Chapter 18: macOS Games ........................... 514 Chapter 19: tvOS Games............................... 537 Chapter 20: watchOS Games........................ 552 Section VI: Advanced Topics............................ 575 Chapter 21: Game Center Achievements...... 576 Chapter 22: Game Center Leaderboards ...... 601 Chapter 23: ReplayKit.................................... 619 Section VII: Bonus Section............................... 644 Chapter 24: Augmented Reality & ARKit ...... 645 Chapter 25: 2D Art for Programmers ............ 672 Conclusion ............................................................ 722 raywenderlich.com 8 2D Apple Games by Tutorials Table of Contents: Extended Introduction ............................................................. 18 History of this book.............................................................................. 19 About this book.................................................................................... 19 iOS game development: a history........................................................ 21 What you need .................................................................................... 22 Who this book is for ............................................................................ 22 How to use this book........................................................................... 23 Whatʼs ahead: an overview.................................................................. 23 Section I: Getting started.................................................................... 24 Section II: Physics and nodes.............................................................. 25 Section III: Tile Maps .......................................................................... 26 Section IV: Juice.................................................................................. 27 Section V: Other Platforms.................................................................. 28 Section VI: Advanced Topics............................................................... 29 Section VI: Bonus chapters................................................................. 30 Book source code and forums............................................................. 31 Book updates....................................................................................... 31 License................................................................................................. 31 Acknowledgements............................................................................. 32 Section I: Getting Started................................... 33 Chapter 1: Sprites ................................................... 34 Getting started.................................................................................... 35 Displaying a sprite............................................................................... 46 Challenges........................................................................................... 55 Chapter 2: Manual Movement................................ 58 The SpriteKit game loop...................................................................... 59 Moving the zombie .............................................................................. 61 Rotating the zombie............................................................................. 77 Challenges........................................................................................... 79 raywenderlich.com 9 2D Apple Games by Tutorials Chapter 3: Actions.................................................. 85 Move action......................................................................................... 85 Sequence action ................................................................................. 88 Wait-for-duration action...................................................................... 89 Run-block action................................................................................. 90 Reversing actions................................................................................. 91 Repeating actions................................................................................ 94 Periodic spawning............................................................................... 95 Remove-from-parent action................................................................ 97 Animation action ................................................................................. 98 Stopping action.................................................................................. 100 Scale action........................................................................................ 101 Rotate action...................................................................................... 103 Group action...................................................................................... 104 Collision detection............................................................................. 105 The SpriteKit game loop, round 2...................................................... 108 Sound action...................................................................................... 109 Sharing actions .................................................................................. 110 Challenges.......................................................................................... 111 Chapter 4: Scenes................................................. 116 Win and lose conditions ..................................................................... 117 Creating a new scene......................................................................... 119 Transitioning to a scene..................................................................... 121 Creating a custom scene initializer.................................................... 122 Background music............................................................................. 124 Challenges......................................................................................... 125 Chapter 5: Camera................................................ 127 Lights, camera, action!...................................................................... 128 A scrolling background...................................................................... 130 An endlessly scrolling background.................................................... 132 Fixing the gameplay........................................................................... 134 Challenges......................................................................................... 137 raywenderlich.com 10

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.