gpt4 book ai didi

ios - Action 完成时调用 func?

转载 作者:行者123 更新时间:2023-11-28 05:31:35 24 4
gpt4 key购买 nike

首先,感谢您抽出时间。我有一个相当简单的问题要解决,但似乎无法弄清楚。

我正在制作一款塔防游戏,我希望当敌人到达目的地时生命条会缩小。我想这一定很简单,就像在序列中添加另一个 Action ,调用一个可以减少生命点数的方法,但我还没有找到方法。任何帮助都会大有裨益。

        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() })

关于ios - Action 完成时调用 func?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27881147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com