I've been trying out the SKLightNode
feature of SpriteKit and I'm having trouble manipulating shadows. Specifically, it appears the the falloff
property of my SKLightNode
doesn't do anything no matter what I set it to. Here is my code for the light:
//set up lights
var light = SKLightNode()
light.categoryBitMask = LightCategory.Light1
/*THIS DOESN'T DO ANYTHING*/ light.falloff = CGFloat(0.01)
light.ambientColor = UIColor.whiteColor()
light.lightColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 0.5)
light.shadowColor = UIColor(red: 0.5, green: 0.25, blue: 0.25, alpha: 0.5)
light.position = CGPointMake(size.width / 2.0, size.height * 0.75)
light.zPosition = DrawOrder.Lights
addChild(light)
And here is where I add it to the player:
//set up player
player.position = CGPoint(x: size.width * 0.1, y: size.height * 0.3)
player.shadowCastBitMask = LightCategory.Light1
player.zPosition = DrawOrder.Sprites
addChild(player)
According to Apple's documentation, falloff
is supposed to set "the exponent for the rate of decay of the light source" and accepts a CGFloat
from 0.0 to 1.0. But no matter what I set falloff
to, the shadow is endless.
What am I doing wrong?
Updated with screenshot (FPS low due to simulator):