mardi 25 juillet 2017

Tic Tac Toe in swift - Winning line

okay I am struggling with this and it is really frustrating me, because I know it can't be that hard. I followed a tut to help me build a tic tac toe game to keep learning swift. In doing so I also wanted to add winning slashes for whatever combination that wins.

in my code I have

let winningCombinations = [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6]]

these are the buttons tags.

I have created labels that are just color bars with no text to be the slashes. I connected them one as

@IBOutlet weak var lineFirstRow: UILabel! 

then hid the label on the storyboard.

I have been trying things like

let lineRowOne = [0, 1, 2]

if lineRowOne = true {
 lineFirstRow.isHidden = true
} else {
 lineFirstRow.isHidden = false
}

I know this is not correct. Hoping someone can help me out.

Aucun commentaire:

Enregistrer un commentaire