问题
I have some textures
var texturesOfEnemies = [SKTexture(imageNamed: "EnemyTexture1"),
SKTexture(imageNamed: "EnemyTexture2"),
SKTexture(imageNamed: "EnemyTexture3"),
SKTexture(imageNamed: "EnemyTexture4"),
SKTexture(imageNamed: "EnemyTexture5")]
I'm using arc4random
to select a random texture
var randomTextureOfEnemies = Int(arc4random_uniform(UInt32(texturesOfEnemies.count)))
and assign the selected texture to a node by
enemy.texture = texturesOfEnemies[randomTextureOfEnemies]
I have some actions for my node. When the actions are done, I want to change the texture of my node.
enemy.run(someAction, completion:{enemy.texture = texturesOfEnemies[randomTextureOfEnemies]})
This actions repeat and are working well, but the textures are only changing once. How can I change the texture every time the action completes?
来源:https://stackoverflow.com/questions/41306264/change-texture-with-random