Framework

SpriteKit

Add high-performance 2D content with smooth animations to your app, or create a game with a high-level set of 2D game-based tools.

Overview

SpriteKit is a general-purpose framework for drawing shapes, particles, text, images, and video in two dimensions. It leverages Metal to achieve high-performance rendering, while offering a simple programming interface to make it easy to create games and other graphics-intensive apps. Using a rich set of animations and physics behaviors, you can quickly add life to your visual elements and gracefully transition between screens.

SpriteKit is supported on iOS, macOS, tvOS, and watchOS, and it integrates well with frameworks such as GameplayKit and SceneKit.

Topics

Essentials

Drawing SpriteKit Content in a View

Display visual content using SpriteKit.

class SKScene

An object that organizes all of the active SpriteKit content.

Nodes for Scene Building

Define the appearance or layout of scene content.

Scene Renderers

Draw a SpriteKit scene using a rendering object.

Choosing a SpriteKit Scene Renderer

Compare the different ways to display a SpriteKit scene.

class SKView

A view subclass that renders a SpriteKit scene.

class SKRenderer

An object that renders a scene into a custom Metal rendering pipeline and drives the scene update cycle.

class WKInterfaceSKScene

A visual WatchKit element that displays a SpriteKit scene.

Textures

Load graphics from various sources, or use an atlas to maximize rendering performance.

Maximizing Texture Performance

Speed up image display and enable more images to be displayed at one time.

class SKTexture

An image, decoded on the GPU, that can be used to render various SpriteKit objects.

class SKTextureAtlas

A collection of textures optimized for storage and drawing performance.

class SKMutableTexture

A texture whose contents can be dynamically updated.

Animation

Animate nodes by using a suite of provided actions, or create custom actions.

Getting Started with Actions

Create, configure, and run actions in SpriteKit.

class SKAction

An object that is run by a node to change its structure or content.

Constraints

Constrain the position or orientation of nodes.

class SKConstraint

A specification for constraining a node's position or rotation.

class SKReachConstraints

A specification of the degree of freedom when solving inverse kinematics.

Mathematical Tools

Multipurpose mathematical objects you use to facilitate other graphical work.

class SKKeyframeSequence

An object that performs interpolation between values specified at different times (keyframes).

class SKRange

A definition of a range of floating-point values.

class SKRegion

The definition of an arbitrary area.

Physics Simulation

Add physics behaviors to nodes in your scene.

Getting Started with Physics

Simulate gravity, acceleration, collision detection, or joints.

class SKPhysicsWorld

The driver of the physics engine in a scene; it exposes the ability for you to configure and query the physics system.

class SKPhysicsBody

An object that adds physics simulation to a node.

class SKPhysicsContact

A description of the contact between two physics bodies.

protocol SKPhysicsContactDelegate

Methods your app can implement to respond when physics bodies come into contact.

class SKFieldNode

A node that applies physics effects to nearby nodes.

Physics Joints

Connect physics bodies by using conceptual tools like pins, sliding joints, and spring joints.

Working with Inverse Kinematics

Gain fine-tuned control of objects that are connected by joints.

class SKPhysicsJoint

The abstract superclass for objects that connect physics bodies.

class SKPhysicsJointFixed

A joint that fuses two physics bodies together at a reference point.

class SKPhysicsJointLimit

A joint that imposes a maximum distance between two physics bodies, as if they were connected by a rope.

class SKPhysicsJointPin

A joint that pins together two physics bodies, allowing independent rotation.

class SKPhysicsJointSliding

A joint that allows two physics bodies to slide along an axis.

class SKPhysicsJointSpring

A joint that simulates a spring connecting two physics bodies.

Tiling

Configure the images or autotiling behavior of a tile map node.

class SKTileMapNode

A two-dimensional array of images.

class SKTileDefinition

A single tile that can be repeated in a tile map.

class SKTileGroup

A set of tiles that collectively define one type of terrain.

class SKTileGroupRule

Rules that describe how various tiles should be placed in a map.

class SKTileSet

A container for related tile groups.

Shaders

Customize node drawing by augmenting the node's color or shape.

class SKShader

An object that allows you to apply a custom fragment shader.

class SKAttribute

A specification for dynamic per-node data used with a custom shader.

class SKAttributeValue

A container for dynamic shader data associated with a node.

class SKUniform

A container for uniform shader data.

Warping

Distort a node by supplying vertices and their transformations.

class SKWarpGeometry

A definition for a deformation of nodes that conform to SKWarpable.

class SKWarpGeometryGrid

A definition for a grid-based deformation of nodes that conform to SKWarpable.

protocol SKWarpable

A protocol for objects that can be warped and animated by an SKWarpGeometry.

Reference

SpriteKit Enumerations

Enumerations used across SpriteKit.

SpriteKit Data Types

Data types used across SpriteKit.

SpriteKit Constants

Constants used across SpriteKit.

SpriteKit Type Aliases

Type aliases used across SpriteKit.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software