How Do I Blur a Scene in SpriteKit?

后端 未结 7 913
北恋
北恋 2020-11-28 06:00

How would I add a gaussian blur to all nodes (there\'s no fixed number of nodes) in an SKScene in SpriteKit? A label will be added on top of the scene later, this will be m

7条回答
  •  北海茫月
    2020-11-28 06:36

    Swift 4:

    add this to your gameScene if you want to blur everything in the scene:

    let  blur = CIFilter(name:"CIGaussianBlur",withInputParameters: ["inputRadius": 10.0])
            self.filter = blur
            self.shouldRasterize = true
            self.shouldEnableEffects = false
    

    change self.shouldEnableEffects = true when you want to use it.

提交回复
热议问题