|
|
|
@ -10,7 +10,7 @@ import SpriteKit
|
|
|
|
|
|
|
|
|
|
class SpriteMeeple : SKNode {
|
|
|
|
|
|
|
|
|
|
/*static let offset = CGPoint(x: -400, y: -300)
|
|
|
|
|
static let offset = CGPoint(x: -400, y: -300)
|
|
|
|
|
static let direction = CGVector(dx: 100, dy: 100)
|
|
|
|
|
|
|
|
|
|
let imageNode : SKSpriteNode
|
|
|
|
@ -25,18 +25,24 @@ class SpriteMeeple : SKNode {
|
|
|
|
|
|
|
|
|
|
init(imageNamed imageName: String, size: CGSize, backgroundColor: UIColor){
|
|
|
|
|
imageNode = SKSpriteNode(imageNamed: imageName)
|
|
|
|
|
imageNode.size = CGSize(width: 90, height: 90)
|
|
|
|
|
|
|
|
|
|
ellipseNode = SKShapeNode(ellipseOf: CGSize(width: 100, height: 100))
|
|
|
|
|
ellipseNode.fillColor = .yellow
|
|
|
|
|
|
|
|
|
|
cellPosition = CGPoint(x: 0, y: 0)
|
|
|
|
|
|
|
|
|
|
super.init()
|
|
|
|
|
|
|
|
|
|
ellipseNode = SKShapeNode(ellipseOf: CGSize(width: imageNode.size.width, height: imageNode.size.height))
|
|
|
|
|
//self.addChild(ellipseNode)
|
|
|
|
|
//self.addChild(imageNode)
|
|
|
|
|
//ellipseNode = SKShapeNode(ellipseOf: CGSize(width: imageNode.size.width, height: imageNode.size.height))
|
|
|
|
|
self.addChild(ellipseNode)
|
|
|
|
|
self.addChild(imageNode)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
required init?(coder aDecoder:NSCoder){
|
|
|
|
|
imageNode = SKSpriteNode(imageNamed: "ratMeeple")
|
|
|
|
|
//ellipseNode = SKSpriteNode(ellipseNode)
|
|
|
|
|
imageNode = SKSpriteNode(imageNamed: "rat")
|
|
|
|
|
ellipseNode = SKShapeNode(ellipseOf: CGSize(width: 100, height: 100))
|
|
|
|
|
cellPosition = CGPoint(x: 0, y: 0)
|
|
|
|
|
super.init(coder: aDecoder)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -45,11 +51,35 @@ class SpriteMeeple : SKNode {
|
|
|
|
|
get { true }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*override func touchesBegin(_ touches: Set<UITouch>, with event: UIEvent?){
|
|
|
|
|
Set<UITouch>, with event: UIEvent?)
|
|
|
|
|
}*/
|
|
|
|
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
|
|
|
|
var x: CGFloat = 0
|
|
|
|
|
var y: CGFloat = 0
|
|
|
|
|
let position = touches.first?.location(in: parent!) ?? CGPoint(x: 0, y: 0)
|
|
|
|
|
if (position.x < -400){
|
|
|
|
|
x = -400
|
|
|
|
|
}
|
|
|
|
|
else if (position.x > 500){
|
|
|
|
|
x = 500
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
x = (abs(x.truncatingRemainder(dividingBy: 100)) < 50) ? floor(position.x/100) * 100 : ceil(position.x/100) * 100
|
|
|
|
|
}
|
|
|
|
|
if (position.y < -300){
|
|
|
|
|
y = -300
|
|
|
|
|
}
|
|
|
|
|
else if (position.y > 400){
|
|
|
|
|
y = 400
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
y = (abs(y.truncatingRemainder(dividingBy: 100)) < 50) ? floor(position.y/100) * 100 : ceil(position.y/100) * 100
|
|
|
|
|
}
|
|
|
|
|
self.position = CGPoint(x: x, y: y)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?){
|
|
|
|
|
self.position = touches.first?.location(in: parent!) ?? CGPoint(x: 0, y: 0)
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|