A container for associating GameplayKit objects with a SpriteKit scene.


@interface GKScene : NSObject


When you create a scene in the Xcode SpriteKit scene editor, Xcode automatically creates a GKScene object to manage any GameplayKit objects you add to the scene (entities, components, or pathfinding graphs) and archive them alongside the SpriteKit scene content.

To use a SpriteKit scene that contains GameplayKit objects, load the scene file with the GKScene sceneWithFileNamed: method. You can then use the entities and graphs properties to access the GKEntity (and associated GKComponent) objects and GKGraph objects in the scene, and the rootNode property to access the scene’s SpriteKit content.

For more information on Entity-Component architecture and pathfinding graphs, see Entities and Components and Pathfinding in GameplayKit Programming Guide.


Loading a Scene File

+ sceneWithFileNamed:

Loads the specified SpriteKit scene file, creating a GKScene object containing the SpriteKit scene and associated GameplayKit objects.

Accessing the SpriteKit Scene


The SpriteKit scene managed by this GKScene object.

Managing Entities and Components


The list of GameplayKit entities managed by the scene.

- addEntity:

Adds a GameplayKit entity to the list of entities managed by the scene.

- removeEntity:

Removes a GameplayKit entity from the list of entities managed by the scene.

Managing Pathfinding Graphs


The list of pathfinding graph objects managed by the scene.

- removeGraph:

Removes a pathfinding graph from the list of graphs managed by the scene.

Instance Methods


Inherits From

See Also

Xcode and SpriteKit Integration


Identifies scene classes from other frameworks that support embedded GameplayKit information.


A component that manages a SpriteKit node.