Just a small update this time. Added some placeholder tiles to the board. A little bit of tidying as well. Mostly moving some values into constants for re-use elsewhere. The only thing of note is using an SKCropNode
with a rounded rect, set to the same size as the board, so that the tiles always fit within the same space.
private func addTiles(parent: SKNode) {
let tileColor: [UIColor] = [SKColor(colorLiteralRed: 200/255, green: 182/255, blue: 240/255, alpha: 1),
SKColor(colorLiteralRed: 164/255, green: 134/255, blue: 222/255, alpha: 1),
SKColor(colorLiteralRed: 131/255, green: 95/255, blue: 200/255, alpha: 1)]
let tileSize = boardWidth / 10
for col in 0..<10 {
for row in 0..<10 {
let xValue = CGFloat(col)
let yValue = CGFloat(row)
let rect = CGRect(x: tileSize * xValue, y: tileSize * yValue, width: tileSize, height: tileSize)
let tile = SKShapeNode(rect: rect)
tile.fillColor = tileColor[((row * 10) + col) % tileColor.count]
tile.strokeColor = tile.fillColor
parent.addChild(tile)
}
}
}