Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SKSpriteNode with a glow
import SpriteKit
extension SKSpriteNode {
/// Initializes a textured sprite with a glow using an existing texture object.
convenience init(texture: SKTexture, glowRadius: CGFloat) {
self.init(texture: texture, color: .clear, size: texture.size())
let glow: SKEffectNode = {
let glow = SKEffectNode()
glow.addChild(SKSpriteNode(texture: texture))
glow.filter = CIFilter(name: "CIGaussianBlur", withInputParameters: ["inputRadius": glowRadius])
glow.shouldRasterize = true
return glow
let glowRoot: SKNode = {
let node = SKNode() = "Glow"
node.zPosition = -1
return node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment