我正在做一些游戏的死亡动画,并想寻求一些帮助。我希望我的怪物能够在一阵烟雾中消失,但不会在它激发穿过他身体的斜线效果之前消失。SKAction排序和分组动画
我有3个动画,我想用:
weaponSlash - 跨怪物绘制一条线。看起来你用剑砍了他。
烟 - 一缕青烟慢慢扩大了
monsterFalling - 怪物回落,吓了一跳
我想要做的就是在这个顺序播放:
- 同时,斜线出现&怪物开始回落
- Abou t 0.25s进入上面的动画,我想云开始出现
- 当云即将结束(所以也许在1s后)我想怪物消失
- 删除烟雾,怪物,剑等,并丢弃一些硬币在地上
我开始喜欢这一点,因为的作品有些测试:(忽略上述时间现在)
//Cancel any current actions, like a monster attacking
monster.removeAllActions()
//since you can't play 3 animations on one node at the same time, you have to create 3 separate nodes for everything
let slash = SKSpriteNode()
let cloud = SKSpriteNode()
cloud.size = monster.size
slash.size = monster.size
monster.addChild(cloud)
monster.addChild(slash)
//Start the slash animation
slash.run(self.player.currentlyEquippedWeapon.attackAnimation())
//Start the cloud animation (how I get it is elsewhere and not relevant)
cloud.run(cloudAnimation)
//Run the monster death animation, followed by the cleanup/coin dropping
monster.run(SKAction.sequence([monster.deathAnimation(), SKAction.wait(forDuration: 1), postDeathActions]))
上面的变量PostDeathActions只是移除怪物节点并为一些硬币下落提供动画。
,我需要一些帮助
所以上面的代码不会彼此独立的所有运行工作如此之大的动画。在此基础上,你可以看到无论是完成斜线还是云,怪物都会执行两个动作:他回退,然后进行清理,这会清除怪物并产生硬币。正如你所看到的,我试图通过增加1秒的延迟来延迟这一点,但这有点破解,因为我可能有不同的怪物或攻击等,这些更快/更慢。我宁愿保证,所有事情在我将这个怪物消灭之前完成。
我想这组到SKAction.Run像这样:
let preDeath = SKAction.run {
[unowned self] in
monster.run(monster.deathAnimation()
slash.run(self.player.currentlyEquippedWeapon.attackAnimation())
cloud.run(cloudAnimation)
}
但这再次运行在同一时间一切。
我想要做的是序列像这样(伪代码):
让preDeathAnimations = SKAction.Group([斜线,云,monsterDeathAnimation]) ])
SKAction。序列([preDeathAnimations,postDeathActions])
所以这种方式在运行清理前运行全部3个。
有没有办法做这样的事情?我知道Sequnce/Group需要对SKNode运行,但我没有3个独立的。
感谢您阅读本文以及您可以提供的任何建议!
哇,这很有趣..让我稍后详细阅读。感谢您的帮助 – NullHypothesis
@NullHypothesis np。希望它有用。我认为粉扑是消失的动画。所以如果你想在粉扑之后再拍一张动画,那么你需要调整其他的代码。此外,对不起,这不是过度复制/粘贴,应该只是一个想法,如何得到你想要的 – Fluidity