I want to get the effect show above using the steps below.
Basically, it consists of a background image SKSpriteNode of
And I add a red color SKShapeNode on top of it
The I want to cut out the SKLabel Node off of that Red ShapeNode.
I have a code that could fake this effect. But, if you move the shape node, then the gimmick will be exposed.
class GameScene: SKScene {
override func didMove(to view: SKView) {
let baseNode = SKSpriteNode(imageNamed: "step1")
baseNode.zPosition = 0
baseNode.position = CGPoint(x:0,y:100)
let shapeNode = SKShapeNode(rect: CGRect(origin: CGPoint(x:-155, y:-15), size: baseNode.size))
shapeNode.fillColor = .red
shapeNode.zPosition = 1
addChild(shapeNode)
let labelNode = SKLabelNode(text: "Hi")
labelNode.fontColor = .white
labelNode.fontName = "Arial"
labelNode.fontSize = 185
labelNode.zPosition = 2
let cropNode = SKCropNode()
cropNode.addChild(baseNode)
cropNode.maskNode = labelNode
cropNode.zPosition = 1
addChild(cropNode)
}
}
And If I try blend modes, it doesn't take me anywhere.]
class GameScene: SKScene {
override func didMove(to view: SKView) {
let baseNode = SKSpriteNode(imageNamed: "step1")
baseNode.zPosition = 0
baseNode.position = CGPoint(x:0,y:100)
addChild(baseNode)
let shapeNode = SKShapeNode(rect: CGRect(origin: CGPoint(x:-155, y:-15), size: baseNode.size))
shapeNode.fillColor = .green
shapeNode.zPosition = 1
addChild(shapeNode)
let labelNode = SKLabelNode(text: "Hi")
labelNode.fontColor = .red
labelNode.fontName = "Arial"
labelNode.fontSize = 185
labelNode.zPosition = 2
labelNode.blendMode = .subtract
shapeNode.addChild(labelNode)
let circle = SKShapeNode(circleOfRadius: 40)
circle.position = CGPoint(x:0,y:40)
circle.fillColor = .green
circle.blendMode = .subtract
circle.zPosition = 3
shapeNode.addChild(circle)
}
}