Is there any way to make an entire scene, including all of its children nodes (not just the background color) darker in color? I am looking for an effect similar to that of this code:
node.color = SKColor.blackColor()
node.colorBlendFactor = 0.25
The above code shades the node
a darker color, while keeping the original colors (except that those colors are just darker) and detail.
However, as far as I can tell, this code doesn't work on scenes, it only works on SKSpriteNode
. Is there any way to darken a whole scene? The answer could be some sort of filter, a special way of colorizing a scene, or maybe there is just no way. Anything helps!
Thanks
When I need to do something similar to what you are asking, I simply add a SKSpriteNode
on top of everything else as follows:
let dimPanel = SKSpriteNode(color: UIColor.blackColor(), size: self.size)
dimPanel.alpha = 0.75
dimPanel.zPosition = 100
dimPanel.position = CGPoint(x: self.size.width/2, y: self.size.height/2)
self.addChild(dimPanel)
Just make sure the panel's zPosition
is greater than everything you want to make dimmer.
This way, you can also use the SKAction.colorizeWithColor
to change the panel to whatever color you want.
To add the panel and then remove it, you could start the alpha at 0, then do:
dimPanel.runAction(SKAction.sequence([
SKAction.fadeAlphaTo(0.75, duration: 3),
SKAction.fadeOutWithDuration(3)
]))