title: How do I center array of nodes in view?
body: <p>I have created a game board by programmatically drawing isometric tiles, then added them to an array. The nodes have have been places arbitrary to show the game board as much in the center as possible. Of course, this doesn't work when running on different devices. So, I'm looking for a way to always have the game board at the absolute center of the screen.</p>
  
  <p>I had an idea about merging the nodes into one big... node? and then setting its center to the center of the view. Is that doable? How? Or is there a better or simpler way?</p>
  
  <p>This is how I create a tile: </p>
  
  <pre><code>func newTile(size:CGSize) -&gt; SKShapeNode {
      let shape = SKShapeNode()
      let path = UIBezierPath()
      path.move(to: CGPoint(x:0, y:size.height / 2.0))
      path.addLine(to: CGPoint(x:size.width / 2.0, y:0))
      path.addLine(to: CGPoint(x:0, y:-size.height / 2.0))
      path.addLine(to: CGPoint(x:-size.width / 2.0, y:0))
      path.close()
  
      shape.path = path.cgPath
      shape.lineWidth = 1.0
      shape.fillColor = SKColor.gray
  
      return shape
  }
  </code></pre>
  
  <p>the function for placing the tile:</p>
  
  <pre><code>func tilePosition(col:Int, row:Int) -&gt; CGPoint {
      let x = (CGFloat(row) * tileWidth  / 2.0) + (CGFloat(col) * tileWidth  / 2.0)
      let y = (CGFloat(col) * tileHeight / 2.0) - (CGFloat(row) * tileHeight / 2.0)
      return CGPoint(x: x-250, y: y)
  }
  </code></pre>
  
  <p>... and adding to a board (I have deleted code here to simplify. This is just to give you an idea): </p>
  
  <pre><code>func createGameBoard(sceneView: SKScene) -&gt; [[SKShapeNode]] {
      let size = CGSize(width: tileWidth, height: tileHeight)
  
      for row in 1...numRows {
          var colArray = [SKShapeNode]()
  
  
          for col in 1...numCols {
              let tile = newTile(size: size)
              tile.position = tilePosition(col: col, row: row)
  
              sceneView.addChild(tile)
              colArray.append(tile)
          }
              gameBoardArray.append(colArray)
      }
      return gameBoardArray
  }
  </code></pre>
  
  <p>So, how do I place this thing smack in the middle of the view? That is, that the center tile is at the center of the screen and all the other tiles are aligned around it accordingly.</p>