1

我有一个工作正常的 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)

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

4

1 回答 1

1

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

于 2015-06-22T20:11:40.303 回答