Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift iOS雪碧套件-雪碧从一种颜色变为另一种颜色_Ios_Swift_Sprite Kit - Fatal编程技术网

Swift iOS雪碧套件-雪碧从一种颜色变为另一种颜色

Swift iOS雪碧套件-雪碧从一种颜色变为另一种颜色,ios,swift,sprite-kit,Ios,Swift,Sprite Kit,我需要在x时间内将精灵从一种颜色褪色到另一种颜色。 例如: 一个黄色的精灵在4秒内变为粉红色的精灵 如果可能,它需要接受十六进制颜色代码或类似的东西 谢谢! 托比。您可以使用SKAction上的colorizeWithColor方法创建一个SKAction,该方法将更改SKSpriteNode的颜色。下面是一个例子: let node = SKSpriteNode(color: UIColor.greenColor(), size: CGSize(width: 50, height: 50))

我需要在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)
谢谢,我能够使用允许UIColor接受十六进制代码。