mercredi 23 décembre 2015

arc4random_uniform negative 100 to positive 100

Trying to figure out how to make this little ball spawn anywhere from the center (self.frame.width / 2) to (self.frame.width / 2 - 100) and (self.frame.width / 2 + 100)

I found this code on stackoverflow and it seems fine, but my game crashes when the ball is about to spawn

ball.position = CGPoint(x: self.frame.width / 2 + (CGFloat(arc4random_uniform(201) - 100)), y: self.frame.height)

Help would be greatly appreciated as always <3




Aucun commentaire:

Enregistrer un commentaire