Class

GKGridGraph

A navigation graph for 2D game worlds where movement is constrained to an integer grid.

Overview

Use this class to generate a graph containing `GKGridGraphNode` objects representing a specified grid. Then use methods of the superclass `GKGraph` to find routes through the graph.

To learn more about graphs and pathfinding, see Pathfinding in GameplayKit Programming Guide.

Topics

Creating a Graph

`- initFromGridStartingAt:width:height:diagonalsAllowed:nodeClass:`

Initializes a graph that describes an integer grid with the specified dimensions, using the specified node class.

`+ graphFromGridStartingAt:width:height:diagonalsAllowed:nodeClass:`

Creates a graph that describes an integer grid with the specified dimensions, using the specified node class.

`- initFromGridStartingAt:width:height:diagonalsAllowed:`

Initializes a graph that describes an integer grid with the specified dimensions.

`+ graphFromGridStartingAt:width:height:diagonalsAllowed:`

Creates a graph that describes an integer grid with the specified dimensions.

Working with Nodes

`- nodeAtGridPosition:`

Returns the node in the graph at the specified grid coordinates.

`- connectNodeToAdjacentNodes:`

Adds the specified node to the graph, connecting it to its nearest neighbors in the grid.

Inspecting a Graph

`diagonalsAllowed`

A Boolean value that indicates whether nodes in the grid are connected to their diagonal neighbors.

`gridOrigin`

The lowest x- and y-coordinates that appear in the grid.

`gridWidth`

The number of possible x-coordinates in the grid.

`gridHeight`

The number of possible y-coordinates in the grid.

Relationships

Pathfinding

`GKGraph`

A collection of nodes that describes the navigability of a game world and provides pathfinding methods to search for routes through that space.

`GKObstacleGraph`

A navigation graph for 2D game worlds that creates a minimal network for precise pathfinding around obstacles.

`GKMeshGraph`

A navigation graph for 2D game worlds that creates a space-filling network for smooth pathfinding around obstacles.

`GKGraphNode`

A single node in a navigation graph for use in pathfinding.

`GKGraphNode2D`

A node in a navigation graph, associated with a point in continuous 2D space.

`GKGraphNode3D`

A node in a navigation graph, associated with a point in continuous 3D space.

`GKGridGraphNode`

A node in a navigation graph, associated with a position on a discrete two-dimensional grid.