动作完成后调用func?

时间:2015-01-10 20:58:10

标签: ios swift sprite-kit skaction

首先,谢谢你的时间。我有一个相当简单的问题要解决,但似乎无法弄明白。

我正在进行塔防游戏,我想在敌人到达目的地时拥有它,生命栏会缩小。我认为它必须像在序列中添加另一个动作一样简单,该序列调用可以减少生命点的方法,但我还没找到方法。任何帮助都会非常有益。

        let enemy1 = SKSpriteNode(imageNamed: "magSquare.png")
        enemy1.position = startPoint

        let step1 : SKAction = SKAction.moveTo(firstTurn, duration: duration)
        let step2 : SKAction = SKAction.moveTo(secondTurn, duration: duration)
        let step3 : SKAction = SKAction.moveTo(thirdTurn, duration: duration)
        let step4 : SKAction = SKAction.moveTo(fourthTurn, duration: duration)
        let step5 : SKAction = SKAction.moveTo(fifthTurn, duration: duration)
        let step6 : SKAction = SKAction.removeFromParent()
        //let step7 : SKAction = SKAction.** call method **

        enemy1.runAction(SKAction.sequence([step1, step2, step3, step4, step5, step6]))

        self.addChild(enemy1)

1 个答案:

答案 0 :(得分:2)

let step7 = SKAction.runBlock({ self.yourfunc() })