Framework

SpriteKit

Create 2D sprite-based games using an optimized animation system, physics simulation, and event-handling support.

Overview

SpriteKit is a graphics rendering and animation infrastructure that you can use to animate arbitrary textured images, otherwise known as sprites. SpriteKit provides a traditional rendering loop that alternates between determining the contents of and rendering frames. You determine the contents of the frame and how those contents change. SpriteKit does the work to render that frame efficiently using graphics hardware. SpriteKit is optimized for applying arbitrary animations or changes to your content. This design makes SpriteKit more suitable for games and apps that require flexibility in how animations are handled.

Getting Started with SpriteKit

SpriteKit implements content as a hierarchical tree structure of nodes. A node tree consists of a scene node as the root node and other nodes that provide content. Each frame of a scene is processed and rendered to a view. The scene executes actions and simulates physics, both of which change the contents of the tree. Then the scene is rendered efficiently using SpriteKit.

To start learning SpriteKit, you should look at these classes in the following order, before moving on to other classes in the framework:

SpriteKit Programming Guide includes an exercise that teaches these classes.

Symbols

Displaying SpriteKit Content in Your App

Create the fundamental objects SpriteKit uses for representing and displaying content.

SKTransitionDirection

For some transitions, the direction in which the transition is performed.

SKSceneScaleMode

The modes that determine how the scene’s area is mapped to the view that presents it.

SKView

An SKView object is a view that displays SpriteKit content. This content is provided by an SKScene object.

SKScene

The root node for all Sprite Kit objects displayed in a view.

SKNode

The SKNode class is the fundamental building block of most SpriteKit content.

SKCameraNode

A node that controls camera movement, zoom and rotation.

SKViewDelegate

A protocol that allows dynamic control of an SKView object's render rate.

SKSceneDelegate

Methods your app can implement to participate in SpriteKit's animation loop.

SKTransition

An SKTransition object is used to perform an animated transition between a SKScene object already presented by an SKView object and a new incoming scene.

SKReferenceNode

A node that creates its children from an archived collection of other nodes.

Nodes That Draw Content

Generate visual nodes that can display shapes, textures, images and video.

SKTextureFilteringMode

Texture filtering modes to use when the texture is drawn in a size other than its native size.

SKBlendMode

The modes that describe how the source and destination pixel colors are used to calculate the new destination color.

SKLabelVerticalAlignmentMode

Options for aligning text vertically.

SKLabelHorizontalAlignmentMode

Options for aligning text horizontally.

SKCropNode

A node that masks pixels drawn by its children so that only some are rendered to the parent’s framebuffer.

SKMutableTexture

An SKMutableTexture object is a SpriteKit texture whose contents can be dynamically updated.

SKLabelNode

A node that displays a text label.

SKVideoNode

A node that displays video content.

SKTextureAtlas

An object containing a collection of textures.

SKTexture

An object which represents an image for use in SpriteKit.

SKSpriteNode

A node that draws a rectangular texture, image or color.

SKShapeNode

A node that renders a shape defined by a Core Graphics path.

Building Content with Tiles

Create large, detailed scenes with easily managed tiles.

SKTileDefinitionRotation

Options that define permitted tile definition rotation angles.

SKTileSetType

An enumeration defining how tiles are arranged.

SKTileAdjacencyMask

An enumeration defining how neighboring tiles are automatically placed next to each other.

SKTileDefinition

A class that describes a single type of tile that is used within a tile map.

SKTileGroup

A class that encapsulates a collection of related tile definitions that are designed to be pieced together within a tile map.

SKTileGroupRule

A class that defines how tiles should be placed in a map.

SKTileMapNode

A node used to render a 2D array of textured sprites.

SKTileSet

A class that contains all the tile definitions available for use in a tile map.

Animating Nodes

Add actions and constraints to animate nodes.

SKAction

An object which is executed by an SKNode to change its structure or content.

SKActionTimingFunction

The signature for the custom timing block.

SKActionTimingMode

The modes that an action can use to adjust the apparent timing of the action.

SKConstraint

An object which constrains a node's position or rotation.

SKReachConstraints

An object that controls the degree of freedom when solving inverse kinematics.

Warping Nodes

Distort nodes with warp geometry.

SKWarpGeometry

A class that defines the deformation of nodes that conform to SKWarpable.

SKWarpGeometryGrid

A class that defines grid based deformation of nodes that conform to SKWarpable.

SKWarpable

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

Lighting

Add lighting and shadows to scenes.

SKLightNode

A node that adds lighting into a scene.

Playing Audio

Add positional audio with effects such as occlusion and reverb.

SKAudioNode

A node which adds positional audio to a scene.

Simulating Physics

Simulate physics in a scene.

SKFieldForceEvaluator

The definition for a custom block that processes a single physics body’s interaction with the field.

SKPhysicsContactDelegate

A protocol that allows your app to respond when physics bodies come into contact.

SKFieldNode

A node that applies physics effects to a portion of the scene.

SKPhysicsBody

An object which adds physics simulation to a node.

SKPhysicsContact

An object which describes the contact between two physics bodies.

SKPhysicsJoint

An object which connects two physics bodies.

SKPhysicsJointFixed

An object which fixes two physics bodies together.

SKPhysicsJointLimit

An object which imposes a maximum distance between two physics bodies, as if they were connected by a rope.

SKPhysicsJointPin

An object which pins together two physics bodies, allowing independent rotation.

SKPhysicsJointSliding

An object which allows two physics bodies to slide along an axis.

SKPhysicsJointSpring

An object which simulates a spring connecting two physics bodies.

SKPhysicsWorld

An object which encapsulates a scene's physics simulation.

Particle Systems

Create high performance particle systems to simulate fluids, smoke and fire.

SKInterpolationMode

The modes used to interpolate between keyframes in the sequence.

SKRepeatMode

The modes used to determine how the sequence repeats.

SKParticleRenderOrder

Order to use when the emitter’s particles are rendered.

SKKeyframeSequence

An object which contains a sequence of values and times for controlling particle properties.

SKEmitterNode

A node that creates and renders particles.

Working with Shaders

Leverage the power of shaders to add custom effects to nodes and particle systems.

SKUniformType

An enumerated type to identify the type of a uniform object.

SKAttributeType

Options that specify an attribute's data type.

SKAttribute

A class that describes dynamic attribute data for an SKShader.

SKAttributeValue

A class that contains the value of a custom OpenGL or OpenGL ES shader attribute.

SKUniform

An object which holds uniform data for an SKShader.

SKShader

An object which allows nodes to be rendered or filtered with a custom OpenGL ES fragment shader.

Integrating with Other Frameworks

Integrate SpriteKit with other frameworks such as SceneKit and Core Image.

SKEffectNode

A node that can apply Core Image filters or SKWarpGeometry distortions to its children.

SK3DNode

A node that renders a Scene Kit scene as a 2D image.

Mathematical Classes

SKRange

An SKRange object defines a range of CGFloat values. Ranges are typically used to clamp a value so that it is within the specified range.

SKRegion

An object which defines an arbitrary area.

Extended Types

NSEvent

An NSEvent object, or simply an event, contains information about an input action such as a mouse click or a key press. AppKit associates each such user action with a window, reporting the event to the application that created the window. The NSEvent object contains pertinent information about each event, such as where the cursor was located or which character was typed. As the application receives events, it temporarily places them in a buffer called the event queue. When the application is ready to process an event, it takes one from the queue.

UITouch

A UITouch object represents the location, size, movement, and force of a finger on the screen for a particular event. The force of a touch is available starting in iOS 9 on devices that support 3D Touch or Apple Pencil.

See Also

Related Documentation