I'm trying to set the scene background color to a random color on launch using the below code.
func randomColor() -> UIColor{
//Generate between 0 to 1
let red:CGFloat = CGFloat(drand48())
let green:CGFloat = CGFloat(drand48())
let blue:CGFloat = CGFloat(drand48())
return UIColor(red:red, green: green, blue: blue, alpha: 1.0)
}
override func didMove(to view: SKView) {
self.backgroundColor = randomColor()
}
I'm using the code elsewhere in my program and its working as expected however when I try and set the scene background color with the same function it always loads the same green color. Any idea's why?