【问题标题】:SKCropNode not rendering greyscale mask values in SpriteKitSKCropNode 未在 SpriteKit 中呈现灰度蒙版值
【发布时间】:2015-06-23 04:11:40
【问题描述】:

我有一个工作正常的 SKCropNode,除了一件事 - 蒙版图像中非黑色或白色的所有灰度值都设置为纯白色。

这意味着所有灰度 alpha 值都不会以透明度进行渲染,而只是被设置为完全不透明。

这是我的代码:

    let foregroundTexture = SKTexture(image: UIImage(contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("P01_foreground.jpg"))!)
    var foreground = SKSpriteNode(texture: foregroundTexture)

    let maskTexture = SKTexture(image: UIImage(contentsOfFile:NSBundle.mainBundle().resourcePath!.stringByAppendingPathComponent("P01_mask.png"))!)
    var mask = SKSpriteNode(texture: maskTexture)

    var cropNode = SKCropNode()
    cropNode.addChild(foreground)
    cropNode.maskNode = mask
    cropNode.position = CGPoint(x: device.x/2, y: device.y/2)
    cropNode.zPosition = 2.0
    self.addChild(cropNode)

有谁知道为什么将灰度区域设置为白色,或者我如何才能达到预期的效果?提前致谢!

【问题讨论】:

    标签: swift sprite-kit mask skcropnode


    【解决方案1】:

    不幸的是,您似乎不能。 SKCropNode 目前只有一个属性,maskNode 本身。没有其他设置可用于执行您想要的操作。

    【讨论】:

    • 是的……我就是这么想的。 :(
    猜你喜欢
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    相关资源
    最近更新 更多