首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SKCropNode不在SpriteKit中呈现灰度遮罩值

SKCropNode不在SpriteKit中呈现灰度遮罩值
EN

Stack Overflow用户
提问于 2015-06-23 03:00:37
回答 1查看 338关注 0票数 1

我有一个SKCropNode,它工作得很好,除了一件事--蒙版图像中所有不是黑色或白色的灰度值都被设置为纯白。

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

下面是我的代码:

代码语言:javascript
复制
    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)

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

EN

回答 1

Stack Overflow用户

发布于 2015-06-23 04:11:40

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30987751

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档