Class

SKReferenceNode

A node that's defined in an archived .sks file.

Declaration

@interface SKReferenceNode : SKNode

Overview

SKReferenceNode is used within an archived .sks file to refer to node defined in another .sks file without duplicating its definition. This way, a change to the referenced node propagates to all the references in other files.

As an example, you might want to share an enemy ship across two different levels, Scene1.sks and Scene2.sks, in a level-based game. Reference nodes allow you to do that without creating copies of the shared node and its properties.

To use a reference node:

  • Create the shared content in a separate archive

  • Add references to the shared archive within your scene archives

When each scene is loaded, the reference nodes are resolved dynamically, and therefore you only need to configure a shared object in one place.

Topics

Initializers

+ referenceNodeWithURL:

Creates a reference node from a URL.

- initWithURL:

Initializes a reference node from a URL.

+ referenceNodeWithFileNamed:

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

- initWithFileNamed:

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

- initWithCoder:

A method that initializes a reference node from an archive.

Regenerating

Load a reference nodes contents freshly from the archive again.

- resolveReferenceNode

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

Loading Callback

- didLoadReferenceNode:

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

Relationships

Inherits From

See Also

Base Nodes

Using Base Nodes to Lay Out SpriteKit Content

Use nonvisual nodes to define the layout of a scene.

SKNode

The base class of all SpriteKit nodes.

SKCameraNode

A node that determines which parts of the scene are visible within a view.