动作完成时调用 func?
call func when action completes?
首先,感谢您抽出宝贵时间。我有一个相当简单的问题要解决,但似乎无法弄清楚。
我正在制作一款塔防游戏,我希望当敌人到达目的地时生命条会减少。我想这一定很简单,就像在序列中添加另一个动作,调用一个可以减少生命点数的方法,但我还没有找到方法。任何帮助都会非常有益。
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)
let step7 = SKAction.runBlock({ self.yourfunc() })
首先,感谢您抽出宝贵时间。我有一个相当简单的问题要解决,但似乎无法弄清楚。
我正在制作一款塔防游戏,我希望当敌人到达目的地时生命条会减少。我想这一定很简单,就像在序列中添加另一个动作,调用一个可以减少生命点数的方法,但我还没有找到方法。任何帮助都会非常有益。
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)
let step7 = SKAction.runBlock({ self.yourfunc() })