sprite kit - Swift - SpriteKit - Update SKAction.waitForDuration while running forever -
i trying update waitforduration action in sequence running forever.
override func didmovetoview(view: skview) { //code runaction(skaction.repeatactionforever(runseq())) } func runseq() -> skaction{ var difficulty: cgfloat = 0.75 let updateaction = skaction.runblock({ self.runcount++ self.runcount %= 4 println(self.runcount) if self.runcount == 0 { difficulty -= 0.1 } if self.children.count > 51{ println("you loose") }else{ self.scorelabel.text = string(format: "score: %i", self.score) } }) let createantaction = skaction.runblock({self.createant()}) var wait = skaction.waitforduration(nstimeinterval(difficulty)) let seq = skaction.sequence([createantaction, wait, updateaction]) return seq } difficulty value want, , every 4 loops want decrease amount. currently, starting value remains same, , doesn't change, though changing difficulty value, , recalling sequence of actions every time.
this happening because wait established .75, , nothing changing that. skaction.waitforduration(nstimeinterval(difficulty)) not looking reference difficulty, value, need rethink how want code this.
Comments
Post a Comment