One of the great features of SpriteKit's actions is that they can be chained together using action sequences. SpriteKit automatically ensures each action finishes before the next one begins – all you need to do is create the actions then put them into an array.
The example below makes a spaceship shrink down to 10% of its original size before fading out:
let sprite = SKSpriteNode(imageNamed:"Spaceship") let scale = SKAction.scale(to: 0.1, duration: 0.5) let fade = SKAction.fadeOut(withDuration: 0.5) let sequence = SKAction.sequence([scale, fade]) sprite.run(sequence)
Available from iOS 7.0 – see Hacking with Swift tutorial 14
Did this solution work for you? Please pass it on!
Other people are reading…
About the Swift Knowledge Base
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Love Hacking with Swift?
Get all 40 projects in PDF and HTML: buy the Hacking with Swift book! It contains over 1300 pages of hands-on Swift coding, and will really help boost your iOS career