You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
import Foundation
|
|
import SpriteKit
|
|
|
|
class BoardNode: SKShapeNode {
|
|
init(cells: (w: Int, h: Int), size: CGSize) {
|
|
super.init()
|
|
|
|
let path = CGMutablePath()
|
|
path.addRect(CGRect(x: 0, y: 0, width: size.width, height: size.height))
|
|
|
|
for y in 0..<cells.h {
|
|
for x in 0..<cells.w {
|
|
let border = PieceNode.pieceSize - PieceNode.pieceSize * PieceNode.borderFactor
|
|
let offset = border / 2
|
|
let size2 = PieceNode.pieceSize - border
|
|
|
|
path.addEllipse(in: CGRect(
|
|
x: CGFloat(x) * PieceNode.pieceSize + offset,
|
|
y: CGFloat(y) * PieceNode.pieceSize + offset,
|
|
width: size2,
|
|
height: size2
|
|
))
|
|
}
|
|
}
|
|
|
|
self.path = path
|
|
fillColor = .blue
|
|
strokeColor = .black
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
}
|