I have an array that contains 8 CGPoints
:
let easyArray = [CGPointMake(0,0), CGPointMake(126.6,0), CGPointMake(253.4,0), CGPointMake(0,197.5), CGPointMake(126.7,197.5), CGPointMake(253.4,197.5), CGPointMake(0,395), CGPointMake(126.7,395), CGPointMake(253.4,395)]
I then have an object that moves to one of the points using a random function:
//Moving the object
let easyPos = randomInt(0,8)
let moveSelector = SKAction.moveTo(easyArray5s[easyPos], duration: 0)
easySelector5s.runAction(moveSelector)
//Random Function
func randomInt(min: Int, max:Int) -> Int {
return min + Int(arc4random_uniform(UInt32(max - min + 1)))
}
The problem I am having is that sometimes the object will move to one location then stay in that same location again. In other words the same location will get used twice one after another. How can I make it so that this doesn't happen. I am using swift.
Aucun commentaire:
Enregistrer un commentaire