You are previewing iOS Game Development By Example.
O'Reilly logo
iOS Game Development By Example

Book Description

Learn how to develop an ace game for your iOS device, using Sprite Kit

About This Book

  • Learn about the Sprite Kit engine and create games on the iOS platform from the ground up

  • Acquaint your Sprite Kit knowledge with Swift programming and turn your 2D game conceptualization into reality in no time

  • An abridged and focused guide to develop an exhaustive mobile game

  • Who This Book Is For

    This book is for beginners who want to start their game development odyssey in the iOS platform. If you are an intermediate or proficient game developer hailing from a different development platform, this book will be a perfect gateway to the Sprite Kit engine. The reader does not need to have any knowledge of Sprite Kit and building games on the iOS platform.

    What You Will Learn

  • Learn about the Sprite Kit game engine and create indie games in no time

  • Set sail on the quest of game development career by successfully creating a runner game

  • Know more about the IDE provided by Apple for game development – Xcode

  • Get an overview of Apple’s latest programming language, Swift

  • Discover the functionalities of scenes and nodes in a game

  • Explore how physics bodies work and how to add this feature into your game

  • Grasp knowledge of particle effect and shaders

  • Add a scoring system into your game to visualize high scores

  • In Detail

    Game development has always been an exciting subject for game enthusiasts and players and iOS game development takes a big piece of this cake in terms of perpetuating growth and creativity. With the newest version of iOS and Sprite Kit, comes a series of breathtaking features such as Metal rendering support, camera nodes, and a new and improved Scene Editor.

    Conceptualizing a game is a dream for both young and old. Sprite Kit is an exciting framework supported by Apple within the iOS development environment. With Sprite Kit, creating stunning games has become an easy avenue.

    Starting with the basics of game development and swift language, this book will guide you to create your own fully functional game. Dive in and learn how to build and deploy a game on your iOS platform using Sprite Kit game engine.

    Go on a detailed journey of game development on the iOS platform using the Sprite Kit game engine. Learn about various features implemented in iOS 8 that further increase the essence of game development using Sprite Kit. Build an endless runner game and implement features like physics bodies, character animations, scoring and other essential elements in a game. You will successfully conceive a 2D game along with discovering the path to reach the pinnacle of iOS game development.

    By the end of the book, you will not only have created an endless runner game but also have in-depth knowledge of creating larger games on the iOS platform.

    Style and approach

    An easy-to-follow, comprehensive guide that makes your learning experience more intriguing by gradually developing a Sprite Kit game. This book discusses each topic in detail making sure you attain a clear vision of the subject.

    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 If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

    Table of Contents

    1. iOS Game Development By Example
      1. Table of Contents
      2. iOS Game Development By Example
      3. Credits
      4. About the Author
      5. About the Reviewers
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. 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 color images of this book
          2. Downloading the example code
          3. Errata
          4. Piracy
          5. Questions
      8. 1. An Introduction to Sprite Kit
        1. What's new in iOS 8?
        2. Getting to know Swift
        3. Getting to know Sprite Kit
        4. Advantages of Sprite Kit
        5. Elements of Sprite Kit
          1. Scenes
          2. Nodes
          3. Actions
        6. Features of Sprite Kit
          1. Particle editor
          2. Texture atlas generator
          3. Shaders
          4. Lighting and shadows
          5. Physics
          6. The game loop
        7. Setting up a project
          1. The Hello World project
        8. Result
        9. Summary
      9. 2. Scenes in Sprite Kit
        1. Device orientation in Sprite Kit
        2. Orientation in our project
        3. Revisiting project elements
          1. AppDelegate.swift
          2. GameScene.sks
          3. GameScene.swift
          4. GameViewController.swift
          5. Main.storyboard
          6. LaunchScreen.xib
        4. Adjusting the project
        5. What is a scene?
        6. Coordinate system
        7. Creating a scene
        8. Creating a node tree
        9. Drawing order for a node tree
        10. Adding the first scene in our game
        11. Adding another scene to our game
        12. A transition from one scene to another
        13. Setting animation play during transition
        14. Creating transition objects
        15. Adding transition in our game
        16. Summary
      10. 3. Sprites
        1. SKSpriteNode
          1. Initializing a sprite
        2. The properties of SKSpriteNode
          1. Physical
          2. Texture
          3. centerRect
          4. Color
          5. Shader
        3. Adding a sprite without using textures
          1. Changing the color property
          2. Changing colorBlendFactor in MenuScene
          3. Changing the position of a sprite
          4. Resizing a sprite
        4. Working with texture objects
          1. What is a texture atlas?
        5. Preloading textures into memory
        6. Summary
      11. 4. Nodes in Sprite Kit
        1. All you need to know about nodes
          1. Using the SKNode object in the game
          2. Recognizing a node
          3. Initializing a node
          4. Building a node tree
          5. Actions on a node tree
          6. The coordinate system of a node
          7. Other functions and properties
        2. Creating subclasses for our Platformer game
          1. NodeMenuScene
            1. CropScene
            2. ShapeScene
            3. ParticleScene
            4. LightScene
            5. VideoNodeScene
        3. Summary
      12. 5. Physics in Sprite Kit
        1. Simulating physics in Sprite Kit
        2. SKPhysicsBody
          1. The initialization of volume-based physics bodies
          2. The initialization of edge-based physics bodies
          3. The behavior controller properties of a physics body
          4. The physical properties of a physics body
          5. Collision control properties and functions
          6. Forces and impulses
          7. The velocity of a physics body
          8. Using GameScene.swift to add physics bodies
        3. Summary
      13. 6. Animating Sprites, Controls, and SceneKit
        1. Animating nodes
          1. SKAction
          2. Adding a single action to a node
          3. Adding multiple actions to a node
        2. Creating actions
          1. Moving nodes using actions
          2. Rotating nodes using actions
          3. Changing the animation speed of a node
          4. Changing the scale position of a node
          5. Showing or hiding a node
          6. Changing the transparency of a node
          7. Changing the content of a sprite node
          8. Some other important actions
        3. Adding controls in Sprite Kit
          1. Node tapping and clicking
          2. Gesture recognitions (swiping in any direction, pinching, or rotating)
          3. Moving sprites with an accelerometer
        4. An introduction to SceneKit
        5. Adding animations and controls in our Platformer game
          1. Adding actions
          2. Transiting from GameScene to MenuScene
          3. Adding controls in our game
        6. Summary
      14. 7. Particle Effects and Shaders
        1. Particle effects
        2. The SKEmitter node
        3. Creating the particle effect
          1. Properties for determining a particle's lifetime
          2. Adding the particle effect in our Platformer game
            1. Adding the code to facilitate the particle effect
        4. Shaders
          1. A fact about using custom shaders
          2. The creation and initialization of new shader objects
          3. Uniform data in shaders
          4. Implementing shaders in the Platformer game
        5. Summary
      15. 8. Handling Multiple Scenes and Levels
        1. Optimizing game levels
          1. A strategy for multiple levels
            1. Core Data
        2. Adding levels in our Platformer game
          1. Adding the Level label
          2. Adding levels
        3. Adding the pause functionality
        4. Adding the NODE MENU button
        5. Summary
      16. 9. Performance Enhancement and Extras
        1. Performance enhancement
          1. Systemizing a game's content in the scene
          2. Performance enhancement by preloading textures
          3. Improving the drawing performance
          4. Improving performance with SKActions and constraints
          5. Improving the physics performance
          6. Improving shape's performance
          7. Improving effect's performance
          8. Improving lighting performance
        2. Measuring performance with instruments
        3. A scoring system in a game
          1. Adding a scoring system in our Platformer game
            1. Creating the Score label
            2. Incrementing the score when required
            3. Saving the high score
              1. Creating the scene to save the high score
              2. Adding a textbox to save player name
              3. Saving the player name with high score
            4. Creating the high score board
        4. Adding sound into a game
          1. Adding sounds into a Sprite Kit game
          2. Adding sound into our Platformer game
        5. Animation frames using SKTexture
          1. Adding the Run action texture to the player in the Platformer game
        6. Summary
      17. 10. Revisiting Our Game and More on iOS 9
        1. A recap on the development process of our Platformer game
        2. Working further on the Platformer game
        3. An introduction to Game Center
          1. The advantages of Game Center in a game
          2. Integrating Game Center in a game
            1. Working with Xcode
            2. Working with iTunes Connect
        4. What's new in iOS 9
        5. Summary
      18. Index