add attributes to Base for unitCount and unitType. Init attributes in constructor with default parameters

This commit is contained in:
72haja 2020-04-22 18:16:25 +02:00
parent 6c68a569b9
commit d8adce88d2

View File

@ -13,8 +13,10 @@ class Base : SKSpriteNode{
public static let colorSelected = SKColor.yellow
var availableBases = [Base]()
var defaultColor = SKColor.green
var unitType: Unit = Unit.General;
var unitCount: Int = 0;
init(color: UIColor, position: CGPoint, name: String) {
init(color: UIColor, position: CGPoint, name: String, unitCount: Int = 0, unitType: Unit = Unit.General) {
super.init(texture: SKTexture(imageNamed: "Base"),
color: color,
size: CGSize(width: 50.0, height: 50.0)
@ -26,6 +28,8 @@ class Base : SKSpriteNode{
self.position = position
self.zPosition = 2
self.isUserInteractionEnabled = true
self.unitCount = unitCount
self.unitType = unitType
}
required init?(coder aDecoder: NSCoder) {
@ -45,8 +49,7 @@ class Base : SKSpriteNode{
]
)
)
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
self.color = SKColor.yellow