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
Radius¶
- Set
or
light.setRadius(radius);
light.radius = radius;
- Get
var radius = light.radius;
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');