samedi 24 décembre 2016

If statements with arrays in swift

I am having some trouble with my swift code. I want to make an endless game similar to the line zen, where a random node appears from the top. I used this code to help use the randomizer:

let randomWallNameIndex = Int(arc4random_uniform(2))
    let wallNames = ["obsticle #1", "obsticle #2"]
    //can also be [1, 2,]

    if wallNames == "obsticle #1"{

       //insert code here
    }

Although, I'm having trouble using the if statement to tell whether a specific number was selected and I can spawn that certain node.

Can someone find the solution?

Aucun commentaire:

Enregistrer un commentaire