问题描述
我在 swift SpriteKit 中有一个执行动画的函数。当我需要在我的场景中播放动画时,我需要调用这个函数。当我调用该函数时,动画播放良好,但完成后它会在屏幕上留下动画的最后一帧。我是 swift 编程的新手,我无法找到解决我的问题的方法。我一直在研究解决方案,但似乎找不到。有什么方法可以在需要时调用以开始/暂停动画。
import SpriteKit
class GameScene: SKScene,SKPhysicsContactDelegate {
var exp_A: SKSpriteNode! = SKSpriteNode(imageNamed: "tile000")
var exp_Anim: [SKTexture] = []
}
override func didMove(to view: SKView) {
for i in 0...63{
if i < 10 {
print("tile00" + String(i))
exp_Anim.append(SKTexture(imageNamed: "tile00" + String(i)))
}
else{
print("tile0" + String(i))
exp_Anim.append(SKTexture(imageNamed: "tile0" + String(i)))
}
}
}
func expAnimation(){
self.addChild(exp_A)
let e_A = SKAction.animate(with: exp_Anim,timePerFrame: 0.01)
let exp_Anim = SKAction.repeat(e_A,count: 1)
exp_A.run(exp_Anim,completion: {() -> Void in self.removeFromParent()})
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)