Light2d
class Light2d extends Renderable
A 2D point light. Note: this is a very experimental and work in progress feature, that provides a simple spot light effect. The light effect is best rendered in WebGL, as they are few limitations when using the Canvas Renderer (multiple lights are not supported, alpha component of the ambient light is ignored)
Constructor
new Light2d(x: number, y: number, radiusX: number, radiusY: number, color: Color | string, intensity: number) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
The horizontal position of the light. |
||
y | number |
The vertical position of the light. |
||
radiusX | number |
The horizontal radius of the light. |
||
radiusY | number |
<optional> |
radiusX |
The vertical radius of the light. |
color | Color | string |
<optional> |
"#FFF" |
the color of the light |
intensity | number |
<optional> |
0.7 |
The intensity of the light. |
Summary
Properties from Light2d
string |
|
Color |
|
number |
|
number |
|
number |
|
Methods from Light2d
Ellipse |
|
boolean |
|
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
Body |
|
Matrix2d |
|
number |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
Application |
|
ObservableVector3d |
|
GLShader |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Array<number> |
|
boolean |
|
Polygon |
|
Polygon |
|
|
|
Polygon |
|
Polygon |
|
Polygon |
|
Public Properties
blendMode: string = "lighter"
string
the default blend mode to be applied when rendering this light
Public Methods
getVisibleArea() → {Ellipse}
returns a geometry representing the visible area of this light
Type | Description |
---|---|
Ellipse |
the light visible mask |
update(dt: number) → {boolean}
update function
Name | Type | Description |
---|---|---|
dt | number |
time since the last update in milliseconds. |
Type | Description |
---|---|
boolean |
true if dirty |
Protected Methods
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d) → {}
draw this Light2d (automatically called by melonJS)
Name | Type | Attributes | Description |
---|---|---|---|
renderer | CanvasRenderer | WebGLRenderer |
a renderer instance |
|
viewport | Camera2d |
<optional> |
the viewport to (re)draw |