1681-engine / index / LightLayer
Class: LightLayer ​
Defined in: src/light/LightLayer.ts:65
Smooth darkness with lights cut out of it, for art that is not pixel art (the pixel module has its own dithered Darkness). The dark is a screen-sized texture: each light erases a soft hole in it, and lays its colour over what shows through. It sits on the screen layer, over the world and under the HUD you add after it.
const night = new LightLayer(stage, { darkness: 0.9 });
const torch = night.add({ x: 100, y: 80, radius: 90, color: 0xffb060, flicker: 0.08 });
// each frame: torch.x = hero.x; night.update(now);Constructors ​
Constructor ​
new LightLayer(stage, options?): LightLayer;Defined in: src/light/LightLayer.ts:80
Parameters ​
| Parameter | Type |
|---|---|
stage | Stage |
options | LightLayerOptions |
Returns ​
LightLayer
Methods ​
add() ​
add(light): Light;Defined in: src/light/LightLayer.ts:98
Parameters ​
| Parameter | Type |
|---|---|
light | Light |
Returns ​
clear() ​
clear(): void;Defined in: src/light/LightLayer.ts:107
Returns ​
void
destroy() ​
destroy(): void;Defined in: src/light/LightLayer.ts:155
Returns ​
void
remove() ​
remove(light): void;Defined in: src/light/LightLayer.ts:103
Parameters ​
| Parameter | Type |
|---|---|
light | Light |
Returns ​
void
setAmbient() ​
setAmbient(color, darkness): void;Defined in: src/light/LightLayer.ts:112
Changes the dark: its colour and how dark (a day/night cycle eases these).
Parameters ​
| Parameter | Type |
|---|---|
color | number |
darkness | number |
Returns ​
void
update() ​
update(now?): void;Defined in: src/light/LightLayer.ts:118
Redraws the dark with this frame's lights. Call once a frame, after the camera moved.
Parameters ​
| Parameter | Type |
|---|---|
now | number |
Returns ​
void