1

in my game I have these neon barriers. I would like to know how to make a glowing effect around them as if they were lighting up. Here is the function where I create the obstacles:

func addObstacle (_ type:ObstacleType) -> SKSpriteNode {

    let obstacle = SKSpriteNode(imageNamed: "neonLine2.png")
    obstacle.color = UIColor.green
    obstacle.size = CGSize(width: 0, height: 100)
    //(color: UIColor.white, size: CGSize(width: 0, height: 30))
    obstacle.name = "OBSTACLE"
    obstacle.physicsBody?.isDynamic = true

    switch type {
    case .small:
        obstacle.size.width = self.size.width * 0.2
        break
    case .medium:
        obstacle.size.width = self.size.width * 0.35
        break
    case .large:
        obstacle.size.width = self.size.width * 0.75
        break

    }

    obstacle.position = CGPoint(x: 0, y: self.size.height + obstacle.size.height)
    obstacle.physicsBody = SKPhysicsBody(rectangleOf: obstacle.size)

    obstacle.color = UIColor(red: 0, green: 0.4314, blue: 0.7373, alpha: 1.0)

    obstacle.colorBlendFactor = 1.0
    obstacle.physicsBody?.categoryBitMask = CollisionBitMask.Obstacle
    obstacle.physicsBody?.collisionBitMask = 0


    return obstacle

}

In some other post I read that you can use a CIFilter? If so how can I utilize this feature.

Please let me know if there is anything I can try. Thanks!

Matthew Anguelo
  • 293
  • 2
  • 12
  • 1
    have a look at this: http://stackoverflow.com/questions/40413994/applying-a-cifilter-with-skeffectnode-to-a-skspritenode you need to make a blurred edge that's of a colour of your choosing (or based on the sprite content) and then use additive blending of that with the background. This is the easiest way to make a glow. – Confused Nov 12 '16 at 17:07
  • 2
    I created and extension to add glow to an `SKSpriteNode`, it's [here](http://stackoverflow.com/questions/40362204/add-glowing-effect-to-an-skspritenode/40362874#40362874). – Luca Angeletti Nov 12 '16 at 18:42
  • Thanks you guys! that's exactly what I needed!!! – Matthew Anguelo Nov 12 '16 at 19:11

0 Answers0