Swift iOS Sprite Kit - 将精灵从一种颜色淡化到另一种颜色

时间:2015-05-27 19:16:56

标签: ios swift sprite-kit

我需要在x持续时间内将精灵从一种颜色淡化到另一种颜色。 例如: 一个黄色精灵在4秒内消失为粉红精灵。

如果可能,它需要接受十六进制颜色代码或类似的东西。

谢谢! 托比。

1 个答案:

答案 0 :(得分:2)

您可以使用colorizeWithColor上的SKAction方法创建SKAction,以更改SKSpriteNode的颜色。这是一个例子:

let node = SKSpriteNode(color: UIColor.greenColor(), size: CGSize(width: 50, height: 50))

// Position and add the node to the scene...

let colorize = SKAction.colorizeWithColor(UIColor.redColor(), colorBlendFactor: 1.0, duration: 5.0)
node.runAction(colorize)