Skip to content

Instantly share code, notes, and snippets.

@Pudding124
Created May 4, 2018 11:09
Show Gist options
  • Save Pudding124/60423a34f051e5b9104a71e5878cbf4a to your computer and use it in GitHub Desktop.
Save Pudding124/60423a34f051e5b9104a71e5878cbf4a to your computer and use it in GitHub Desktop.
func checkerBoard(){ //產生出遊戲題目
//亂數
let shuffledDistribution = GKShuffledDistribution(lowestValue: 0, highestValue: imageName.count - 1)
var count = 0;
for i in 0...5{
let index1 = shuffledDistribution.nextInt()
let index2 = shuffledDistribution.nextInt()
let index3 = shuffledDistribution.nextInt()
let index4 = shuffledDistribution.nextInt()
AllCard[count].setBackgroundImage(UIImage(named: imageName[index1]), for: .normal)
count += 1
AllCard[count].setBackgroundImage(UIImage(named: imageName[index2]), for: .normal)
count += 1
AllCard[count].setBackgroundImage(UIImage(named: imageName[index3]), for: .normal)
count += 1
AllCard[count].setBackgroundImage(UIImage(named: imageName[index4]), for: .normal)
count += 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment