refactoring with master Aldin

This commit is contained in:
127-Z3R0 2020-04-22 15:59:31 +02:00
parent d596442015
commit e91b2c3220
2 changed files with 7 additions and 37 deletions

View File

@ -12,12 +12,12 @@ import GameplayKit
class Base : SKSpriteNode{
public static let colorSelected = SKColor.yellow
var availableBases = [Base]()
var standartColor = SKColor.green
var defaultColor = SKColor.green
init(color: UIColor, position: CGPoint, name: String) {
super.init(texture: SKTexture(imageNamed: "Base"), color: color, size: CGSize(width: 50.0, height: 50.0))
standartColor = color
defaultColor = color
self.colorBlendFactor = 1
self.name = name
self.position = position
@ -55,21 +55,11 @@ class Base : SKSpriteNode{
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
self.color = standartColor
self.color = defaultColor
for base in availableBases {
base.color = base.standartColor
base.color = base.defaultColor
base.size = CGSize(width: 50, height: 50)
}
}
}
enum PlayerColors {
static let colors = [
UIColor(red: 231/255, green: 76/255, blue: 60/255, alpha: 1.0),
UIColor(red: 241/255, green: 196/255, blue: 15/255, alpha: 1.0),
UIColor(red: 46/255, green: 204/255, blue: 113/255, alpha: 1.0),
UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0),
]
}

View File

@ -173,23 +173,11 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
}
func touchDown(atPoint pos : CGPoint) {
}
func touchMoved(toPoint pos : CGPoint) {
}
func touchUp(atPoint pos : CGPoint) {
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
let locationUser = touch.location(in: self)
if atPoint(locationUser) == menu {
menu.removeFromParent()
let locationUser = touch.location(in: self)
if atPoint(locationUser) == menu {
menu.removeFromParent()
}
}
}
@ -213,12 +201,4 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
func didBegin(_ contact: SKPhysicsContact) {
self.addChild(menu)
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func update(_ currentTime: TimeInterval) {
}
}