O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning iOS 8 Game Development Using Swift

Book Description

Create robust and spectacular 2D and 3D games from scratch using Swift – Apple's latest and easy-to-learn programming language

In Detail

Game development has been simplified with Apple's new programming language-Swift. It starts with the absolute basics such as the Xcode interface and takes you all the way to Swift programming.

You will take a walk through the creation of 2D and 3D games followed by an introduction to SpriteKit and SceneKit. The book also looks at how game objects are placed in 3D scenes, how to use the graphics pipeline, and how objects are displayed on mobile screens. You will also delve into essential game concepts such as collision detection, animation, particle systems, and scene transitions. Finally, you will learn how to publish and distribute games to the iTunes store.

What You Will Learn

  • Learn Apple's latest programming language-Swift
  • Acquaint yourself with the Xcode interface
  • Create stunning games with SpriteKit and SceneKit
  • Understand the basics of graphics programming
  • Intensify your gameplay experience by learning how to add customized sound
  • Develop highly interactive games using animation, sound, collision detection, particle systems, and shaders
  • Package and publish games on the Apple App Store

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Learning iOS 8 Game Development Using Swift
    1. Table of Contents
    2. Learning iOS 8 Game Development Using Swift
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Getting Started
      1. Downloading and installing Xcode
      2. Creating an iOS developer account
      3. Introducing Swift
      4. Introducing Playground
      5. Exploring SpriteKit
        1. New features in SpriteKit
        2. Looking at the default SpriteKit project
      6. Exploring SceneKit
        1. Looking at the default SceneKit project
      7. Understanding 3D objects
      8. 2D and 3D coordinate systems
      9. The basics of SceneKit
      10. Introducing Metal
      11. The graphics pipeline
      12. Summary
    10. 2. Swift Basics
      1. Variables
      2. Operators
        1. Arithmetic operators
        2. Comparison operators
        3. Logical operators
        4. Arithmetic increment/decrement
        5. Composite operations
      3. Statements
        1. Decision-making statements
          1. The if statement
          2. The if else statement
          3. The else if statement
          4. Conditional expressions
          5. The switch statement
        2. Looping statements
          1. The while loop
          2. The do while loop
          3. The for loop
          4. The for in loop
      4. Arrays
        1. Looping through arrays
        2. Adding, removing, and inserting objects into arrays
        3. Important array functions
      5. Dictionary
        1. Adding and removing objects from the dictionary
        2. Looping through items in the dictionary
        3. Dictionary functions
      6. Functions
        1. Simple functions
        2. Passing a parameter
        3. Passing more than one parameter
        4. Returning a value
        5. Default and named parameters
        6. Returning more than one value
      7. Classes
        1. Properties and initializers
        2. Custom methods
        3. Inheritance
        4. Access specifiers
      8. Optionals
      9. Summary
    11. 3. An Introduction to Xcode
      1. Xcode application types
        1. Master-Detail Application
        2. Page-Based Application
        3. Tabbed Application
        4. Single View Application
      2. The Xcode interface
        1. The toolbar
        2. The Navigation panel
        3. The Project Navigation tab
        4. The Symbol Navigator tab
        5. The Find Navigator tab
        6. The Issue Navigator tab
        7. The Test Navigator tab
        8. The Debug Navigator tab
        9. The Breakpoint Navigator tab
        10. The Report Navigator tab
      3. The Utility panel
      4. The Single View Project
        1. The project root
          1. General
          2. The Capabilities tab
          3. The Info tab
          4. The Build Settings tab
          5. The Build Phases tab
          6. The Build Rules tab
        2. The project folder
        3. The Utility panel (Redux)
          1. The inspector tabs
            1. The File Inspector tab
            2. The Quick Help Inspector tab
            3. The Identity Inspector tab
            4. The Attributes Inspector tab
            5. The Size Inspector tab
            6. The Connections Inspector tab
          2. The library
            1. The File Template tab
            2. The Code Snippet Library tab
            3. The Object Library tab
            4. The Media Library tab
        4. The Debug panel
      5. Running the app on the device
      6. Summary
    12. 4. SpriteKit Basics
      1. Introduction to SpriteKit and SKScene
      2. Adding a main menu scene
      3. Adding a gameplay scene
      4. Adding a background and a hero
        1. Updating the position of the hero
        2. Adding player controls
        3. Adding enemies
        4. Adding enemy bullets
      5. Collision detection
      6. Keeping score
        1. Displaying the score
      7. Displaying the game over screen
      8. Adding the main menu button
      9. Saving the high score
      10. Resetting the high score count
      11. Summary
    13. 5. Animation and Particles
      1. Sprite sheet animation
      2. Basic SpriteKit animation
      3. Exploring Texture Packer
        1. Data
        2. Texture
        3. Layout
        4. Sprites
      4. Creating the hero spritesheet
      5. Animating the hero
      6. Particle systems
        1. Designing particles
          1. Name
          2. Background
          3. Particle Texture
          4. Particles
          5. Lifetime
          6. Position Range
          7. Angle
          8. Speed
          9. Acceleration
          10. Alpha
          11. Scale
          12. Rotation
          13. Color Blend
          14. Color Ramp
      7. Creating particle effects
      8. Adding a particle system to the game
      9. Summary
    14. 6. Audio and Parallax Effect
      1. Audio file formats
      2. Downloading and installing Audacity
      3. Converting the audio format
      4. Adding sound effects
        1. Adding the fireRocket sound effect
        2. Adding the enemy-kill sound effect
        3. Adding a sound effect at GameOver
      5. Adding background music
        1. Adding audio loops
      6. Parallax background theory
      7. Implementing the parallax effect
      8. Summary
    15. 7. Advanced SpriteKit
      1. Lighting and shadows
      2. Sprite Illuminator
        1. The Sprites panel
        2. The Preview panel
        3. The Tools panel
      3. Physics
      4. Objective-C in Swift
      5. Glyph Designer
        1. Implementing a Bitmap font
      6. Skeletal animation
      7. Summary
    16. 8. SceneKit
      1. Creating a scene with SCNScene
      2. Adding objects to the scene
        1. Adding a sphere to the scene
        2. Adding light sources
        3. Adding a camera to the scene
        4. Adding a floor
      3. Importing scenes from external 3D applications
      4. Adding objects and physics to the scene
        1. Accessing the hero object and adding a physics body
        2. Adding the ground
      5. Adding an enemy node
        1. Updating objects in the scene
        2. Checking for contact between objects
      6. Adding a SpriteKit overlay
        1. Adding labels and buttons
      7. Adding touch interactivity
      8. Finishing the game loop
        1. Making the hero jump
        2. Setting a game over condition
        3. Fixing the jump
      9. Adding wall and floor parallax
      10. Adding particles
      11. Summary
    17. 9. Metal
      1. Overview
      2. The graphics pipeline and shaders
        1. The preparation/initialization stage
          1. Get device
          2. Command queue
          3. Resources
          4. Render pipeline
          5. View
        2. The draw stage
          1. Start render pass
          2. Get command buffer
          3. Draw
          4. Commit the command buffer
      3. The basic Metal project
      4. The colored quad project
      5. The texture quad project
      6. Summary
    18. 10. Publishing and Distribution
      1. Getting Ms. tinyBazooka ready
      2. Generating the distribution certificate
      3. The iTunesConnect portal
      4. Creating the app
      5. Creating an ad hoc app
      6. References
      7. Alternative frameworks/engines
      8. Final remarks
      9. Summary
    19. Index