Mac Developer Library

Developer

SpriteKit Framework Reference

Introduction

Classes   Protocols   Other Reference  

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.

Table I-1 lists a recommended reading order for the most important classes in SpriteKit. When you start building a game using SpriteKit, you should understand these classes before moving on to other classes in the framework. SpriteKit Programming Guide includes an exercise that teaches some of the most common ways to use these classes.

Table I-1Important classes in SpriteKit

Class

Description

SKView

A view that displays SpriteKit content.

SKScene

The root node for a node tree of sprites and other content. Scenes are drawn by a view. Scenes often perform global per-frame tasks.

SKNode

The class from which all SpriteKit node classes originate.

SKSpriteNode

A node that draws a textured sprite object.

SKTexture

A reusable texture image.

SKAction

An object that is executed by a node in the tree to modify the scene’s content or to implement game-specific behavior.

SKPhysicsBody

An object that adds physics characteristics (such as mass and velocity) to a node object.

Classes

Class

Abstract

NSObject

NSObject is the root class of most Objective-C class hierarchies.

SKAction

An SKAction object is an action that is executed by a node in the scene (SKScene).

SKConstraint

An SKConstraint object describes a mathematical constraint on a node’s position or orientation.

SKKeyframeSequence

An SKKeyframeSequence object specifies values for keyframes so that when a particle in an emitter node is simulated, that particle gets its keyframe values from the keyframe sequence (instead of from the normal emitter properties controlling that particle).

SKPhysicsBody

An SKPhysicsBody object is used to add physics simulation to a node.

SKPhysicsContact

An SKPhysicsContact object is created automatically by Sprite Kit to describe a contact between two physical bodies in a physics world.

SKPhysicsJoint

An SKPhysicsJoint object connects two physics bodies so that they are simulated together by the physics world.

SKPhysicsJointFixed

An SKPhysicsJointFixed object fuses two physics bodies together at a reference point.

SKPhysicsJointLimit

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

SKPhysicsJointPin

An SKPhysicsJointPin object allows two physics bodies to independently rotate around the anchor point as if pinned together.

SKPhysicsJointSliding

An SKPhysicsJointSliding object allows the anchor points of the two physics bodies to slide along a chosen axis.

SKPhysicsJointSpring

An SKPhysicsJointSpring object simulates connecting two physics bodies together with a spring.

SKPhysicsWorld

An SKPhysicsWorld object simulates collisions and other physical properties.

SKRange

An SKRange object defines a range of CGFloat values.

SKReachConstraints

An SKReachConstraints object is used to describe the range of motion for an SKNode object whenever an inverse kinematic (IK) action is executed.

SKRegion

An SKRegion object defines a mathematical shape and is typically used to determine whether a particular point lies inside this area.

SKShader

An SKShader object holds a custom OpenGL ES fragment shader.

SKTexture

An SKTexture object is an image that can be applied to SKSpriteNode and SKShapeNode objects or particles created by an SKEmitterNode object.

SKMutableTexture

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

SKTextureAtlas

An SKTextureAtlas object is a collection of related texture objects created from a texture atlas stored inside the app bundle.

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.

SKUniform

An SKUniform object is used to hold uniform data for a custom OpenGL or OpenGL ES shader.

NSResponder

NSResponder is an abstract class that forms the basis of event and command processing in the Application Kit.

SKNode

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

SK3DNode

A SK3DNode object is a Sprite Kit node that renders a Scene Kit scene as a 2D textured image.

SKCropNode

An SKCropNode crops the pixels drawn by its children so that only some of the pixels are rendered to the parent’s framebuffer.

SKEffectNode

An SKEffectNode object renders its children into a buffer and optionally applies a Core Image filter to this rendered output.

SKScene

An SKScene object represents a scene of content in Sprite Kit.

SKEmitterNode

A SKEmitterNode object is a node that automatically creates and renders small particle sprites.

SKFieldNode

A SKFieldNode applies physics effects to physics bodies within a specific part of the scene.

SKLabelNode

An SKLabelNode is a node that draws a string.

SKLightNode

A SKLightNode object is used to add lighting into a scene.

SKShapeNode

An SKShapeNode object draws a shape defined by a Core Graphics path.

SKSpriteNode

An SKSpriteNode is a node that draws a textured image, a colored square, or a textured image blended with a color.

SKVideoNode

An SKVideoNode object is a node that uses the AV Foundation framework to display live video content.

NSView

The NSView class defines the basic drawing, event-handling, and printing architecture of an app.

SKView

An SKView object is a view that displays Sprite Kit content.

Protocols

Protocol

Abstract

SKPhysicsContactDelegate

An object that implements the SKPhysicsContactDelegate protocol can respond when two physics bodies are in contact with each other in a physics world.

SKSceneDelegate

The SKSceneDelegate protocol is used to implement a delegate to be called whenever the scene is being animated.

Other Reference

Reference

SpriteKit Function Reference