You can repeat the function execution with NSTimer
.
override func didMoveToView(view: SKView) {
self.addChild(sprite)
var timer = NSTimer.scheduledTimerWithTimeInterval(0.2, target: self, selector: "doAction", userInfo: nil, repeats: true)
}
This will repeat your function execution for every 2 second.
EDIT :
You can do it this way too :
override func didMoveToView(view: SKView) {
self.addChild(sprite)
runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.runBlock(doAction), SKAction.waitForDuration(1.0)])))
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…