Swift iOS Sprite Kit - 将精灵从一种颜色淡化为另一种颜色
Swift iOS Sprite Kit - Fade sprite from one color to another
我需要在 x 持续时间内将精灵从一种颜色淡入另一种颜色。
例如:
黄色精灵在 4 秒内淡化为粉色精灵。
如果可能,它需要接受十六进制颜色代码或类似的东西。
谢谢!
托比.
您可以在 SKAction
上使用 colorizeWithColor
方法创建一个 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)
我需要在 x 持续时间内将精灵从一种颜色淡入另一种颜色。 例如: 黄色精灵在 4 秒内淡化为粉色精灵。
如果可能,它需要接受十六进制颜色代码或类似的东西。
谢谢! 托比.
您可以在 SKAction
上使用 colorizeWithColor
方法创建一个 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)