【问题标题】:Swift iOS Sprite Kit - Fade sprite from one color to another [closed]Swift iOS Sprite Kit - 将精灵从一种颜色淡化为另一种颜色[关闭]
【发布时间】:2015-05-27 19:16:56
【问题描述】:

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

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

谢谢! 托比。

【问题讨论】:

    标签: ios swift sprite-kit


    【解决方案1】:

    您可以对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)
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-15
    • 2013-05-20
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    相关资源
    最近更新 更多