Skip to main content

Check Sim Games

SpriteKit Overview

Table of Contents

What is SpriteKit?

SpriteKit is Apple’s framework for making 2D games. Some of the game types you can make with SpriteKit include the following:

  • Platform games
  • Brick breaking games
  • Arcade games
  • RPGs
  • Strategy games
  • Word games
  • Puzzle games

SpriteKit is different than game engines like Unity, Unreal, and Godot. There is no dedicated SpriteKit app to make games. SpriteKit developers generally use one of the following apps:

Use Xcode if you have a Mac. Use Swift Playgrounds if all you have is an iPad. The following articles provide introductions to using SpriteKit and Swift Playgrounds:

SpriteKit does not have visual scripting. You must write code to make a SpriteKit game. SpriteKit supports the Swift and Objective-C programming languages. I recommend using Swift. If you are using Swift Playgrounds, you must use Swift.

Reasons to Use SpriteKit

  • You can make games on an iPad with the Swift Playgrounds app.
  • You want to make a 2D game in Swift.
  • You don’t care about non-Apple platforms.
  • You can use GameplayKit to more easily add complex behavior to your games.

Reasons to Avoid SpriteKit

  • Your game will run only on Apple platforms.
  • Apple hasn’t updated SpriteKit in years.
  • You want to make 3D games.
  • You don’t like writing code.

SpriteKit Components

SpriteKit has the following components to make 2D games:

  • Scenes
  • Nodes
  • Actions
  • Particle effects
  • Shaders

You don’t have to use all of the SpriteKit components in your game. You can definitely make a game without writing shaders or adding particle effects.

Scenes

The game action in a SpriteKit game takes place in a scene. Every SpriteKit game needs at least one scene. But you can create additional scenes if your game has multiple levels. You can also create a scene to show a game menu when the game launches or to show a Game Over scene when the game ends.

Xcode includes an editor to build scenes visually. Swift Playgrounds does not have an editor so you must build your scenes in code. The following article provides an introduction to Xcode’s scene editor:

Introducing Xcode’s Scene Editor

Nodes

Nodes represent the objects in a SpriteKit. Common nodes are the following:

  • Sprite nodes for the entities the player interacts with in the game
  • Label nodes for displaying text
  • Camera nodes to scroll the screen
  • Light nodes for lighting a scene
  • Audio nodes for playing sounds
  • Tile map nodes for laying out levels

SpriteKit nodes inherit from the SKNode class.

Actions

Actions apply changes to nodes. Some things you can do with actions include the following:

  • Move sprites
  • Resize sprites
  • Rotate sprites
  • Animate sprites
  • Play sounds

The SKAction class has dozens of built in actions that you can use by calling the class initializers.

Particle Effects

Particle effects let you add visual flair to your game. If you shoot an enemy ship in a space shooting game, you can add a particle effect for the explosion.

Xcode has support for adding particle resource files to your projects and editing them in the scene editor.

Shaders

A shader is a program that runs on the graphics card instead of the CPU. Writing custom shaders can make your game stand out.

Where to Go for More Information

The most recent book on SpriteKit is Apple Game Frameworks and Technologies.

If you want a free book, Kodeco (formerly raywenderlich.com), has the book 2D Apple Games by Tutorials on their deprecated book GitHub page. The SpriteKit material is still relevant, but the code hasn’t been updated for the latest versions of Swift and Xcode.

This site has articles on SpriteKit.

Apple’s developer site has SpriteKit documentation. You can also read the SpriteKit documentation in Xcode by choosing Help > Developer Documentation. The SpriteKit documentation is in the Graphics and Games section of the documentation.