Getting Started with SpriteKit

Book description

Develop fun and exciting games and create amazing animations for your existing apps with SpriteKit, Apple's 2D game development framework

About This Book
  • Learn the key concepts of game development in iOS
  • Take advantage of SpriteKit to create your own games and improve your apps
  • Follow the step-by-step chapters to create a complete product ready to submit to the App Store
Who This Book Is For

Getting Started with SpriteKit is for beginner-level iOS developers who want to add an extra edge to their apps and create amazing games using SpriteKit. It doesn't matter whether you have experience in iOS development or not as this book will show you the swift tricks you can use to create games.

What You Will Learn
  • Create and configure a SpriteKit project from scratch
  • Load and manage the basic elements of games such as sprites, labels, and geometrical primitives
  • Handle touch events, detect collisions, and play sound audio files
  • Create complex elements, animate sprites, and run the parallax effect
  • Complete your games with key components such as a main menu, transitions between scenes, a tutorial, and the ability to load and save data
  • Increase the efficiency of your device using the accelerometer or by adding shaders, lights, and shadows
  • Gain complementary techniques such as creating or finding audio resources, applying SpriteKit to apps, or using third-party tools
In Detail

SpriteKit is Apple's game engine to develop native iOS games. Strongly boosted by the Apple Inc., Cupertino, it has increased in popularity since its first release. This book shows you the solutions provided by SpriteKit to help you create any 2D game you can imagine and apply them to create animations that will highlight your existing apps.

This book will give you the knowledge you need to apply SpriteKit to your existing apps or create your own games from scratch.

Throughout the book, you will develop a complete game. The beautiful designs implemented in the game in this book will easily lead you to learn the basis of 2D game development, including creating and moving sprites, and adding them to a game scene. You will also discover how to apply advanced techniques such as collision detection, action execution, playing music, or running animations to give a more professional aspect to the game. You will finish your first game by learning how to add a main menu and a tutorial, as well as saving and loading data from and to the player's device.

Finally, you will find out how to apply some mobile games techniques such as accelerometer use or touch detection.

Style and approach

Written in an informal way with plenty of illustrative screenshots, this easy-to-follow and practical guide will help you get the most from SpriteKit. The main part of the book provides step-by-step instructions to develop of a complete product, while the last chapters give you some complementary techniques than can be used in mobile 2D game development.

Table of contents

  1. Getting Started with SpriteKit
    1. Table of Contents
    2. Getting Started with SpriteKit
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      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 example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. The First Step toward SpriteKit
      1. Game engines
      2. Creating a new SpriteKit project
      3. Running the project for first time
        1. How the default project looks like
      4. The SKNode class
        1. The SKNode class properties
          1. The position property
          2. The frame property
          3. The zPosition property
          4. The hidden property
          5. An alpha property
          6. The children node
          7. name
          8. userInteractionEnabled
        2. Using SKNode to organize a scene
      5. SKScene
        1. The game loop
        2. The SKScene properties
          1. scaleMode
          2. anchorPoint
          3. size
          4. backgroundColor
      6. Your first game – InsideTheHat
      7. Our first SKSpriteNode class
      8. Adding a background
      9. Working with screen resolutions
      10. Summary
    9. 2. What Makes a Game a Game?
      1. Handling touch events
        1. Handling actions
        2. Building a wall
        3. Running through the doors
      2. 1-star challenge: an easier way to reset position
        1. Solution
        2. Creating loops
        3. Installing doors into the wall
      3. Collision management
        1. Understanding collisions
        2. Handling collisions
      4. 1-star challenge: check collisions accurately
        1. Solution
      5. Creating labels
        1. Aligning labels
      6. Playing some music
        1. AVFoundation
      7. 2-star challenge: reproducing sound effects
        1. Solution
      8. Summary
    10. 3. Taking Games One Step Further
      1. Extending the SKNode class
        1. Creating a new class
        2. Handling the behavior of custom classes
      2. 2-star challenge: colliding puppets
        1. Solution
      3. The parallax effect
        1. The update method and delta times
      4. Creating animations in SpriteKit
      5. 2-star challenge: animate collisions
        1. Solution
      6. Geometrical primitives
      7. Summary
    11. 4. From Basic to Professional Games
      1. Ending the game
      2. 3-star challenge: restarting a game
        1. Solution
      3. Creating a main menu
      4. Transitions and scenes
        1. The SKTransition class
      5. Creating a tutorial
        1. Updating the tutorial steps
      6. Loading and saving data
        1. The NSUserDefaults class
      7. 2-star challenge: completing the tutorial
        1. Solution
        2. The property list files
      8. Summary
    12. 5. Utilizing the Hardware and Graphics Processor
      1. Using the accelerometer
        1. The CMMotionManager class
        2. Compensating for the position of the device
      2. Adding shaders to our game
      3. Turning on the lights
        1. Creating lights with the editor
        2. Programmatically creating lights
      4. 2-star challenge: moving lights
        1. Solution
      5. Summary
    13. 6. Auxiliary Techniques
      1. Creating particle systems
        1. Creating an emitter with the editor
        2. Creating the emitter programmatically
      2. Combining SpriteKit and UIKit
        1. Including UIKit in a game
        2. Including SpriteKit in an app
      3. Using third-party tools
        1. Creating audio resources
          1. Voice memos
          2. Audacity
          3. GarageBand
        2. Font makers
      4. How to find audio files
      5. How to find images
      6. Summary
    14. Index

Product information

  • Title: Getting Started with SpriteKit
  • Author(s): Jorge Jordán
  • Release date: January 2016
  • Publisher(s): Packt Publishing
  • ISBN: 9781785887338