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


class SKReferenceNode : SKNode


Reference nodes are used to break your game up into multiple reusable parts. For example, games often provide multiple levels of game content but need to share content between those levels. If the game is packaged as a set of scene files, and content is duplicated between those files, then editing the duplicated content can be time consuming. With reference nodes, create the shared content as a separate archive, and then add reference nodes that reference this archive in your game scenes. When each level is loaded, the reference nodes are resolved, and the shared content is added to the final level. Reference nodes are almost always used in conjunction with the Xcode Scene editor.


Creating a Reference Node

init(url: URL)

Creates a reference node from a URL.

init(url: URL?)

Initializes a reference node from a URL.

init(fileNamed: String)

Creates a reference node from a file in the app’s main bundle.

init(fileNamed: String?)

Initializes a reference node from a file in the app’s main bundle.

Accessing Reference Nodes

func resolve()

Loads the reference node’s content and adds it as a new child node.

Loading a Reference Node

func didLoad(SKNode?)

A method called by SpriteKit after the reference node’s contents are loaded.

See Also

Nodes That Draw Content

class SKSpriteNode

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

class SKShapeNode

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

class SKLabelNode

A node that displays a text label.

class SKVideoNode

A node that displays video content.

class SKCropNode

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