Light
2D point or spot light with colour, energy, radius and falloff; casts shadows from physics shapes. Set the scene’s Ambient to darken unlit areas.
Type: LightNode · Category: Graphics & Rendering · Also found as: light, pointlight, spotlight
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
kind |
enum: Point, Spot |
Point |
Point: shines all round. Spot: a cone along the node’s rotation. |
color |
color | #ffecc8ff |
Colour of the light. |
energy |
number | 1 |
Brightness multiplier. Range 0 to 8. |
radius |
number | 256 |
Reach of the light (px). Range 1 to 4000. |
falloff |
number | 2 |
Fade towards the edge: 1 linear, 2 smooth, higher = tighter. Range 0.1 to 8. |
spread |
number | 35 |
Spot: half-angle of the cone (degrees). Range 1 to 180. |
shadows |
boolean | true |
Cast shadows from the scene’s physics shapes (bodies, LDtk and tile map colliders; not sensors). |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
LightNode:get_property(path)
Section titled “LightNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("kind")pathLightNodeProperty|string
Returns any
LightNode:set_property(path, value, y)
Section titled “LightNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("kind", "Spot")pathLightNodeProperty|stringvalueanyy?number
LightNode:light_set_color(r, g, b)
Section titled “LightNode:light_set_color(r, g, b)”Sets the light’s colour (0..1).
local lamp = self.node:get_node("Lamp"); lamp:light_set_color(1.0, 0.8, 0.4)rnumbergnumberbnumber
LightNode:light_set_energy(energy)
Section titled “LightNode:light_set_energy(energy)”Sets the light’s energy (brightness multiplier, 0..8).
local lamp = self.node:get_node("Lamp"); lamp:light_set_energy(2.5)energynumber
LightNode:light_get_energy()
Section titled “LightNode:light_get_energy()”Gets the light’s energy (brightness multiplier).
local lamp = self.node:get_node("Lamp"); lamp:light_set_energy(lamp:light_get_energy() * 0.9)Returns number energy
LightNode:light_set_radius(radius)
Section titled “LightNode:light_set_radius(radius)”Sets the light’s radius (world units).
local lamp = self.node:get_node("Lamp"); lamp:light_set_radius(200)radiusnumber
In a scene file
Section titled “In a scene file”{ "type": "LightNode", "name": "Light", "position": [ 0, 0 ], "properties": { "kind": "Point", "color": "#ffecc8ff", "energy": 1 }}