Basically this is one of the actions in a repeating sequence of actions. Each time the action gets called up in the sequence, i want the waiting time to increase, so i added a counter to act as the waiting time number and increment whenever the action gets called up in the sequence. The problem is with this, is that the variable only increments when the sequence starts, but doesn't change at all when the action happens again in the sequence, The waiting time remains constant throughout the game. and i can't figure out how to get it to change when it gets called up
var timeInterval = 0
//main method
override func didMoveToView(view: SKView) {
var scale = SKAction.scaleTo(5,duration: 2)
sprite = spriteSet(texture: SKTexture(imageNamed: "texture"), color: UIColor.brownColor(), size: CGSizeMake(100,100))
sprite.runAction(SKAction.repeatActionForever(SKAction.sequence([waitAction,scale,waitAction])))
}
//I want the time to increase each time this function is called in the sequence
func waitFunction() -> SKAction {
timeInterval++
return SKAction.waitForDuration(NSTimeInterval(timeInterval))
}
You can use the recursive way to accomplish what you want (increment duration of wait parameter):
What you are currently experiencing, is that wait action is created, initialized and reused in an action sequence. You have to rebuild an action each time.