问题描述
我目前正在使用 SKShapeNode
和 SKCropNode
在节点内创建孔。但是,我希望能够在它们内部创建自定义形状的孔。当我尝试用 SKCropNode
的 maskNode 属性内的自定义图像替换圆孔时,我得到了相反的结果。
这就是我要实现的目标:
这是我目前拥有的代码:
let radius = 200
let fullScreen: SKSpriteNode = SKSpriteNode(texture: nil,color: backgroundColor,size: CGSize(width: frame.size.width,height: frame.size.height))
let mask: SKSpriteNode = SKSpriteNode(texture: nil,color: .white,height: frame.size.height))
let circle: SKShapeNode = SKShapeNode(circleOfRadius: radius)
let crop: SKCropNode = SKCropNode()
fullScreen.position = .zero
fullScreen.alpha = 1
fullScreen.zPosition = 0
mask.position = .zero
mask.alpha = 1
circle.fillColor = .red
circle.lineWidth = 4
circle.alpha = 0.001
circle.blendMode = .replace
circle.position = CGPoint(x: 0,y: -100)
mask.addChild(circle)
crop.maskNode = mask
crop.name = "nodeWithHole"
crop.addChild(fullScreen)
addChild(crop)
这可以通过 SpriteKit 实现吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)