【发布时间】:2015-05-27 19:16:56
【问题描述】:
我需要在 x 持续时间内将精灵从一种颜色淡化为另一种颜色。 例如: 黄色精灵在 4 秒内变为粉色精灵。
如果可能,它需要接受十六进制颜色代码或类似的东西。
谢谢! 托比。
【问题讨论】:
标签: ios swift sprite-kit
我需要在 x 持续时间内将精灵从一种颜色淡化为另一种颜色。 例如: 黄色精灵在 4 秒内变为粉色精灵。
如果可能,它需要接受十六进制颜色代码或类似的东西。
谢谢! 托比。
【问题讨论】:
标签: ios swift sprite-kit
您可以对SKAction 使用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)
【讨论】: