重新启动skaction序列

时间:2015-07-15 06:14:44

标签: ios swift sprite-kit

在我的游戏中,我有一个skaction序列,我首先使用waitForDuration,然后执行其他操作。问题是,当用户输掉时,我需要使用waitForDuration从头开始重新启动序列。有没有人知道在didMoveToView中重置序列的方法?

override func didMoveToView(view: SKView) {

        var wait = SKAction.waitForDuration(15)
        let secondAction = SKAction.sequence([wait, SKAction.runBlock({() in self.addSecond(0.8)})])
        self.runAction(secondAction, completion: {println("second done")})
}

 func addSecond(waitDuration: NSTimeInterval) {

        var move = SKAction.runBlock({() in self.createTargets()})
        var wait = SKAction.waitForDuration(waitDuration)
        var moveAndWait = SKAction.repeatActionForever(SKAction.sequence([move, wait]))
        self.runAction(moveAndWait, withKey: "movingAction2")   
    }

0 个答案:

没有答案