試試這個:
func blink() {
inviolable = true
lifeCount--
if lifeCount <= 0 {
lifeCount = 0
}
var changeColorAction: SKAction = SKAction.runBlock {() -> Void in
self.alpha = 0.5
}
var changeBackAction: SKAction = SKAction.runBlock {() -> Void in
self.alpha = 1.0
}
var waitAction: SKAction = SKAction.waitForDuration(0.2)
var finalAction: SKAction = SKAction.runBlock {() -> Void in
self.inviolable = false
}
var combined: SKAction = SKAction.sequence(
[ changeColorAction,
waitAction,
changeBackAction,
waitAction,
changeColorAction,
waitAction,
changeBackAction,
waitAction,
changeColorAction,
waitAction,
changeBackAction,
changeColorAction,
waitAction,
changeBackAction,
changeColorAction,
waitAction,
changeBackAction,
finalAction])
runAction(combined)
}
感謝名單!是的,這就是我一直在讀的東西。啊。大聲笑:) – Xofear
如果精靈動畫(例如走路),這並不會奏效。我認爲需要一個skeffectnode或着色器來將它設置爲白色。我認爲這將是非常簡單的着色器,但我沒有任何glsl着色器的技能。 –