The following code crashes on iPhone 5, which means that it reaches the else case, but works fine in the simulator. It also works great if we use standard colors for red and blue (e.g. SKColor.blueColor (), SKColor.redColor ())
let BlueColor = SKColor(red: 0/255.0, green: 185/255.0, blue: 252/255.0, alpha: 1.0) let RedColor = SKColor(red: 250/255.0, green: 50/255.0, blue: 53/255.0, alpha: 1.0) let dot = SKSpriteNode(imageNamed: "dot50") dot.colorBlendFactor = 1.0 dot.color = BlueColor if (dot.color == BlueColor) { println("Blue!") } else if (dot.color == RedColor) { println("Red!") } else { println("Nooooo! This shouldn't happen") }
Any clues why?
ios iphone swift sprite-kit
Crashalot
source share