GameCrom includes a complete 2D lighting system based on masking layers, fully compatible with the Canvas engine and without relying on WebGL. This system allows you to create dynamic darkness effects such as caves, flashlights, torches, or realistic night scenes, all with perfect performance even on mobile browsers.
The system works with two types of objects:
Lights are used to illuminate specific areas of the scene.
color → Light color (default: #ffffaa).radius → Illumination radius in pixels.intensity → Light intensity (0.0 to 1.0).layer → Render layer (combines with object order).active / visible → Allows turning the light ON/OFF.// Example: warm torch light
{
type: "light",
x: 320,
y: 240,
radius: 250,
intensity: 0.8,
color: "#ffb84d",
layer: 20,
active: true,
visible: true
}
This object creates the global darkness layer. Only one can exist per scene, and it covers the entire camera view during gameplay. Lighted areas are cut out dynamically.
color → Darkness color (typically black #000000).opacity → Overall darkness level (0 = no effect, 1 = fully dark).playerLightRadius → Light radius emitted around the player.active / visible → Controls whether darkness is active.darkness object on a very high layer (e.g., layer = 999).playerLightRadius or opacity via script for dynamic effects.