I have 25 circles on screen each with a random colour that has been generated from the declared colours and each names 'CIRCLE_1', 'CIRCLE_2' etc.
When matching the node.fillColor with the pre-defined colours, only the Yellow returns a value. Everything else remains at 0.
Can't see what I'm doing wrong/missing.
let SDRed = SKColor(red: 255/255, green: 61/255, blue: 61/255, alpha: 1.0)
let SDBlue = SKColor(red: 0/255, green: 175/255, blue: 255/255, alpha: 1.0)
let SDYellow = SKColor(red: 255/255, green: 255/255, blue: 0/255, alpha: 1.0)
let SDOrange = SKColor(red: 255/255, green: 128/255, blue: 0/255, alpha: 1.0)
let SDPink = SKColor(red: 255/255, green: 105/255, blue: 180/255, alpha: 1.0)
let SDGreen = SKColor(red: 144/255, green: 238/255, blue: 144/255, alpha: 1.0)
let SDDodgerBlue = SKColor(red: 30/255, green: 144/255, blue: 255/255, alpha: 1.0)
func checkAllColoursAvailable() -> Bool {
var yellow = 0
var blue = 0
var pink = 0
var green = 0
var red = 0
var orange = 0
enumerateChildNodes(withName: "CIRCLE_*", using:
{ (node, stop) -> Void in
print((node as! SKShapeNode).name!)
let col: SKColor = (node as! SKShapeNode).fillColor
if col == SDYellow {
yellow = yellow + 1
} else if col == SDGreen {
green = green + 1
} else if col == SDDodgerBlue {
blue = blue + 1
} else if col == SDOrange {
orange = orange + 1
} else if col == SDRed {
red = red + 1
} else if col == SDPink {
pink = pink + 1
}
})
if yellow >= 1 && blue >= 1 && green >= 1 && orange >= 1 && red >= 1 && pink >= 1 {
return true
} else {
return false
}
}