I am trying to animate a SKSpriteNode using an array of textures. What I am trying to achieve is to iterate through the texture array and change the SKSpriteNode texture through each iteration and display it's change for about 1 second. The only problem is, the loop is continuing as the animations are taking place I believe, so I can't see the changes.
I essentially want to be able to see each texture on the screen for about a second or two before it changes. Here is what I have so far.
var textures: [SKTexture] = [texture1, texture2, texture3, texture4]
var sprite = SKSpriteNode()
func animateSpriteTextures() {
for texture in textures {
/* Want to pause for about a second or two here, but does not. */
sprite.texture = texture
let scaleDown = SKAction.scaleTo(200, duration: 1)
let scaleUp = SKAction.scaleTo(300, duration: 1)
sprite.runAction(SKAction.sequence([scaleDown, scaleUp]))
}
}