How to increase the size of an SKLightNode in iOS
Asked Answered
G

1

6

I'm playing around with SKLightNodes and attempting to have an object (sun) shine light on anything around it. The problem is that when I add the SKLightNode to the sun node, the SKLightNode only appears in the very center of the sun. I've tried scaling the SKLightNode, but it seems to have no effect on the size or range of the SKLightNode. Here is how The SKLightNode is implemented.

  let light = SKLightNode()
                light.categoryBitMask = 1;
                light.falloff = 1;
                light.ambientColor = UIColor.whiteColor();
                light.setScale(50)
                star!.addChild(light)

If anyone has any input on how I can increase the effectiveness of the light source, I sure would appreciate it.

Greenwald answered 25/10, 2015 at 23:24 Comment(4)
Have you tried turning down the falloff? I believe that will make the light decay less.Gradual
I've tried adjusting the falloff, but nothing seems to change. My initial thought was that since I am adding the lightNode to an SKEmitterNode (sun), this is causing sizing issues. I've also tried creating a basic SKNode() as a holder for both the sun and the light, but it didn't seem to make a difference.Greenwald
Were you able to solve this?Darendaresay
I have not been able to increase the size or effectiveness of an SKLightNodeGreenwald
G
4

I think the only way to increase the "size" of an SKLightNode is decreasing the falloff value. You must need to set some value between 0 and 1.0.

    // very bright
    light?.falloff = 0.1

    // a little less bright
    light?.falloff = 0.5

    // the default brightness
    light?.falloff = 1.0

    // a little darker
    light?.falloff = 2.0

    // very dark
    light?.falloff = 5.0
Glyphography answered 26/2, 2019 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.