How to wait for a duration before a sequence is run?

2.6k views Asked by At

I'm making a game with SpriteKit, and when it starts, I have nodes that spawn and fall from the top of the screen:

let wait = SKAction.waitForDuration(0.2, withRange: 0.19)
let spawn = SKAction.runBlock {
    self.addTears()
}
let sequence = SKAction.sequence([wait, spawn])
self.runAction(SKAction.repeatActionForever(sequence))

Before these nodes spawn, I want to wait for a duration of 1 second, but only when the game starts. I tried to add a waitForDuration before I run the sequence but it didn't work.

1

There are 1 answers

0
ABakerSmith On BEST ANSWER

Try:

let otherWait = SKAction.waitForDuration(1)
let otherSequence = SKAction.sequence([otherWait, SKAction.repeatActionForever(sequence)])
runAction(otherSequence)