sorry if I make any mistakes in terms of language, english is just my third language or so.
I'm learning how to code and as a first project I thought it would be a good idea to create a little stone paper scissors game against the computer. The problem is, that obviously the computer may not show his choice, so I have to create a function, which makes a random picture x (I'm using Apple's smileys for it) appear on the position x on the screen.
So I have to:
-
random number between 1 and 3 (var rN = GKRandomDistribution(lowestValue: 1, highestValue: 3)
-
let array = [opStone, opPaper, opScissors] //already declared as files
-
let choiceOp = array[rN]
-
choiceOp.position = CGPoint(x. ?, y: ?)
-
self.addChild(choiceOp)
... in theory. The problem is, that Swift does not accept a GKRandom distributed number rN at the third step.
Do you have any ideas how I could do it?
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire