Light
Introduction¶
lighting system from normal map.
- Author: Richard Davey
WebGL only
It only works in WebGL render mode.
Usage¶
Light system¶
Enable¶
- Enable
scene.lights.enable();
- Disable
or
scene.lights.disable();
scene.lights.active = false;
Ambient color¶
scene.lights.setAmbientColor(color);
color
: Integer color value.
Light¶
- Add
var light = scene.lights.addLight(x, y, radius); // var light = scene.lights.addLight(x, y, radius, color, intensity);
x
,y
: The horizontal/vertical position of the Light.radius
: The radius of the Light.color
: The integer RGB color of the light. Default is0xffffff
.intensity
: The intensity of the Light.
- Remove
scene.lights.removeLight(light);
Position¶
- Set
or
light.setPosition(x, y);
light.x = x; light.y = y;
- Get
var x = light.x; var y = light.y;
Color¶
- Set
- Red, green, blue
or
light.color.set(red, green, blue);
light.color.r = red; light.color.g = green; light.color.b = blue;
- Integer value
light.setColor(colorInteger);
- Red, green, blue
- Get
- Red, green, blue
var red = light.color.r; var green = light.color.g; var blue = light.color.b;
- Red, green, blue
Size¶
- Set
or
light.setRadius(radius); // light.radius = radius;
light.diameter = diameter; // light.width = diameter; // light.height = diameter; // light.displayWidth = diameter; // light.displayHeight = diameter;
- Get
or
var radius = light.radius;
var diameter = light.diameter; // var diameter = light.displayWidth; // var diameter = light.displayHeight; // var diameter = light.width; // var diameter = light.height;
Intensity¶
- Set
or
light.setIntensity(intensity);
light.intensity = intensity;
- Get
var intensity = light.intensity;
Game object¶
Load texture with normal map¶
scene.load.image(key, [url, normalMapUrl]);
url
: Url of texture.url
: Url of texture.normalMapUrl
: Url of normal map.
Apply light pipeline¶
gameObject.setPipeline('Light2D');