Skip to content

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

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.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("kind")
  • path LightNodeProperty|string

Returns any

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.” a field of the node’s script.

self.node:set_property("kind", "Spot")
  • path LightNodeProperty|string
  • value any
  • y? number

Sets the light’s colour (0..1).

local lamp = self.node:get_node("Lamp"); lamp:light_set_color(1.0, 0.8, 0.4)
  • r number
  • g number
  • b number

Sets the light’s energy (brightness multiplier, 0..8).

local lamp = self.node:get_node("Lamp"); lamp:light_set_energy(2.5)
  • energy number

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

Sets the light’s radius (world units).

local lamp = self.node:get_node("Lamp"); lamp:light_set_radius(200)
  • radius number
{
"type": "LightNode",
"name": "Light",
"position": [
0,
0
],
"properties": {
"kind": "Point",
"color": "#ffecc8ff",
"energy": 1
}
}