我正在学习Spritekit,我想知道如何通过点亮场景来传达闪电的印象。我不想显示实际的闪电。但是我希望天空中的云(例如)点亮,或整个场景(接着是适当的声音)在暴风雨天气中传达闪电效果。
任何帮助将不胜感激。谢谢。
我认为你可以做到这一点的一种方法是创建一个if语句并将颜色更改为白色然后再返回到它的形式。此外,如果一切都要精简,就需要一个新的zPosition。
if lightUpThePlace = true {
background.color = SKColor.white
background.zPosition = 100
//and then do either : (Because the language is read top to bottom)
background.color = SKColor.//the regular color
background.zPosition = //default zPosition
}
否则,您可以为屏幕制作一个足够大的白色精灵节点,然后立即将其移动到中心,然后让它消失。
let flash = SKSpritenode(imageNamed: "//white sprite node")
let move = SKAction.moveTo...
let despawn = flash.removeFromParent()
let sequence = SKAction.sequence([move, despawn])
希望这有帮助!