title: How do I combine Sprite-Kit and Gameplay-Kit for pathfinding?
body: <p>I have been using <code>Sprite-Kit</code> to create a tile board for a game. The tiles are made up of <code>SKShapeNodes</code>. There is one player character and one enemy on the board, placed on different tiles (nodes). </p>
  
  <p>Now, I'm trying to use <code>Gameplay-Kit</code> <code>framework</code> to implement <code>pathfinding</code> between the player character and the enemy, but it doesn't seem like the <code>Sprite-Kit</code> <code>nodes</code> and the <code>Gameplay-Kit</code> <code>pathfinding</code> were meant to work together.</p>
  
  <p>The first thing in <code>pathfinding</code> is to create a graph. As I envision it, this graph should be made up by the <code>SKShapeNodes</code> I have in my <code>gameBoardArray[x][y]</code>. The graph, however, looks like something like this, and doesn't seem to take my <code>[[SKShapeNode]]</code> as an argument:</p>
  
  <pre><code>let graph = GKGridGraph(fromGridStartingAt: int2(0, 0), width: Int32(Maze.dimensions), height: Int32(Maze.dimensions), diagonalsAllowed: false)
  </code></pre>
  
  <p>This is just a default graph from another project. The thing is that I don't quite understand it and don't understand how I should connect this to my <code>gameBoardArray[x][y]</code>.</p>
  
  <p>Or am I completely missing how the graph is supposed to work? Isn't it supposed to be based on the gameBoard I have already created?</p>
  
  <p>EDIT
  I have tried the following:</p>
  
  <pre><code>let startNode = GKGraphNode2D(point: float2(x: Float(iBeginning), y: Float(jBeginning)))
  
  let endNode = GKGraphNode2D(point: float2(x: Float(iEnd), y: Float(jEnd)))
  
  let graph = GKGraph()
  
  let pathNodes = graph.findPath(from: startNode, to: endNode) as! [GKGraphNode2D]
  </code></pre>
  
  <p>The <code>startNode</code> and <code>endNode</code> use the correct values from the player and the enemy positions. Then I use <code>graph.findPath</code>... But then what? I don't think I understand how to actually use it. For example, is there a way I can mark the pathway with colors so that I can see if it even works? Or what am I supposed to do with it. (Note: I checked the documentation).</p>