jeudi 4 février 2016

Is there a way to make a random position of a screen's width? [Swift]

I'm trying to make my programmatically appear somewhere random on the screen depending on the screen's size. I have already tried:

var random = Int(arc4random_uniform(UInt32(screenWidth)))
let newDrop:Drop = Drop(dropType: DropType.blue, xPos: random)

For some reason, the button ends up in the same place, near the edge of the screen:

enter image description here

Why is it appearing in the same position, and am I even doing it right. Is it even possible?

Thanks, Jack




Aucun commentaire:

Enregistrer un commentaire