Swift version: 5.4
SpriteKit action groups let you run multiple SpriteKit actions simultaneously. The grouped actions become a new action that can go into a sequence, and SpriteKit automatically ensures all actions in a group finish before the sequence continues.
The code below makes a spaceship shrink down to 10% of its original size while fading out, with both actions happening at the same time:
let sprite = SKSpriteNode(imageNamed:"Spaceship") let scale = SKAction.scale(to: 0.1, duration: 0.5) let fade = SKAction.fadeOut(withDuration: 0.5) let group = SKAction.group([scale, fade]) sprite.run(group)
SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.
Available from iOS 7.0 – see Hacking with Swift tutorial 17
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.