我有一个工作正常的 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)
有谁知道为什么将灰度区域设置为白色或者我如何才能达到预期的效果?提前致谢!