← Back to Docs
  • index.html
  • Clayground
  • Clayground.World
  • Light2d
  • Clayground 2026.8
  • Light2d QML Type

    A coloured point light in world units, rendered by LightLayer2d. More...

    Import Statement: import Clayground.World

    Properties

    Methods

    Detailed Description

    A light is a position, a radius and a colour. It draws nothing itself: every Light2d registers with the module and each LightLayer2d picks up the lights that reach into its viewport.

    Declare it inside the item it belongs to - a torch on a wall, a lantern carried by the player. When target is not set and the parent has xWu and yWu (a PhysicsItem, for example), the light follows the parent. Otherwise it sits at xWu / yWu.

    RectBoxBody {
        id: player
        // ...
        Light2d { radius: 9; color: "#ffc070"; flicker: 0.2 }
    }
    
    Light2d { xWu: 12; yWu: 30; radius: 7; color: "#ff8030"; flicker: 0.6 }

    The light is off when enabled is false - which, as for any Item, also happens when its parent is disabled.

    See also LightLayer2d.

    Property Documentation

    castsShadows : bool

    Whether the layer's occluders block this light.


    color : color

    Light colour. Saturated colours tint what they light.


    flicker : real

    Flicker amount in 0..1; 0 is a steady light.

    Every light gets its own phase (phase), so torches do not pulse in sync.


    intensity : real

    Brightness multiplier; 1 lights the centre to full scene brightness, above 1 overexposes into the light colour.


    lightLayer : LightLayer2d

    Restricts the light to one layer; null (default) means every layer shows it. (Not layer: that is Item's own.)


    offsetXWu : real

    X offset from the followed item, in world units.


    offsetYWu : real

    Y offset from the followed item, in world units.


    phase : real

    Flicker phase offset; randomised per light on creation.


    radius : real

    Distance in world units at which the light has faded to zero.


    target : var

    Optional item to follow; it must expose xWu and yWu.

    When null, the parent is followed if it has xWu and yWu.


    xWu : real

    X position in world units, used when nothing is followed.


    yWu : real

    Y position in world units, used when nothing is followed.


    Method Documentation

    point positionWu()

    The light's current position in world units, following target or the parent when there is one.