【发布时间】:2016-06-05 09:28:20
【问题描述】:
我希望创建一个动画,以便在用户使用应用程序时在每个动画之间以随机间隔重复运行。
我创建了一个完成动画的函数。
func Yawn () {
Yawn1.append(character_atlas.textureNamed("1.png"))
Yawn1.append(character_atlas.textureNamed("2.png"))
Yawn2.append(character_atlas.textureNamed("3.png"))
Yawn2.append(character_atlas.textureNamed("4.png"))
Character_animate = SKSpriteNode(texture: Yawn1[0])
Character_animate2 = SKSpriteNode(texture: Yawn2[0])
Character_animate.size = CGSize(width: self.size.width/6.3, height: self.size.height/5.6)
Character_animate2.size = CGSize(width: self.size.width/6.3, height: self.size.height/5.6)
Character_animate2.position = CGPoint(x: self.frame.width/2, y: self.frame.height*0.90)
Character_animate.position = CGPoint(x: self.frame.width/2, y: self.frame.height*0.90)
Character_animate.zPosition = 3
Character_animate2.zPosition = 3
addChild(Character_animate)
addChild(Character_animate2)
var action1 = SKAction.repeatAction(SKAction.animateWithTextures(Yawn1, timePerFrame: 0.4), count: 3)
var action2 = SKAction.repeatAction(SKAction.animateWithTextures(Yawn2, timePerFrame: 1), count: 4)
var action3 = SKAction.sequence([action1,action2])
var action4 = SKAction.runBlock({self.Character_animate.removeFromParent()})
var action5 = SKAction.runBlock({self.Character_animate2.removeFromParent()})
var action6 = SKAction.sequence([action4,action5])
Character_animate2.runAction(action3,completion: {
self.runAction(action6)
})
}
【问题讨论】:
标签: ios iphone swift sprite-kit