O'Reilly logo

Getting Started with SpriteKit by Jorge Jordán

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Turning on the lights

One of the most important elements in a game is lighting as it helps you give the desired atmosphere or highlight some places on the scene.

SpriteKit provides the SKLightNode class that gives us the capability of creating lights and treating them as nodes and, as a consequence of that, we can decide which nodes on the scene will interact with the lights, casting shadows.

It's important to take into account that even though lights are nodes, they have no visual representation unless we associate a sprite node to it. We also need to bear in mind that it's possible that the shadows produced by a source of light will be shown over other nodes.

When allowing a node to be affected by a source of light in the scene, there are three ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required