lundi 13 juin 2016

Calling a random SKAction when my score increments?

I have three SKAction variables, all of them change the color of my ball on the screen. I want to make it so that whenever my score increments, it selects a random action out of the three. Is this possible? It would mean so much if you could help me. Thanks.

Here is my code thus far:

let colorize1 = SKAction.colorizeWithColor(.redColor(), colorBlendFactor: 1.0, duration: 0.001)

let colorize2 = SKAction.colorizeWithColor(.greenColor(), colorBlendFactor: 1.0, duration: 0.001)

let colorize3 = SKAction.colorizeWithColor(.blueColor(), colorBlendFactor: 1.0, duration: 0.001)

if score == 0 {
        Ball.runAction(colorize1)

    }

I have a for loop incrementing my score everytime "this thing" happens. When my score increments by 1 I want the ball to do colorize1, colorize2, or colorize3.

Thank you for your help in advance.

Aucun commentaire:

Enregistrer un commentaire