如何制作SKSriteNode Glow(Swift)?

时间:2016-11-12 16:50:11

标签: ios swift sprite-kit

在我的游戏中,我有这些霓虹灯屏障。我想知道如何在它们周围发光效果,就像它们点亮一样。这是我创造障碍的功能:

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

}

在其他一些帖子中我读到你可以使用CIFilter?如果是,我该如何使用此功能。

如果有什么我可以尝试,请告诉我。谢谢!

0 个答案:

没有答案