melonjs 19.1.0 → 19.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -15
- package/build/application/application.d.ts +33 -0
- package/build/application/application.d.ts.map +1 -1
- package/build/application/settings.d.ts +1 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +45 -22
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/effects/camera_effect.d.ts +45 -0
- package/build/camera/effects/camera_effect.d.ts.map +1 -0
- package/build/camera/effects/fade_effect.d.ts +60 -0
- package/build/camera/effects/fade_effect.d.ts.map +1 -0
- package/build/camera/effects/mask_effect.d.ts +88 -0
- package/build/camera/effects/mask_effect.d.ts.map +1 -0
- package/build/camera/effects/shake_effect.d.ts +47 -0
- package/build/camera/effects/shake_effect.d.ts.map +1 -0
- package/build/index.d.ts +10 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4283 -1315
- package/build/index.js.map +4 -4
- package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
- package/build/math/color_matrix.d.ts +51 -0
- package/build/math/color_matrix.d.ts.map +1 -0
- package/build/math/matrix2d.d.ts +6 -6
- package/build/math/matrix3d.d.ts +17 -0
- package/build/math/matrix3d.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +19 -5
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +4 -1
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +200 -31
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +5 -2
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/quadtree.d.ts.map +1 -1
- package/build/renderable/container.d.ts +1 -1
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts +13 -2
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/light2d.d.ts +128 -18
- package/build/renderable/light2d.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +54 -35
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +38 -6
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +33 -5
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +27 -1
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +44 -19
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/state/stage.d.ts +65 -9
- package/build/state/stage.d.ts.map +1 -1
- package/build/state/state.d.ts +44 -2
- package/build/state/state.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +9 -0
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/video/buffer/index.d.ts +40 -0
- package/build/video/buffer/index.d.ts.map +1 -0
- package/build/video/{webgl/buffer → buffer}/vertex.d.ts +5 -3
- package/build/video/buffer/vertex.d.ts.map +1 -0
- package/build/video/canvas/canvas_renderer.d.ts +2 -0
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +141 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +27 -0
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/rendertarget/canvasrendertarget.d.ts +26 -63
- package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
- package/build/video/rendertarget/render_target_pool.d.ts +73 -0
- package/build/video/rendertarget/render_target_pool.d.ts.map +1 -0
- package/build/video/rendertarget/rendertarget.d.ts +77 -0
- package/build/video/rendertarget/rendertarget.d.ts.map +1 -0
- package/build/video/rendertarget/webglrendertarget.d.ts +30 -0
- package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -0
- package/build/video/texture/atlas.d.ts +26 -2
- package/build/video/texture/atlas.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +10 -4
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +109 -0
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -0
- package/build/video/webgl/batchers/quad_batcher.d.ts +34 -3
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +5 -34
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/effects/colorMatrix.d.ts +92 -0
- package/build/video/webgl/effects/colorMatrix.d.ts.map +1 -0
- package/build/video/webgl/effects/desaturate.d.ts +2 -4
- package/build/video/webgl/effects/desaturate.d.ts.map +1 -1
- package/build/video/webgl/effects/invert.d.ts +2 -2
- package/build/video/webgl/effects/invert.d.ts.map +1 -1
- package/build/video/webgl/effects/radialGradient.d.ts +105 -0
- package/build/video/webgl/effects/radialGradient.d.ts.map +1 -0
- package/build/video/webgl/effects/sepia.d.ts +2 -2
- package/build/video/webgl/effects/sepia.d.ts.map +1 -1
- package/build/video/webgl/effects/vignette.d.ts +42 -0
- package/build/video/webgl/effects/vignette.d.ts.map +1 -0
- package/build/video/webgl/glshader.d.ts.map +1 -1
- package/build/video/webgl/lighting/constants.d.ts +13 -0
- package/build/video/webgl/lighting/constants.d.ts.map +1 -0
- package/build/video/webgl/lighting/pack.d.ts +76 -0
- package/build/video/webgl/lighting/pack.d.ts.map +1 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts +23 -0
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -0
- package/build/video/webgl/webgl_renderer.d.ts +24 -7
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/build/video/webgl/buffer/vertex.d.ts.map +0 -1
|
@@ -1,18 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* additional import for TypeScript
|
|
3
|
+
* @import {Color} from "./../math/color.ts";
|
|
4
|
+
* @import {Ellipse} from "./../geometries/ellipse.ts";
|
|
5
|
+
* @import Renderer from "./../video/renderer.js";
|
|
6
|
+
*/
|
|
1
7
|
/**
|
|
2
8
|
* A 2D point light.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
9
|
+
*
|
|
10
|
+
* Light2d carries the *properties* of a light (color, radii, intensity,
|
|
11
|
+
* height, flags, position) and asks the active renderer to render it
|
|
12
|
+
* via `renderer.drawLight(this)`. The renderer picks the right machinery:
|
|
13
|
+
*
|
|
14
|
+
* - **WebGL**: a single quad through a shared procedural radial-falloff
|
|
15
|
+
* fragment shader (`RadialGradientEffect`). One shader is reused across
|
|
16
|
+
* every Light2d on the renderer; no per-light texture is allocated.
|
|
17
|
+
* - **Canvas**: a small `Gradient` config object (cached per-light in a
|
|
18
|
+
* `WeakMap` and rebuilt only when radii / color / intensity change),
|
|
19
|
+
* rasterized via `Gradient.toCanvas()` on every draw into a single
|
|
20
|
+
* shared `CanvasRenderTarget`, then composited with `drawImage`. The
|
|
21
|
+
* per-light cache holds only the gradient stops, not the bitmap — the
|
|
22
|
+
* render target is one-per-engine.
|
|
23
|
+
*
|
|
24
|
+
* Light2d itself is renderer-agnostic — no shader knowledge, no canvas
|
|
25
|
+
* allocation, no renderer reference held.
|
|
6
26
|
* @see stage.lights
|
|
7
27
|
*/
|
|
8
28
|
export default class Light2d extends Renderable {
|
|
9
29
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
30
|
+
* Create a 2D point light.
|
|
31
|
+
*
|
|
32
|
+
* A `Light2d` is a first-class world Renderable: add it to a container
|
|
33
|
+
* with `app.world.addChild(light)` (or any sub-container, including a
|
|
34
|
+
* `Sprite`, so the light follows the parent via its transform). On
|
|
35
|
+
* activation, the light auto-registers with the active `Stage`'s
|
|
36
|
+
* lighting set so the ambient overlay (`Stage.ambientLight`) cuts a
|
|
37
|
+
* hole at the light's visible area, and a radial gradient from the
|
|
38
|
+
* given `color` (full intensity at center → fully transparent at the
|
|
39
|
+
* radius) is composited additively on top — producing a soft spot
|
|
40
|
+
* light. Rendering happens inside each `Camera2d`'s post-effect FBO
|
|
41
|
+
* bracket so any camera shader (vignette, color-matrix, scanlines,
|
|
42
|
+
* etc.) wraps the lighting output.
|
|
43
|
+
*
|
|
44
|
+
* Set `radiusY` to a different value than `radiusX` for a stretched
|
|
45
|
+
* (elliptical) light. The `intensity` parameter scales the gradient's
|
|
46
|
+
* inner alpha; the `Stage.ambientLight` color and alpha control how
|
|
47
|
+
* dark the unlit areas are. Use `light.blendMode` to override the
|
|
48
|
+
* default additive blend if needed.
|
|
49
|
+
* @param {number} x - The horizontal position of the light's center (matches `Ellipse(x, y, w, h)` conventions).
|
|
50
|
+
* @param {number} y - The vertical position of the light's center.
|
|
12
51
|
* @param {number} radiusX - The horizontal radius of the light.
|
|
13
52
|
* @param {number} [radiusY=radiusX] - The vertical radius of the light.
|
|
14
|
-
* @param {Color|string} [color="#FFF"] -
|
|
15
|
-
* @param {number} [intensity=0.7] - The
|
|
53
|
+
* @param {Color|string} [color="#FFF"] - The color of the light at full intensity.
|
|
54
|
+
* @param {number} [intensity=0.7] - The peak alpha of the radial gradient at the light's center (0–1).
|
|
16
55
|
*/
|
|
17
56
|
constructor(x: number, y: number, radiusX: number, radiusY?: number, color?: Color | string, intensity?: number);
|
|
18
57
|
/**
|
|
@@ -39,25 +78,98 @@ export default class Light2d extends Renderable {
|
|
|
39
78
|
intensity: number;
|
|
40
79
|
/** @ignore */
|
|
41
80
|
visibleArea: Ellipse;
|
|
42
|
-
/** @ignore */
|
|
43
|
-
texture: CanvasRenderTarget;
|
|
44
81
|
/**
|
|
45
|
-
*
|
|
82
|
+
* When `true`, this light acts as a pure illumination source —
|
|
83
|
+
* the gradient texture isn't drawn. The light still feeds the
|
|
84
|
+
* `Stage` ambient-cutout pass and the WebGL lit-sprite
|
|
85
|
+
* pipeline's per-frame uniforms, so normal-mapped sprites still
|
|
86
|
+
* get shaded by it. Use this for SpriteIlluminator-style demos
|
|
87
|
+
* where the light should be invisible (only its effect on
|
|
88
|
+
* normal-mapped surfaces is what you want to see).
|
|
89
|
+
*
|
|
90
|
+
* Default `false`, preserving the legacy "soft glowing spot"
|
|
91
|
+
* behavior.
|
|
92
|
+
* @type {boolean}
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
illuminationOnly: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Light height above the sprite plane (Z axis), in the same
|
|
98
|
+
* units as `radiusX`/`radiusY`. Used by the WebGL lit-sprite
|
|
99
|
+
* pipeline as the Z component of the light direction in the
|
|
100
|
+
* `dot(normal, lightDir)` calculation: a low height makes the
|
|
101
|
+
* lighting graze across the surface (long visible shadows on
|
|
102
|
+
* normal-map detail), a high height makes it head-on (more
|
|
103
|
+
* uniform brightness on the lit hemisphere).
|
|
104
|
+
*
|
|
105
|
+
* Default is `max(radiusX, radiusY) * 0.075` — a balanced look
|
|
106
|
+
* at the asset's native scale that prevents lights at the
|
|
107
|
+
* sprite's center from producing degenerate flat shading.
|
|
108
|
+
*
|
|
109
|
+
* Named `lightHeight` (not just `height`) to avoid colliding
|
|
110
|
+
* with the bbox-height getter Light2d inherits from `Rect`.
|
|
111
|
+
* @type {number}
|
|
112
|
+
*/
|
|
113
|
+
lightHeight: number;
|
|
114
|
+
/**
|
|
115
|
+
* Set new radii for this light.
|
|
116
|
+
*
|
|
117
|
+
* Updates `radiusX`/`radiusY` and the underlying bbox (via
|
|
118
|
+
* `Renderable.resize(width, height)`) so `getBounds()` and
|
|
119
|
+
* `getVisibleArea()` — which feed the ambient-cutout pass — track the
|
|
120
|
+
* new size. The Canvas renderer's gradient cache auto-invalidates on
|
|
121
|
+
* next draw via its property comparison; the WebGL procedural shader
|
|
122
|
+
* adapts to the new dimensions automatically.
|
|
123
|
+
*
|
|
124
|
+
* Named `setRadii` (not `resize`) so it does not shadow
|
|
125
|
+
* `Renderable.resize(width, height)` — code that operates on a
|
|
126
|
+
* generic `Renderable` and calls `.resize(w, h)` keeps working when
|
|
127
|
+
* the instance happens to be a `Light2d`.
|
|
128
|
+
* @param {number} radiusX - new horizontal radius
|
|
129
|
+
* @param {number} [radiusY=radiusX] - new vertical radius
|
|
130
|
+
*/
|
|
131
|
+
setRadii(radiusX: number, radiusY?: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* returns a geometry representing the visible area of this light, in
|
|
134
|
+
* world-space coordinates (so it aligns with the rendered gradient
|
|
135
|
+
* regardless of camera scroll or container parenting).
|
|
46
136
|
* @returns {Ellipse} the light visible mask
|
|
47
137
|
*/
|
|
48
138
|
getVisibleArea(): Ellipse;
|
|
49
139
|
/**
|
|
50
140
|
* update function
|
|
51
|
-
* @param {number} dt - time since the last update in milliseconds.
|
|
52
141
|
* @returns {boolean} true if dirty
|
|
53
142
|
*/
|
|
54
143
|
update(): boolean;
|
|
55
144
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param {
|
|
58
|
-
|
|
145
|
+
* preDraw this Light2d (automatically called by melonJS)
|
|
146
|
+
* @param {Renderer} renderer - a renderer instance
|
|
147
|
+
*/
|
|
148
|
+
preDraw(renderer: Renderer): void;
|
|
149
|
+
/**
|
|
150
|
+
* draw this Light2d (automatically called by melonJS).
|
|
151
|
+
*
|
|
152
|
+
* Delegates to `renderer.drawLight(this)` — each renderer picks its
|
|
153
|
+
* own implementation (procedural shader on WebGL; cached `Gradient`
|
|
154
|
+
* rasterized into a shared `CanvasRenderTarget` on Canvas). Light2d
|
|
155
|
+
* itself doesn't know which path is used.
|
|
156
|
+
* @param {Renderer} renderer - a renderer instance
|
|
157
|
+
*/
|
|
158
|
+
draw(renderer: Renderer): void;
|
|
159
|
+
/**
|
|
160
|
+
* Auto-register this light with the active Stage's lighting set when
|
|
161
|
+
* added to a container. The Stage uses that set to build the ambient
|
|
162
|
+
* overlay cutouts; rendering the light itself is handled normally as
|
|
163
|
+
* part of the world tree walk.
|
|
164
|
+
* @ignore
|
|
165
|
+
*/
|
|
166
|
+
onActivateEvent(): void;
|
|
167
|
+
/**
|
|
168
|
+
* Auto-deregister this light from the active Stage's lighting set when
|
|
169
|
+
* removed from a container.
|
|
170
|
+
* @ignore
|
|
59
171
|
*/
|
|
60
|
-
|
|
172
|
+
onDeactivateEvent(): void;
|
|
61
173
|
/**
|
|
62
174
|
* Destroy function<br>
|
|
63
175
|
* @ignore
|
|
@@ -67,7 +179,5 @@ export default class Light2d extends Renderable {
|
|
|
67
179
|
import Renderable from "./renderable.js";
|
|
68
180
|
import type { Color } from "./../math/color.ts";
|
|
69
181
|
import type { Ellipse } from "./../geometries/ellipse.ts";
|
|
70
|
-
import
|
|
71
|
-
import type CanvasRenderer from "./../video/canvas/canvas_renderer.js";
|
|
72
|
-
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
182
|
+
import type Renderer from "./../video/renderer.js";
|
|
73
183
|
//# sourceMappingURL=light2d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light2d.d.ts","sourceRoot":"","sources":["../../src/renderable/light2d.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"light2d.d.ts","sourceRoot":"","sources":["../../src/renderable/light2d.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,eAPW,MAAM,KACN,MAAM,WACN,MAAM,YACN,MAAM,UACN,KAAK,GAAC,MAAM,cACZ,MAAM,EAiGhB;IAlFA;;;;OAIG;IACH,OAHU,KAAK,CAG6B;IAE5C;;;OAGG;IACH,SAFU,MAAM,CAEM;IAEtB;;;OAGG;IACH,SAFU,MAAM,CAEM;IAEtB;;;;OAIG;IACH,WAHU,MAAM,CAGU;IAa1B,cAAc;IACd,qBAKC;IAKD;;;;;;;;;;;;;OAaG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;;;;;;;;;;;;;OAgBG;IACH,aAFU,MAAM,CAEqC;IAiCtD;;;;;;;;;;;;;;;;OAgBG;IACH,kBAHW,MAAM,YACN,MAAM,QAMhB;IAED;;;;;OAKG;IACH,kBAFa,OAAO,CAOnB;IAED;;;OAGG;IACH,UAFa,OAAO,CAInB;IAED;;;OAGG;IACH,kBAFW,QAAQ,QAKlB;IAED;;;;;;;;OAQG;IACH,eAFW,QAAQ,QAOlB;IAED;;;;;;OAMG;IACH,wBAKC;IAED;;;;OAIG;IACH,0BAKC;IAED;;;OAGG;IACH,gBAQC;CACD;uBArSsB,iBAAiB;2BAIhB,oBAAoB;6BAClB,4BAA4B;0BAC7B,wBAAwB"}
|
|
@@ -185,45 +185,26 @@ export default class Renderable extends Rect {
|
|
|
185
185
|
*/
|
|
186
186
|
mask: Rect | RoundRect | Polygon | Line | Ellipse;
|
|
187
187
|
/**
|
|
188
|
-
*
|
|
189
|
-
* Use {@link
|
|
190
|
-
*
|
|
191
|
-
* - {@link FlashEffect} — flash the sprite with a solid color (hit feedback)
|
|
192
|
-
* - {@link OutlineEffect} — colored outline around the sprite (selection, hover)
|
|
193
|
-
* - {@link GlowEffect} — soft colored glow around the sprite (power-ups, magic)
|
|
194
|
-
* - {@link DesaturateEffect} — partial or full grayscale (disabled, death)
|
|
195
|
-
* - {@link PixelateEffect} — progressive pixelation (teleport, retro)
|
|
196
|
-
* - {@link BlurEffect} — box blur (defocus, backdrop)
|
|
197
|
-
* - {@link ChromaticAberrationEffect} — RGB channel offset (impact, glitch)
|
|
198
|
-
* - {@link DissolveEffect} — noise-based dissolve (death, spawn)
|
|
199
|
-
* - {@link DropShadowEffect} — offset shadow beneath the sprite
|
|
200
|
-
* - {@link ScanlineEffect} — horizontal scanlines with optional CRT curvature and vignette
|
|
201
|
-
* - {@link TintPulseEffect} — pulsing color overlay (poison, freeze, fire)
|
|
202
|
-
* - {@link WaveEffect} — sine wave distortion (underwater, heat haze)
|
|
203
|
-
* - {@link InvertEffect} — color inversion (negative image, X-ray)
|
|
204
|
-
* - {@link SepiaEffect} — warm vintage photo tone
|
|
205
|
-
* - {@link HologramEffect} — flickering holographic projection (sci-fi)
|
|
206
|
-
*
|
|
207
|
-
* Use {@link GLShader} for full control over vertex and fragment shaders.
|
|
188
|
+
* the list of post-processing shader effects applied to this renderable (WebGL only).
|
|
189
|
+
* Effects are applied in order. Use {@link addPostEffect}, {@link getPostEffect},
|
|
190
|
+
* and {@link removePostEffect} to manage effects, or assign directly.
|
|
208
191
|
* In Canvas mode, this property is ignored.
|
|
209
|
-
* @type {GLShader|ShaderEffect}
|
|
210
|
-
* @default
|
|
211
|
-
* @example
|
|
212
|
-
* // apply a built-in effect
|
|
213
|
-
* mySprite.shader = new FlashEffect(renderer, { intensity: 1.0 });
|
|
192
|
+
* @type {Array<GLShader|ShaderEffect>}
|
|
193
|
+
* @default []
|
|
214
194
|
* @example
|
|
215
|
-
* //
|
|
216
|
-
* mySprite.
|
|
217
|
-
*
|
|
218
|
-
* float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
|
219
|
-
* return vec4(vec3(gray), color.a);
|
|
220
|
-
* }
|
|
221
|
-
* `);
|
|
195
|
+
* // add effects via helper methods
|
|
196
|
+
* mySprite.addPostEffect(new DesaturateEffect(renderer));
|
|
197
|
+
* mySprite.addPostEffect(new VignetteEffect(renderer));
|
|
222
198
|
* @example
|
|
223
|
-
* //
|
|
224
|
-
* mySprite.
|
|
199
|
+
* // assign directly
|
|
200
|
+
* mySprite.postEffects = [new SepiaEffect(renderer), new VignetteEffect(renderer)];
|
|
225
201
|
*/
|
|
226
|
-
|
|
202
|
+
postEffects: Array<GLShader | ShaderEffect>;
|
|
203
|
+
/**
|
|
204
|
+
* whether this renderable manages its own FBO lifecycle (e.g. Camera2d)
|
|
205
|
+
* @ignore
|
|
206
|
+
*/
|
|
207
|
+
_postEffectManaged: boolean;
|
|
227
208
|
/**
|
|
228
209
|
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
229
210
|
* @type {string}
|
|
@@ -313,6 +294,44 @@ export default class Renderable extends Rect {
|
|
|
313
294
|
* @default false
|
|
314
295
|
*/
|
|
315
296
|
get inViewport(): boolean;
|
|
297
|
+
set shader(value: GLShader | ShaderEffect | undefined);
|
|
298
|
+
/**
|
|
299
|
+
* @deprecated since 19.2.0 — use {@link addPostEffect} / {@link getPostEffect} / {@link removePostEffect} instead
|
|
300
|
+
* @type {GLShader|ShaderEffect|undefined}
|
|
301
|
+
*/
|
|
302
|
+
get shader(): GLShader | ShaderEffect | undefined;
|
|
303
|
+
/**
|
|
304
|
+
* Add a post-processing shader effect to this renderable.
|
|
305
|
+
* @param {GLShader|ShaderEffect} effect - the effect to add
|
|
306
|
+
* @returns {GLShader|ShaderEffect} the added effect
|
|
307
|
+
* @example
|
|
308
|
+
* mySprite.addPostEffect(new DesaturateEffect(renderer));
|
|
309
|
+
*/
|
|
310
|
+
addPostEffect(effect: GLShader | ShaderEffect): GLShader | ShaderEffect;
|
|
311
|
+
/**
|
|
312
|
+
* Get post-processing shader effects.
|
|
313
|
+
* When called with a class, returns the first effect matching the given class.
|
|
314
|
+
* When called without arguments, returns the full effects array.
|
|
315
|
+
* @param {Function} [effectClass] - the effect class to search for
|
|
316
|
+
* @returns {GLShader|ShaderEffect|Array|undefined} the matching effect, the effects array, or undefined
|
|
317
|
+
* @example
|
|
318
|
+
* const desat = sprite.getPostEffect(DesaturateEffect);
|
|
319
|
+
* const allEffects = sprite.getPostEffect();
|
|
320
|
+
*/
|
|
321
|
+
getPostEffect(effectClass?: Function): GLShader | ShaderEffect | any[] | undefined;
|
|
322
|
+
/**
|
|
323
|
+
* Remove all post-processing shader effects.
|
|
324
|
+
* @example
|
|
325
|
+
* sprite.clearPostEffects();
|
|
326
|
+
*/
|
|
327
|
+
clearPostEffects(): void;
|
|
328
|
+
/**
|
|
329
|
+
* Remove a specific post-processing shader effect.
|
|
330
|
+
* @param {GLShader|ShaderEffect} effect - the effect to remove
|
|
331
|
+
* @example
|
|
332
|
+
* sprite.removePostEffect(effect);
|
|
333
|
+
*/
|
|
334
|
+
removePostEffect(effect: GLShader | ShaderEffect): void;
|
|
316
335
|
/**
|
|
317
336
|
* returns true if this renderable is flipped on the horizontal axis
|
|
318
337
|
* @public
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;OAUG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,MAlCU,IAAI,CAkCO;IAErB;;;;;OAKG;IACH,MAFU,MAAM,CAEK;IAErB;;;;;;;;;;OAUG;IACH,6BAAmC;IAEnC;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;OAIG;IACH,kBAHU,OAAO,CAGY;IAE7B;;;;OAIG;IACH,cAHU,OAAO,CAGQ;IAEzB;;;;;OAKG;IACH,UAHU,OAAO,CAGI;IAErB;;;;;;;OAOG;IACH,qBAHU,OAAO,CAGe;IAEhC;;;;;;;;;;;;;;;;OAgBG;IACH,eAdU,OAAO,CAcQ;IAEzB;;;;;;;OAOG;IACH,OAHU,MAAM,CAGA;IAEhB;;;;OAIG;IACH,UAHU,SAAS,GAAC,MAAM,CAGD;IAEzB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAlBU,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,CAkBxB;IAErB
|
|
1
|
+
{"version":3,"file":"renderable.d.ts","sourceRoot":"","sources":["../../src/renderable/renderable.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;IAaI;AAEJ;;;GAGG;AACH;IAkBG,iBAAmB;IAGpB;;;;;;;;;;OAUG;IACH,aAHU,eAAe,CAMvB;IAGD;;;;;;;OAOG;IACH,kBAFU,QAAQ,CAEoB;IAIvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,MAlCU,IAAI,CAkCO;IAErB;;;;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O,CAKnB;IAED;;;;OAIG;IACH,wBAHW,OAAO,GACL,MAAM,CAwClB;IAED;;;OAGG;IACH,uBAFa,QAAQ,CAYpB;IAED;;;;;;OAMG;IACH,kBAFW,cAAc,GAAC,aAAa,QAoDtC;IAED;;;;;;;;;;;;OAYG;IAEH,eAJW,cAAc,GAAC,aAAa,aAC5B,QAAQ,QAKlB;IAED;;;;;OAKG;IACH,mBAFW,cAAc,GAAC,aAAa,QAqBtC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAfa,OAAO,CAiBnB;IAED;;;OAGG;IACH,8BA2DC;IAED;;;OAGG;IACH,uBAEC;CACD;qBAr9BoB,8BAA8B;gCADnB,kCAAkC;yBAKzC,qBAAqB;iBAG7B,sBAAsB;2BAQb,gBAAgB;wBADnB,oBAAoB;+BAKf,8BAA8B;6BADhC,0BAA0B;0BAF7B,yBAAyB;6BACtB,4BAA4B;6BAG1B,iCAAiC;gCAC9B,sCAAsC;+BACvC,oCAAoC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* additional import for TypeScript
|
|
3
3
|
* @import {Vector2d} from "../math/vector2d.js";
|
|
4
|
-
* @import
|
|
5
|
-
* @import WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
4
|
+
* @import Renderer from "./../video/renderer.js";
|
|
6
5
|
*/
|
|
7
6
|
/**
|
|
8
7
|
* An object to display a fixed or animated sprite on screen.
|
|
@@ -22,6 +21,7 @@ export default class Sprite extends Renderable {
|
|
|
22
21
|
* @param {number} [settings.flipX] - flip the sprite on the horizontal axis
|
|
23
22
|
* @param {number} [settings.flipY] - flip the sprite on the vertical axis
|
|
24
23
|
* @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] - Anchor point to draw the frame at (defaults to the center of the frame).
|
|
24
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|string} [settings.normalMap] - optional normal-map texture used for per-pixel lighting (SpriteIlluminator-style). Same layout/UVs as `settings.image`. When omitted (default), the sprite renders unlit and pays no extra cost. Ignored by the Canvas renderer. Note: `HTMLVideoElement` is intentionally not supported — normal maps encode static surface directions in RGB, and the engine caches the GL texture per image reference (a video would freeze on frame 0).
|
|
25
25
|
* @example
|
|
26
26
|
* // create a single sprite from a standalone image, with anchor in the center
|
|
27
27
|
* let sprite = new me.Sprite(0, 0, {
|
|
@@ -61,6 +61,7 @@ export default class Sprite extends Renderable {
|
|
|
61
61
|
flipX?: number | undefined;
|
|
62
62
|
flipY?: number | undefined;
|
|
63
63
|
anchorPoint?: Vector2d | undefined;
|
|
64
|
+
normalMap?: string | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | undefined;
|
|
64
65
|
});
|
|
65
66
|
/**
|
|
66
67
|
* @type {boolean}
|
|
@@ -95,6 +96,12 @@ export default class Sprite extends Renderable {
|
|
|
95
96
|
* @type {TextureAtlas}
|
|
96
97
|
*/
|
|
97
98
|
source: TextureAtlas;
|
|
99
|
+
/**
|
|
100
|
+
* backing field for the `normalMap` accessor — see the getter/setter
|
|
101
|
+
* defined on the class for the public API and validation rules.
|
|
102
|
+
* @ignore
|
|
103
|
+
*/
|
|
104
|
+
_normalMap: ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | null;
|
|
98
105
|
anim: {};
|
|
99
106
|
resetAnim: Function | (() => Sprite) | undefined;
|
|
100
107
|
current: {
|
|
@@ -127,6 +134,19 @@ export default class Sprite extends Renderable {
|
|
|
127
134
|
* @ignore
|
|
128
135
|
*/
|
|
129
136
|
removeStatePauseListener: (() => void) | undefined;
|
|
137
|
+
set normalMap(value: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null);
|
|
138
|
+
/**
|
|
139
|
+
* The optional normal-map image paired with this sprite's color
|
|
140
|
+
* texture (SpriteIlluminator workflow). When set, the WebGL
|
|
141
|
+
* renderer's lit pipeline samples this texture for per-pixel
|
|
142
|
+
* lighting using `Stage._activeLights`. `null` when unlit.
|
|
143
|
+
* Setting any non-image value (or anything without numeric
|
|
144
|
+
* `width`/`height`) throws — assign `null` to clear.
|
|
145
|
+
*
|
|
146
|
+
* Silently ignored by the Canvas renderer.
|
|
147
|
+
* @type {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas|ImageBitmap|null}
|
|
148
|
+
*/
|
|
149
|
+
get normalMap(): HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | null;
|
|
130
150
|
atlasIndices: any;
|
|
131
151
|
/**
|
|
132
152
|
* return the flickering state of the object
|
|
@@ -271,12 +291,25 @@ export default class Sprite extends Renderable {
|
|
|
271
291
|
* @returns {number} if using number indices. Returns {object} containing frame data if using texture atlas
|
|
272
292
|
*/
|
|
273
293
|
getAnimationFrameObjectByIndex(id: number): number;
|
|
294
|
+
/**
|
|
295
|
+
* Prepare the rendering context before drawing this sprite (automatically called by melonJS).
|
|
296
|
+
* Extends `Renderable.preDraw` to publish this sprite's `normalMap` (if any)
|
|
297
|
+
* on the renderer so the WebGL lit pipeline can pair it with the next
|
|
298
|
+
* `drawImage` call. Cleared back in `postDraw`.
|
|
299
|
+
* @param {Renderer} renderer - a renderer instance
|
|
300
|
+
*/
|
|
301
|
+
preDraw(renderer: Renderer): void;
|
|
302
|
+
/**
|
|
303
|
+
* restore the rendering context after drawing this sprite (automatically called by melonJS).
|
|
304
|
+
* @param {Renderer} renderer - a renderer instance
|
|
305
|
+
*/
|
|
306
|
+
postDraw(renderer: Renderer): void;
|
|
274
307
|
/**
|
|
275
308
|
* draw this sprite (automatically called by melonJS)
|
|
276
|
-
* @param {
|
|
309
|
+
* @param {Renderer} renderer - a renderer instance
|
|
277
310
|
* @param {Camera2d} [viewport] - the viewport to (re)draw
|
|
278
311
|
*/
|
|
279
|
-
draw(renderer:
|
|
312
|
+
draw(renderer: Renderer): void;
|
|
280
313
|
/**
|
|
281
314
|
* Destroy function<br>
|
|
282
315
|
* @ignore
|
|
@@ -286,7 +319,6 @@ export default class Sprite extends Renderable {
|
|
|
286
319
|
import Renderable from "./renderable.js";
|
|
287
320
|
import type { Vector2d } from "../math/vector2d.js";
|
|
288
321
|
import { TextureAtlas } from "./../video/texture/atlas.js";
|
|
289
|
-
import type
|
|
290
|
-
import type WebGLRenderer from "./../video/webgl/webgl_renderer.js";
|
|
322
|
+
import type Renderer from "./../video/renderer.js";
|
|
291
323
|
import { Color } from "../math/color.ts";
|
|
292
324
|
//# sourceMappingURL=sprite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAWA
|
|
1
|
+
{"version":3,"file":"sprite.d.ts","sourceRoot":"","sources":["../../src/renderable/sprite.js"],"names":[],"mappings":"AAWA;;;;GAIG;AAEH;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,eA1CW,MAAM,KACN,MAAM,YAEd;QAA0G,KAAK,EAAvG,gBAAgB,GAAC,iBAAiB,GAAC,gBAAgB,GAAC,YAAY,GAAC,eAAe,GAAC,MAAM;QACrE,IAAI;QACJ,MAAM;QACN,UAAU;QACV,WAAW;QACL,IAAI;QACV,KAAK;QACL,KAAK;QACH,WAAW;QACkD,SAAS;KAClG,EA6SF;IA5QA;;;OAGG;IACH,gBAHU,OAAO,CAGU;IAE3B;;;;OAIG;IACH,gBAHU,MAAM,CAGS;IAEzB;;;;OAIG;IACH,QAHU,QAAQ,CAGkB;IAEpC;;;;OAIG;IACH,SAHU,OAAO,CAGG;IAEpB;;;;OAIG;IAGH;;;OAGG;IACH,QAFU,YAAY,CAEJ;IAElB;;;;OAIG;IACH,wFAAsB;IAGtB,SAAc;IAGd,iDAA0B;IAI1B;;;;;;;;;MAgBC;IAGD,WAAW;IAEX;;;OAGG;IACH;;;;;MAKC;IAKA,WAAqC;IACrC,kBAAkC;IAiCjC,WAG8C;IAC9C,YAGgD;IAO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apText extends Renderable {
|
|
|
19
19
|
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
|
|
20
20
|
* @param {(string|string[])} [settings.text] - a string, or an array of strings
|
|
21
21
|
* @example
|
|
22
|
-
* // Use
|
|
23
|
-
*
|
|
24
|
-
* { name: "arial", type: "binary" src: "data/font/arial.fnt" },
|
|
25
|
-
* { name: "arial", type: "image" src: "data/font/arial.png" },
|
|
22
|
+
* // Use loader.preload or loader.load to load assets
|
|
23
|
+
* loader.preload([
|
|
24
|
+
* { name: "arial", type: "binary", src: "data/font/arial.fnt" },
|
|
25
|
+
* { name: "arial", type: "image", src: "data/font/arial.png" },
|
|
26
26
|
* ])
|
|
27
27
|
* // Then create an instance of your bitmap font:
|
|
28
|
-
* let myFont = new
|
|
28
|
+
* let myFont = new BitmapText(x, y, {font:"arial", text:"Hello"});
|
|
29
29
|
* // two possibilities for using "myFont"
|
|
30
30
|
* // either call the draw function from your Renderable draw function
|
|
31
31
|
* myFont.draw(renderer, "Hello!", 0, 0);
|
|
@@ -105,6 +105,10 @@ export default class BitmapText extends Renderable {
|
|
|
105
105
|
* @see Renderable#tint
|
|
106
106
|
*/
|
|
107
107
|
public get fillStyle(): Color;
|
|
108
|
+
/**
|
|
109
|
+
* @ignore
|
|
110
|
+
*/
|
|
111
|
+
_visibleCharacters: number;
|
|
108
112
|
metrics: TextMetrics;
|
|
109
113
|
/**
|
|
110
114
|
* change the font settings
|
|
@@ -119,6 +123,30 @@ export default class BitmapText extends Renderable {
|
|
|
119
123
|
* @returns {BitmapText} this object for chaining
|
|
120
124
|
*/
|
|
121
125
|
setText(value?: number | string | string[]): BitmapText;
|
|
126
|
+
public set visibleCharacters(value: number);
|
|
127
|
+
/**
|
|
128
|
+
* the number of characters to display (use -1 to show all).
|
|
129
|
+
* Useful for typewriter effects combined with Tween.
|
|
130
|
+
* @public
|
|
131
|
+
* @type {number}
|
|
132
|
+
* @default -1
|
|
133
|
+
* @see BitmapText#visibleRatio
|
|
134
|
+
* @example
|
|
135
|
+
* // show only the first 5 characters
|
|
136
|
+
* bitmapText.visibleCharacters = 5;
|
|
137
|
+
* // typewriter effect
|
|
138
|
+
* bitmapText.visibleCharacters = 0;
|
|
139
|
+
* new Tween(bitmapText).to({ visibleRatio: 1.0 }, { duration: 2000 }).start();
|
|
140
|
+
*/
|
|
141
|
+
public get visibleCharacters(): number;
|
|
142
|
+
public set visibleRatio(value: number);
|
|
143
|
+
/**
|
|
144
|
+
* the ratio of visible characters (0.0 to 1.0).
|
|
145
|
+
* Setting this automatically updates {@link visibleCharacters}.
|
|
146
|
+
* @public
|
|
147
|
+
* @type {number}
|
|
148
|
+
*/
|
|
149
|
+
public get visibleRatio(): number;
|
|
122
150
|
/**
|
|
123
151
|
* change the font display size
|
|
124
152
|
* @param {number} scale - ratio
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,eA5BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,
|
|
1
|
+
{"version":3,"file":"bitmaptext.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/bitmaptext.js"],"names":[],"mappings":"AAOA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,eA5BW,MAAM,KACN,MAAM,YAEd;QAA+B,IAAI,EAA3B,MAAM,8DAAM;QACM,QAAQ;QACR,IAAI;QACE,SAAS;QACf,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EA2HF;IAzGA;;;;;;OAMG;IACH,kBAHU,MAAM,CAG6B;IAE7C;;;;;;OAMG;IACH,qBAHU,MAAM,CAGkC;IAElD;;;;;;OAMG;IACH,mBAHU,MAAM,CAG4B;IAE5C;;;;;;OAMG;IACH,sBAHU,MAAM,CAGiC;IAEjD;;;OAGG;IACH,cAAe;IAEf;;;OAGG;IACH,kBAA2C;IAE3C;;;OAGG;IACH,kBAG2B;IAG1B;;;OAGG;IAEH,iBAAgE;IA0MlE,4BANU,KAAK,EAad;IAhBD;;;;;OAKG;IACH,wBAHU,KAAK,CAKd;IA9KA;;OAEG;IACH,2BAA4B;IAG5B,qBAAoC;IAWrC;;;;;OAKG;IACH,eAJW,MAAM,UACN,MAAM,GACJ,UAAU,CAWtB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,UAAU,CAqBtB;IAoBD,oCAdU,MAAM,EAmBf;IAvBD;;;;;;;;;;;;;OAaG;IACH,gCAVU,MAAM,CAYf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAqFD;;;;OAIG;IACH,cAHW,MAAM,GACJ,UAAU,CAYtB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,WAAW,CAIvB;IAED;;;OAGG;IACH,eAFW,cAAc,GAAC,aAAa,QAmGtC;IAED;;;OAGG;IACH,gBAQC;CACD;uBA1csB,kBAAkB;sBAFnB,qBAAqB;wBAInB,kBAAkB"}
|
|
@@ -19,7 +19,7 @@ export default class Text extends Renderable {
|
|
|
19
19
|
* @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
|
|
20
20
|
* @param {(string|string[])} [settings.text=""] - a string, or an array of strings
|
|
21
21
|
* @example
|
|
22
|
-
* let font = new
|
|
22
|
+
* let font = new Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
|
|
23
23
|
*/
|
|
24
24
|
constructor(x: number, y: number, settings: {
|
|
25
25
|
font: string;
|
|
@@ -94,6 +94,10 @@ export default class Text extends Renderable {
|
|
|
94
94
|
/** @ignore */
|
|
95
95
|
onResetEvent(x: any, y: any, settings: any): void;
|
|
96
96
|
canvasTexture: CanvasRenderTarget | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* @ignore
|
|
99
|
+
*/
|
|
100
|
+
_visibleCharacters: any;
|
|
97
101
|
metrics: TextMetrics | undefined;
|
|
98
102
|
/**
|
|
99
103
|
* make the font bold
|
|
@@ -122,6 +126,28 @@ export default class Text extends Renderable {
|
|
|
122
126
|
* @returns {Text} this object for chaining
|
|
123
127
|
*/
|
|
124
128
|
setText(value?: number | string | string[]): Text;
|
|
129
|
+
public set visibleCharacters(value: number);
|
|
130
|
+
/**
|
|
131
|
+
* the number of characters to display (use -1 to show all).
|
|
132
|
+
* Useful for typewriter effects combined with Tween.
|
|
133
|
+
* @public
|
|
134
|
+
* @type {number}
|
|
135
|
+
* @default -1
|
|
136
|
+
* @see Text#visibleRatio
|
|
137
|
+
* @example
|
|
138
|
+
* // typewriter effect
|
|
139
|
+
* text.visibleCharacters = 0;
|
|
140
|
+
* new Tween(text).to({ visibleRatio: 1.0 }, { duration: 2000 }).start();
|
|
141
|
+
*/
|
|
142
|
+
public get visibleCharacters(): number;
|
|
143
|
+
public set visibleRatio(value: number);
|
|
144
|
+
/**
|
|
145
|
+
* the ratio of visible characters (0.0 to 1.0).
|
|
146
|
+
* Setting this automatically updates {@link visibleCharacters}.
|
|
147
|
+
* @public
|
|
148
|
+
* @type {number}
|
|
149
|
+
*/
|
|
150
|
+
public get visibleRatio(): number;
|
|
125
151
|
/**
|
|
126
152
|
* measure the given text size in pixels
|
|
127
153
|
* @param {string} [text] - the text to be measured
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;OAiBG;IACH,eAjBW,MAAM,KACN,MAAM,YAEd;QAAyB,IAAI,EAArB,MAAM;QACkB,IAAI,EAA5B,MAAM,GAAC,MAAM;QACW,SAAS;QACT,WAAW;QACjB,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EA2EF;IApEA;;;;OAIG;IACH,WAHU,KAAK,CAGwB;IAEvC;;;;OAIG;IACH,aAHU,KAAK,CAG0B;IAEzC;;;;OAIG;IACH,WAHU,MAAM,CAGE;IAElB;;;;;OAKG;IACH,WAHU,MAAM,CAGO;IAEvB;;;;;OAKG;IACH,cAHU,MAAM,CAGS;IAEzB;;;;;OAKG;IACH,YAHU,MAAM,CAGK;IAErB;;;;;OAKG;IACH,eAHU,MAAM,CAGO;IAEvB;;;;OAIG;IACH,UAHU,MAAM,CAGE;IAElB;;;OAGG;IACH,cAAe;IAMhB,cAAc;IACd,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/renderable/text/text.js"],"names":[],"mappings":"AAmBA;;;GAGG;AACH;IACC;;;;;;;;;;;;;;;;;OAiBG;IACH,eAjBW,MAAM,KACN,MAAM,YAEd;QAAyB,IAAI,EAArB,MAAM;QACkB,IAAI,EAA5B,MAAM,GAAC,MAAM;QACW,SAAS;QACT,WAAW;QACjB,SAAS;QACT,SAAS;QACT,YAAY;QACZ,UAAU;QACR,WAAW;QACb,aAAa;QACF,IAAI;KACzC,EA2EF;IApEA;;;;OAIG;IACH,WAHU,KAAK,CAGwB;IAEvC;;;;OAIG;IACH,aAHU,KAAK,CAG0B;IAEzC;;;;OAIG;IACH,WAHU,MAAM,CAGE;IAElB;;;;;OAKG;IACH,WAHU,MAAM,CAGO;IAEvB;;;;;OAKG;IACH,cAHU,MAAM,CAGS;IAEzB;;;;;OAKG;IACH,YAHU,MAAM,CAGK;IAErB;;;;;OAKG;IACH,eAHU,MAAM,CAGO;IAEvB;;;;OAIG;IACH,UAHU,MAAM,CAGE;IAElB;;;OAGG;IACH,cAAe;IAMhB,cAAc;IACd,kDA0EC;IAdA,8CAEE;IAEF;;OAEG;IACH,wBAA4B;IAG5B,iCAAoC;IAMrC;;;OAGG;IACH,QAFa,IAAI,CAWhB;IAJC,UAA+B;IAMjC;;;OAGG;IACH,UAFa,IAAI,CAWhB;IAED;;;;;;;;OAQG;IACH,cAPW,MAAM,SACN,MAAM,GAAC,MAAM,GACX,IAAI,CAiChB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GAAC,MAAM,GAAC,MAAM,EAAE,GACpB,IAAI,CAyDhB;IAkBD,oCAZU,MAAM,EAiBf;IArBD;;;;;;;;;;;OAWG;IACH,gCARU,MAAM,CAUf;IAyBD,+BAZU,MAAM,EAsBf;IA1BD;;;;;OAKG;IACH,2BAFU,MAAM,CAUf;IAiED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,WAAW,CAIvB;IAED;;;OAGG;IACH,eAFW,cAAc,GAAC,aAAa,QA2BtC;IAED;;OAEG;IACH,4EA6BC;IAED;;;OAGG;IACH,gBAUC;CACD;uBA/fsB,kBAAkB;sBAHR,qBAAqB;+BAEvB,gDAAgD;wBAEvD,kBAAkB"}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @import ResponseObject from "./../physics/response.js";
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Trigger an event when colliding with another object.
|
|
7
|
+
* Supports both fade and mask-based transitions when loading a new level.
|
|
7
8
|
* @category Game Objects
|
|
8
9
|
*/
|
|
9
10
|
export default class Trigger extends Renderable {
|
|
@@ -14,8 +15,10 @@ export default class Trigger extends Renderable {
|
|
|
14
15
|
* @param {number} [settings.width] - width of the trigger area
|
|
15
16
|
* @param {number} [settings.height] - height of the trigger area
|
|
16
17
|
* @param {Rect[]|Polygon[]|Line[]|Ellipse[]} [settings.shapes] - collision shape(s) that will trigger the event
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {string|Color} [settings.color] -
|
|
18
|
+
* @param {number} [settings.duration] - Transition duration (in ms)
|
|
19
|
+
* @param {string|Color} [settings.color] - Transition color (also accepts legacy `fade` property)
|
|
20
|
+
* @param {string} [settings.transition="fade"] - Transition type: "fade" for a color fade, "mask" for a shape-based mask transition
|
|
21
|
+
* @param {Ellipse|Polygon} [settings.shape] - Mask shape for "mask" transition type (e.g. an Ellipse for iris, a Polygon for diamond/star)
|
|
19
22
|
* @param {string} [settings.event="level"] - the type of event to trigger (only "level" supported for now)
|
|
20
23
|
* @param {string} [settings.to] - level to load if level trigger
|
|
21
24
|
* @param {string|Container} [settings.container] - Target container. See {@link level.load}
|
|
@@ -23,21 +26,45 @@ export default class Trigger extends Renderable {
|
|
|
23
26
|
* @param {boolean} [settings.flatten] - Flatten all objects into the target container. See {@link level.load}
|
|
24
27
|
* @param {boolean} [settings.setViewportBounds] - Resize the viewport to match the level. See {@link level.load}
|
|
25
28
|
* @example
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* // fade transition (default)
|
|
30
|
+
* world.addChild(new Trigger(x, y, {
|
|
31
|
+
* shapes: [new Rect(0, 0, 100, 100)],
|
|
32
|
+
* color: "#000",
|
|
33
|
+
* duration: 250,
|
|
34
|
+
* to: "mymap2",
|
|
35
|
+
* }));
|
|
36
|
+
* @example
|
|
37
|
+
* // mask transition with iris (ellipse) shape
|
|
38
|
+
* world.addChild(new Trigger(x, y, {
|
|
39
|
+
* shapes: [new Rect(0, 0, 100, 100)],
|
|
40
|
+
* transition: "mask",
|
|
41
|
+
* shape: new Ellipse(0, 0, 1, 1),
|
|
42
|
+
* color: "#000",
|
|
43
|
+
* duration: 500,
|
|
44
|
+
* to: "mymap2",
|
|
45
|
+
* }));
|
|
46
|
+
* @example
|
|
47
|
+
* // mask transition with diamond polygon
|
|
48
|
+
* world.addChild(new Trigger(x, y, {
|
|
49
|
+
* shapes: [new Rect(0, 0, 100, 100)],
|
|
50
|
+
* transition: "mask",
|
|
51
|
+
* shape: new Polygon(0, 0, [
|
|
52
|
+
* { x: 0, y: -1 }, { x: 1, y: 0 },
|
|
53
|
+
* { x: 0, y: 1 }, { x: -1, y: 0 },
|
|
54
|
+
* ]),
|
|
55
|
+
* color: "#000",
|
|
56
|
+
* duration: 400,
|
|
57
|
+
* to: "mymap2",
|
|
58
|
+
* }));
|
|
34
59
|
*/
|
|
35
60
|
constructor(x: number, y: number, settings: {
|
|
36
61
|
width?: number | undefined;
|
|
37
62
|
height?: number | undefined;
|
|
38
63
|
shapes?: Rect[] | Polygon[] | Line[] | Ellipse[] | undefined;
|
|
39
|
-
duration?:
|
|
64
|
+
duration?: number | undefined;
|
|
40
65
|
color?: string | Color;
|
|
66
|
+
transition?: string | undefined;
|
|
67
|
+
shape?: Ellipse | Polygon;
|
|
41
68
|
event?: string | undefined;
|
|
42
69
|
to?: string | undefined;
|
|
43
70
|
container?: string | Container;
|
|
@@ -45,8 +72,10 @@ export default class Trigger extends Renderable {
|
|
|
45
72
|
flatten?: boolean | undefined;
|
|
46
73
|
setViewportBounds?: boolean | undefined;
|
|
47
74
|
});
|
|
48
|
-
|
|
49
|
-
duration:
|
|
75
|
+
color: any;
|
|
76
|
+
duration: number | undefined;
|
|
77
|
+
transition: string;
|
|
78
|
+
transitionShape: any;
|
|
50
79
|
fading: boolean;
|
|
51
80
|
type: any;
|
|
52
81
|
id: any;
|
|
@@ -62,11 +91,7 @@ export default class Trigger extends Renderable {
|
|
|
62
91
|
event: string;
|
|
63
92
|
};
|
|
64
93
|
/**
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
|
-
onFadeComplete(): void;
|
|
68
|
-
/**
|
|
69
|
-
* trigger this event
|
|
94
|
+
* Trigger this event. Override in subclasses to customize behavior.
|
|
70
95
|
* @protected
|
|
71
96
|
*/
|
|
72
97
|
protected triggerEvent(): void;
|