0%

Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to social integration and monetization, this complete tour of Apple's powerful suite of game technologies covers it all. Familiar with Swift but new to game development? No problem. Start with the basics and then layer in the complexity as you work your way through three exciting - and fully playable - games. In the end, you'll know everything you need to go off and create your own video game masterpiece for any Apple platform.

Discover the power of Apple Game Frameworks, Xcode, and Swift by building three exciting games: Gloop Drop - a new twist on a classic arcade game, Val's Revenge - a roguelike dungeon crawler, and Hog - a social player vs. player mobile dice game. With Apple Game Frameworks, you can create high-performance, power-efficient games that work across all Apple platforms, including iOS, macOS, tvOS, and watchOS.

In this book, you'll discover how to...

Design and develop rich 2D gaming experiences using Apple's built-in game frameworks. Harness the power of SpriteKit using Xcode and Swift to create engaging player experiences. Use the visual Scene Editor to build complete scenes. Unleash the power of the Particle Editor to create amazing effects. Use GameplayKit to add advanced features to your games like pathfinding, artificial intelligence, and complex rule systems. Build larger, more complex worlds with tile maps and Xcode's visual Tile Map editor. Bring people together using GameKit and Game Center, Apple's social gaming network. Increase revenue with third-party banner ads and rewarded ads using Google AdMob (TM). Monetize your games with StoreKit and in-app purchases.

So, grab your gear and get your game on - it's time to level up your skills.

What You Need:

  • macOS Mojave 10.14.6 or newer
  • Xcode 11.3 or newer
  • Basic knowledge of Swift 5.1.4 or newer
  • Table of Contents

    1.  Foreword
    2.  Acknowledgments
    3.  Preface
      1. Who Should Read This Book
      2. What Are Apple Game Frameworks and Technologies
      3. What’s in This Book
      4. What’s Not in This Book
      5. How to Read This Book
      6. Conventions Used in This book
      7. Online Resources
      8. Next Steps
    4.  Get Ready for Game Development
      1. Discover Your Idea
      2. Make a Plan
      3. Gather Your Resources
      4. Next Steps
    5. Part I. Build Your First Game with SpriteKit
      1. 1. Creating Scenes with Sprites and Nodes
      2. Create the Project
      3. Explore the Default Template
      4. Clean Up the Default Template
      5. Set the Supported Device Orientation
      6. Create Your First SpriteKit Scene
      7. Create Your First Sprite Node
      8. Set Position, Coordinates, and Anchor Points
      9. Add the Foreground
      10. Next Steps
      11. 2. Adding Animation and Movement with Actions
      12. Animation in SpriteKit
      13. Add the Images Resources for the Player
      14. Create the Player Class
      15. Load the Textures
      16. Control Render Order with Z-Position
      17. Animate the Player with Actions
      18. Use the Animation Extension
      19. Move the Player with Actions
      20. Use Constraints to Limit Movement
      21. Set the Player’s Direction Using Scales
      22. Keep the Player’s Speed Consistent
      23. Next Steps
      24. 3. Chaining Actions and Using Iterative Design
      25. Add Your First Collectible Item
      26. Improve Code with Iterative and Incremental Development
      27. Chain Actions Together to Create a Sequence
      28. Use Actions to Run Code Blocks
      29. Use Level Data to Add Challenging Gameplay
      30. Use Iterative Design to Adjust the Player’s Movement
      31. Next Steps
      32. 4. Working with Physics and Collision Detection
      33. Run a Playground Physics Simulation
      34. A Closer Look at Physics Bodies
      35. Use Physics Bodies for Collision Detection
      36. Configure Physics Categories
      37. Handle Contact Between Physics Bodies
      38. Next Steps
      39. 5. Adding Labels and Working with the Game Loop
      40. Add Labels to Show Current Level and Score
      41. Use Variables to Monitor Game States
      42. Use the Game Loop to Apply Game Logic
      43. Use Attributed Strings with Labels
      44. Next Steps
      45. 6. Juicing Your Games with Sound and Effects
      46. Add Sound Effects
      47. Add Background Music
      48. Build More Robust Sound Systems
      49. Create an Endless Scrolling Background
      50. Juice Your Game with Particles
      51. Handle Hit-Testing and Touch Events
      52. Squeeze Out a Little More Juice
      53. Challenge Project
      54. Next Steps
    6. Part II. Use the Scene Editor to Build Games
      1. 7. Building Scenes with the Scene Editor
      2. Create the Project
      3. Clean Up the Default Template
      4. Add the Assets
      5. Add Nodes Using the Object Library
      6. Configure the View and Load the Scene
      7. Next Steps
      8. 8. Using the Scene Editor to Add Physics
      9. Write Code to Interface with the Scene
      10. Add Physics to the Player
      11. Move the Player Using Physics
      12. Connect the Attack Button
      13. Next Steps
      14. 9. Operating the Camera and Using References Nodes
      15. Add a Camera to Track the Player
      16. Use Reference Nodes in Your Scene
      17. Add Support for All Devices and Orientations
      18. Resize the Player Node on Device Rotation
      19. Lock the Location of the On-Screen Controls
      20. Refactor the Code and Clean Up the Project
      21. Next Steps
      22. 10. Extending Your Game World with Tile Maps
      23. Create a Bigger World with Tile Map Nodes
      24. Create a Tile Map Node
      25. Use the Tile Map Editor
      26. Add a Dungeon Tile Map
      27. Animating Tiles
      28. Configure Physics Bodies Using User Data
      29. Next Steps
    7. Part III. Scale Your Games with GameplayKit
      1. 11. Building Games with Entities and Components
      2. Organize the Project
      3. Add the Resources
      4. Create Your First Component
      5. Create Your First Entity
      6. Build a Monster Generator
      7. Animate the Monsters
      8. Next Steps
      9. 12. Using States and State Machines
      10. Create the Player States
      11. Set Up the Player State Machine
      12. Add a New Collectible Component
      13. Configure the Physics Bodies
      14. Add a Physics Contact Extension
      15. Place Collectibles and Doors
      16. Add Code to Destroy Collectibles
      17. Next Steps
      18. 13. Planning Routes and Creating Believable AI
      19. Modify the Monster Generator
      20. Use Agents, Goals, and Behaviors
      21. Add Agents to Monsters
      22. Add an Agent to the Player
      23. Use Multiple Goals
      24. Add the Player Agent to the Component System
      25. Add the Monster Entities to the Scene’s Entities Array
      26. Update Physics for Monsters and Projectiles
      27. Build a Better Health Component
      28. Add Pathfinding to Your Game
      29. Next Steps
    8. Part IV. Enhance the Player’s Experience
      1. 14. Using the Action Editor and Enhancing Gameplay
      2. Use the Action Editor to Add Actions
      3. Add the Player’s Heads-Up Display
      4. Build Better On-Screen Controls
      5. Next Steps
      6. 15. Adding More Scenes and Saving the Game
      7. Add New Scenes
      8. Present the Title Scene
      9. Load the First Game Scene
      10. Present the Game Over Scene
      11. Save and Load Game Data
      12. Exit the Map and Load the Next Scene
      13. Create Additional Game Scenes
      14. Support 3D Spatial Audio Effects
      15. Next Steps
    9. Part V. Build Social Games with GameKit
      1. 16. Adding Leaderboards and Achievements
      2. Add Game Center Capability Using Xcode
      3. Use App Store Connect to Add a New App
      4. Add a Leaderboard
      5. Add an Achievement
      6. Create the Game Center Helper
      7. Show the Game Center Dashboard
      8. Report Score to Leaderboard
      9. Report Achievement
      10. Next Steps
      11. 17. Creating Multiplayer Games with GameKit
      12. Request a Turn-Based Match
      13. Manage Multiplayer Matches
      14. Process Player Turns Using an Event Listener
      15. Use Custom Match Data in Multiplayer Games
      16. Update the Game Scene to Send the Match Data
      17. Use Multiple Devices or Simulators for Testing
      18. Next Steps
    10. Part VI. Bonus Content: Monetize Your Games
      1. 18. Using Ads to Increase Revenue
      2. Sign up for AdMob and Register Your App
      3. Create Ad Units
      4. Download and Integrate the Google Mobile Ads SDK
      5. Add the AdMob Helper File
      6. Use the AdMob Helper for Banner Ads
      7. Add the Continue Game Feature (Player Reward)
      8. Use the AdMob Helper for Rewarded Ads
      9. Create Custom Notifications
      10. Save and Load the Number of Continues
      11. Next Steps
      12. 19. Monetizing Your Games with In-App Purchases
      13. Add In-App Purchase Capability Using Xcode
      14. Use App Store Connect to Add a New App
      15. Add In-App Purchase Support to the Project
      16. Configure Products in Xcode
      17. Modify the GameData Class to Store Purchases
      18. Modify the AdMob Helper to Disable Ads
      19. Modify the GameScene Class to Handle Paid Continues
      20. Configure the Shop Scene
      21. Add the Shop Scene to the Main Game Scene
      22. Interface with StoreKit Using the Store Manager
      23. Test In-App Purchases
      24. Next Steps
    18.119.125.7