---
title: GKScene
framework: gameplaykit
role: symbol
role_heading: Class
path: gameplaykit/gkscene
---

# GKScene

A container for associating GameplayKit objects with a SpriteKit scene.

## Declaration

```swift
class GKScene
```

## Overview

Overview 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 init(fileNamed:) 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. note: Any SpriteKit node in the scene to which you’ve attached an entity or components automatically has a GKSKNodeComponent object to manage the relationship between the node and the the GKEntity object it represents. For more information on Entity-Component architecture and pathfinding graphs, see Entities and Components and Pathfinding in GameplayKit Programming Guide.

## Topics

### Loading a Scene File

- [init(fileNamed:)](gameplaykit/gkscene/init(filenamed:).md)

### Accessing the SpriteKit Scene

- [rootNode](gameplaykit/gkscene/rootnode.md)

### Managing Entities and Components

- [entities](gameplaykit/gkscene/entities.md)
- [addEntity(_:)](gameplaykit/gkscene/addentity(_:).md)
- [removeEntity(_:)](gameplaykit/gkscene/removeentity(_:).md)

### Managing Pathfinding Graphs

- [graphs](gameplaykit/gkscene/graphs.md)
- [removeGraph(_:)](gameplaykit/gkscene/removegraph(_:).md)

### Initializers

- [init(fileNamed:rootNode:)](gameplaykit/gkscene/init(filenamed:rootnode:).md)
- [init(coder:)](gameplaykit/gkscene/init(coder:).md)

### Instance Methods

- [addGraph(_:name:)](gameplaykit/gkscene/addgraph(_:name:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Xcode and SpriteKit Integration

- [GKSceneRootNodeType](gameplaykit/gkscenerootnodetype.md)
- [GKSKNodeComponent](gameplaykit/gksknodecomponent.md)
