melonjs 18.1.0 → 18.2.1
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/build/application/application.d.ts +29 -37
- package/build/application/application.d.ts.map +1 -1
- package/build/application/header.d.ts +3 -7
- package/build/application/header.d.ts.map +1 -1
- package/build/application/resize.d.ts +3 -4
- package/build/application/resize.d.ts.map +1 -1
- package/build/audio/audio.d.ts +145 -125
- package/build/audio/audio.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +192 -102
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/geometries/roundrect.d.ts +82 -17
- package/build/geometries/roundrect.d.ts.map +1 -1
- package/build/index.d.ts +12 -12
- package/build/index.js +2288 -842
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts +110 -61
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/input.d.ts +3 -7
- package/build/input/input.d.ts.map +1 -1
- package/build/input/pointer.d.ts +25 -51
- package/build/input/pointer.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts +51 -79
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/tiled/TMXGroup.d.ts +5 -0
- package/build/level/tiled/TMXGroup.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXObject.d.ts +21 -16
- package/build/level/tiled/TMXObject.d.ts.map +1 -1
- package/build/level/tiled/TMXTile.d.ts +16 -5
- package/build/level/tiled/TMXTile.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +15 -3
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts +136 -15
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXUtils.d.ts +31 -0
- package/build/level/tiled/TMXUtils.d.ts.map +1 -1
- package/build/level/tiled/constants.d.ts +1 -1
- package/build/level/tiled/constants.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +42 -0
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -0
- package/build/level/tiled/renderer/autodetect.d.ts +2 -1
- package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts +1 -0
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +38 -121
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +1 -4
- package/build/particles/particle.d.ts.map +1 -1
- package/build/physics/bounds.d.ts +1 -1
- package/build/physics/bounds.d.ts.map +1 -1
- package/build/physics/detector.d.ts.map +1 -1
- package/build/physics/world.d.ts +2 -2
- package/build/plugin/plugin.d.ts +36 -53
- package/build/plugin/plugin.d.ts.map +1 -1
- package/build/polyfill/ellipse.d.ts +2 -0
- package/build/polyfill/ellipse.d.ts.map +1 -0
- package/build/polyfill/index.d.ts +1 -0
- package/build/polyfill/index.d.ts.map +1 -1
- package/build/renderable/colorlayer.d.ts +2 -2
- package/build/renderable/container.d.ts +6 -6
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/imagelayer.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +11 -2
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/ui/uibaseelement.d.ts +46 -33
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uispriteelement.d.ts +53 -43
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +68 -74
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts +1 -1
- package/build/state/state.d.ts +93 -90
- package/build/state/state.d.ts.map +1 -1
- package/build/system/event.d.ts +2 -2
- package/build/system/event.d.ts.map +1 -1
- package/build/utils/decode.d.ts +1 -0
- package/build/utils/decode.d.ts.map +1 -1
- package/build/utils/function.d.ts +1 -1
- package/build/utils/function.d.ts.map +1 -1
- package/build/utils/utils.d.ts +1 -1
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +40 -13
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/renderer.d.ts +12 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts +43 -8
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/quad_batcher.d.ts +0 -2
- package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/buffer/index.d.ts +33 -8
- package/build/video/webgl/buffer/index.d.ts.map +1 -1
- package/build/video/webgl/buffer/vertex.d.ts +9 -1
- package/build/video/webgl/buffer/vertex.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +22 -20
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,104 +1,204 @@
|
|
|
1
|
+
import { Rect } from "./../geometries/rectangle.ts";
|
|
2
|
+
import type { Color } from "../math/color.ts";
|
|
3
|
+
import { Matrix2d } from "../math/matrix2d.ts";
|
|
4
|
+
import { Matrix3d } from "../math/matrix3d.ts";
|
|
5
|
+
import { Vector2d } from "../math/vector2d.ts";
|
|
6
|
+
import { Vector3d } from "../math/vector3d.ts";
|
|
7
|
+
import { Bounds } from "./../physics/bounds.ts";
|
|
8
|
+
import type Container from "./../renderable/container.js";
|
|
9
|
+
import Renderable from "./../renderable/renderable.js";
|
|
10
|
+
import type Tween from "../tweens/tween.ts";
|
|
11
|
+
import type Renderer from "./../video/renderer.js";
|
|
12
|
+
/**
|
|
13
|
+
* @import Entity from "./../renderable/entity/entity.js";
|
|
14
|
+
* @import Sprite from "./../renderable/sprite.js";
|
|
15
|
+
* @import NineSliceSprite from "./../renderable/nineslicesprite.js";
|
|
16
|
+
*/
|
|
17
|
+
interface AxisEnum {
|
|
18
|
+
readonly NONE: 0;
|
|
19
|
+
readonly HORIZONTAL: 1;
|
|
20
|
+
readonly VERTICAL: 2;
|
|
21
|
+
readonly BOTH: 3;
|
|
22
|
+
}
|
|
23
|
+
interface ShakeState {
|
|
24
|
+
intensity: number;
|
|
25
|
+
duration: number;
|
|
26
|
+
axis: number;
|
|
27
|
+
onComplete: (() => void) | null | undefined;
|
|
28
|
+
}
|
|
29
|
+
interface FadeState {
|
|
30
|
+
color: Color | null;
|
|
31
|
+
tween: Tween | null;
|
|
32
|
+
}
|
|
1
33
|
/**
|
|
2
34
|
* a 2D orthographic camera
|
|
3
35
|
* @category Camera
|
|
36
|
+
* @example
|
|
37
|
+
* // create a minimap camera in the top-right corner showing the full level
|
|
38
|
+
* const minimap = new Camera2d(0, 0, 180, 100);
|
|
39
|
+
* minimap.name = "minimap";
|
|
40
|
+
* minimap.screenX = game.viewport.width - 190;
|
|
41
|
+
* minimap.screenY = 10;
|
|
42
|
+
* minimap.autoResize = false;
|
|
43
|
+
* minimap.setBounds(0, 0, levelWidth, levelHeight);
|
|
44
|
+
* minimap.zoom = Math.min(180 / levelWidth, 100 / levelHeight);
|
|
45
|
+
*
|
|
46
|
+
* // add the camera to the current stage
|
|
47
|
+
* this.cameras.set("minimap", minimap);
|
|
4
48
|
*/
|
|
5
49
|
export default class Camera2d extends Renderable {
|
|
6
50
|
/**
|
|
7
51
|
* Axis definition
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
readonly AXIS: {
|
|
16
|
-
NONE: number;
|
|
17
|
-
HORIZONTAL: number;
|
|
18
|
-
VERTICAL: number;
|
|
19
|
-
BOTH: number;
|
|
20
|
-
};
|
|
52
|
+
* NONE no axis
|
|
53
|
+
* HORIZONTAL horizontal axis only
|
|
54
|
+
* VERTICAL vertical axis only
|
|
55
|
+
* BOTH both axis
|
|
56
|
+
*/
|
|
57
|
+
AXIS: AxisEnum;
|
|
21
58
|
/**
|
|
22
59
|
* Camera bounds
|
|
23
|
-
* @type {Bounds}
|
|
24
60
|
*/
|
|
25
61
|
bounds: Bounds;
|
|
26
62
|
/**
|
|
27
63
|
* enable or disable damping
|
|
28
|
-
* @private
|
|
29
64
|
* @default true
|
|
30
65
|
*/
|
|
31
|
-
|
|
66
|
+
smoothFollow: boolean;
|
|
32
67
|
/**
|
|
33
68
|
* Camera damping for smooth transition [0 .. 1].
|
|
34
69
|
* 1 being the maximum value and will snap the camera to the target position
|
|
35
|
-
* @type {number}
|
|
36
70
|
* @default 1.0
|
|
37
71
|
*/
|
|
38
72
|
damping: number;
|
|
39
73
|
/**
|
|
40
74
|
* the closest point relative to the camera
|
|
41
|
-
* @type {number}
|
|
42
75
|
* @default -1000
|
|
43
76
|
*/
|
|
44
77
|
near: number;
|
|
45
78
|
/**
|
|
46
79
|
* the furthest point relative to the camera.
|
|
47
|
-
* @type {number}
|
|
48
80
|
* @default 1000
|
|
49
81
|
*/
|
|
50
82
|
far: number;
|
|
83
|
+
/**
|
|
84
|
+
* the x position on the screen where this camera viewport is rendered.
|
|
85
|
+
* @default 0
|
|
86
|
+
*/
|
|
87
|
+
screenX: number;
|
|
88
|
+
/**
|
|
89
|
+
* the y position on the screen where this camera viewport is rendered.
|
|
90
|
+
* @default 0
|
|
91
|
+
*/
|
|
92
|
+
screenY: number;
|
|
93
|
+
/**
|
|
94
|
+
* @ignore
|
|
95
|
+
*/
|
|
96
|
+
_zoom: number;
|
|
97
|
+
/**
|
|
98
|
+
* the world-space projection matrix for non-default cameras (offset/zoomed).
|
|
99
|
+
* Maps world coordinates to the camera's screen viewport.
|
|
100
|
+
*/
|
|
101
|
+
worldProjection: Matrix3d;
|
|
102
|
+
/**
|
|
103
|
+
* the screen-space projection matrix for non-default cameras.
|
|
104
|
+
* Maps coordinates so that (0,0) aligns with the camera's screenX/screenY position.
|
|
105
|
+
* Used for rendering floating elements (e.g. background layers) in the correct screen area.
|
|
106
|
+
*/
|
|
107
|
+
screenProjection: Matrix3d;
|
|
108
|
+
/**
|
|
109
|
+
* Whether this camera should automatically resize when the canvas resizes.
|
|
110
|
+
* Set to false for non-default cameras with fixed dimensions
|
|
111
|
+
* (e.g. minimap, split-screen viewports).
|
|
112
|
+
* @default true
|
|
113
|
+
*/
|
|
114
|
+
autoResize: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* cached world view bounds
|
|
117
|
+
* @ignore
|
|
118
|
+
*/
|
|
119
|
+
_worldView: Bounds;
|
|
51
120
|
/**
|
|
52
121
|
* the default camera projection matrix
|
|
53
122
|
* (2d cameras use an orthographic projection by default).
|
|
54
|
-
* @type {Matrix3d}
|
|
55
123
|
*/
|
|
56
124
|
projectionMatrix: Matrix3d;
|
|
57
125
|
/**
|
|
58
126
|
* the invert camera transform used to unproject points
|
|
59
127
|
* @ignore
|
|
60
|
-
* @type {Matrix2d}
|
|
61
128
|
*/
|
|
62
129
|
invCurrentTransform: Matrix2d;
|
|
130
|
+
/** offset for shake effect */
|
|
63
131
|
offset: Vector2d;
|
|
64
|
-
target
|
|
132
|
+
/** target to follow */
|
|
133
|
+
target: Vector2d | Vector3d | null;
|
|
134
|
+
/** default value follow */
|
|
65
135
|
follow_axis: number;
|
|
66
136
|
/**
|
|
67
137
|
* shake variables
|
|
68
138
|
* @ignore
|
|
69
139
|
*/
|
|
70
|
-
_shake:
|
|
71
|
-
intensity: number;
|
|
72
|
-
duration: number;
|
|
73
|
-
axis: number;
|
|
74
|
-
onComplete: null;
|
|
75
|
-
};
|
|
140
|
+
_shake: ShakeState;
|
|
76
141
|
/**
|
|
77
142
|
* flash variables
|
|
78
143
|
* @ignore
|
|
79
144
|
*/
|
|
80
|
-
_fadeOut:
|
|
81
|
-
color: null;
|
|
82
|
-
tween: null;
|
|
83
|
-
};
|
|
145
|
+
_fadeOut: FadeState;
|
|
84
146
|
/**
|
|
85
147
|
* fade variables
|
|
86
148
|
* @ignore
|
|
87
149
|
*/
|
|
88
|
-
_fadeIn:
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
150
|
+
_fadeIn: FadeState;
|
|
151
|
+
/** the camera deadzone */
|
|
152
|
+
deadzone: Rect;
|
|
153
|
+
/**
|
|
154
|
+
* @param minX - start x offset
|
|
155
|
+
* @param minY - start y offset
|
|
156
|
+
* @param maxX - end x offset
|
|
157
|
+
* @param maxY - end y offset
|
|
158
|
+
*/
|
|
159
|
+
constructor(minX: number, minY: number, maxX: number, maxY: number);
|
|
92
160
|
/** @ignore */
|
|
93
161
|
_updateProjectionMatrix(): void;
|
|
94
162
|
/** @ignore */
|
|
95
|
-
_followH(target:
|
|
163
|
+
_followH(target: Vector2d | Vector3d): number;
|
|
96
164
|
/** @ignore */
|
|
97
|
-
_followV(target:
|
|
165
|
+
_followV(target: Vector2d | Vector3d): number;
|
|
166
|
+
/**
|
|
167
|
+
* the zoom level of this camera.
|
|
168
|
+
* Values less than 1 zoom out (show more of the world),
|
|
169
|
+
* values greater than 1 zoom in (show less of the world).
|
|
170
|
+
* @default 1
|
|
171
|
+
* @example
|
|
172
|
+
* // zoom out to show the full level in a 180x100 minimap
|
|
173
|
+
* camera.zoom = Math.min(180 / levelWidth, 100 / levelHeight);
|
|
174
|
+
*/
|
|
175
|
+
get zoom(): number;
|
|
176
|
+
set zoom(value: number);
|
|
177
|
+
/**
|
|
178
|
+
* Whether this camera is using default settings (no screen offset, no zoom).
|
|
179
|
+
* Non-default cameras use custom projections for viewport positioning and scaling.
|
|
180
|
+
* @returns true if this camera has no screen offset and zoom is 1
|
|
181
|
+
*/
|
|
182
|
+
get isDefault(): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* The world-space bounds currently visible through this camera,
|
|
185
|
+
* taking into account position and zoom level.
|
|
186
|
+
* @returns the visible world area
|
|
187
|
+
*/
|
|
188
|
+
get worldView(): Bounds;
|
|
189
|
+
/**
|
|
190
|
+
* Set the camera screen position and size in a single call.
|
|
191
|
+
* @param x - x position on screen
|
|
192
|
+
* @param y - y position on screen
|
|
193
|
+
* @param [w] - width (defaults to current width)
|
|
194
|
+
* @param [h] - height (defaults to current height)
|
|
195
|
+
* @returns this camera for chaining
|
|
196
|
+
*/
|
|
197
|
+
setViewport(x: number, y: number, w?: number, h?: number): this;
|
|
98
198
|
/**
|
|
99
199
|
* reset the camera position to specified coordinates
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
200
|
+
* @param [x=0] - initial position of the camera on the x axis
|
|
201
|
+
* @param [y=0] - initial position of the camera on the y axis
|
|
102
202
|
*/
|
|
103
203
|
reset(x?: number, y?: number): void;
|
|
104
204
|
/**
|
|
@@ -106,38 +206,37 @@ export default class Camera2d extends Renderable {
|
|
|
106
206
|
* the "deadzone" defines an area within the current camera in which
|
|
107
207
|
* the followed renderable can move without scrolling the camera.
|
|
108
208
|
* @see {@link follow}
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
209
|
+
* @param w - deadzone width
|
|
210
|
+
* @param h - deadzone height
|
|
111
211
|
*/
|
|
112
212
|
setDeadzone(w: number, h: number): void;
|
|
113
|
-
deadzone: Rect | undefined;
|
|
114
213
|
/**
|
|
115
214
|
* resize the camera
|
|
116
|
-
* @param
|
|
117
|
-
* @param
|
|
118
|
-
* @returns
|
|
215
|
+
* @param w - new width of the camera
|
|
216
|
+
* @param h - new height of the camera
|
|
217
|
+
* @returns this camera
|
|
119
218
|
*/
|
|
120
|
-
resize(w: number, h: number):
|
|
219
|
+
resize(w: number, h: number): this;
|
|
121
220
|
/**
|
|
122
221
|
* set the camera boundaries (set to the world limit by default).
|
|
123
222
|
* the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
223
|
+
* @param x - world left limit
|
|
224
|
+
* @param y - world top limit
|
|
225
|
+
* @param w - world width limit
|
|
226
|
+
* @param h - world height limit
|
|
128
227
|
*/
|
|
129
228
|
setBounds(x: number, y: number, w: number, h: number): void;
|
|
130
229
|
/**
|
|
131
230
|
* set the camera to follow the specified renderable. <br>
|
|
132
231
|
* (this will put the camera center around the given target)
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @param
|
|
232
|
+
* @param target - renderable or position vector to follow
|
|
233
|
+
* @param [axis=me.game.viewport.AXIS.BOTH] - Which axis to follow (see {@link Camera2d.AXIS})
|
|
234
|
+
* @param [damping=1] - default damping value
|
|
136
235
|
* @example
|
|
137
236
|
* // set the camera to follow this renderable on both axis, and enable damping
|
|
138
237
|
* me.game.viewport.follow(this, me.game.viewport.AXIS.BOTH, 0.1);
|
|
139
238
|
*/
|
|
140
|
-
follow(target: Renderable | Vector2d, axis?: number, damping?: number): void;
|
|
239
|
+
follow(target: Renderable | Vector2d | Vector3d, axis?: number, damping?: number): void;
|
|
141
240
|
/**
|
|
142
241
|
* unfollow the current target
|
|
143
242
|
*/
|
|
@@ -145,8 +244,8 @@ export default class Camera2d extends Renderable {
|
|
|
145
244
|
/**
|
|
146
245
|
* move the camera upper-left position by the specified offset.
|
|
147
246
|
* @see {@link focusOn}
|
|
148
|
-
* @param
|
|
149
|
-
* @param
|
|
247
|
+
* @param x - horizontal offset
|
|
248
|
+
* @param y - vertical offset
|
|
150
249
|
* @example
|
|
151
250
|
* // Move the camera up by four pixels
|
|
152
251
|
* me.game.viewport.move(0, -4);
|
|
@@ -155,33 +254,33 @@ export default class Camera2d extends Renderable {
|
|
|
155
254
|
/**
|
|
156
255
|
* move the camera upper-left position to the specified coordinates
|
|
157
256
|
* @see {@link focusOn}
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
257
|
+
* @param x - horizontal position
|
|
258
|
+
* @param y - vertical position
|
|
160
259
|
*/
|
|
161
260
|
moveTo(x: number, y: number): void;
|
|
162
261
|
/** @ignore */
|
|
163
|
-
updateTarget(): void;
|
|
262
|
+
updateTarget(_dt?: number): void;
|
|
164
263
|
/** @ignore */
|
|
165
|
-
update(dt
|
|
264
|
+
update(dt?: number): boolean;
|
|
166
265
|
/**
|
|
167
266
|
* shake the camera
|
|
168
|
-
* @param
|
|
267
|
+
* @param intensity - maximum offset that the screen can be moved
|
|
169
268
|
* while shaking
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
269
|
+
* @param duration - expressed in milliseconds
|
|
270
|
+
* @param [axis=me.game.viewport.AXIS.BOTH] - specify on which axis to apply the shake effect (see {@link Camera2d.AXIS})
|
|
271
|
+
* @param [onComplete] - callback once shaking effect is over
|
|
272
|
+
* @param [force] - if true this will override the current effect
|
|
174
273
|
* @example
|
|
175
274
|
* // shake it baby !
|
|
176
275
|
* me.game.viewport.shake(10, 500, me.game.viewport.AXIS.BOTH);
|
|
177
276
|
*/
|
|
178
|
-
shake(intensity: number, duration: number, axis?: number, onComplete?:
|
|
277
|
+
shake(intensity: number, duration: number, axis?: number, onComplete?: () => void, force?: boolean): void;
|
|
179
278
|
/**
|
|
180
279
|
* fadeOut(flash) effect<p>
|
|
181
280
|
* screen is filled with the specified color and slowly goes back to normal
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
281
|
+
* @param color - a CSS color value
|
|
282
|
+
* @param [duration=1000] - expressed in milliseconds
|
|
283
|
+
* @param [onComplete] - callback once effect is over
|
|
185
284
|
* @example
|
|
186
285
|
* // fade the camera to white upon dying, reload the level, and then fade out back
|
|
187
286
|
* me.game.viewport.fadeIn("#fff", 150, function() {
|
|
@@ -190,65 +289,56 @@ export default class Camera2d extends Renderable {
|
|
|
190
289
|
* me.game.viewport.fadeOut("#fff", 150);
|
|
191
290
|
* });
|
|
192
291
|
*/
|
|
193
|
-
fadeOut(color: Color | string, duration?: number, onComplete?:
|
|
292
|
+
fadeOut(color: Color | string, duration?: number, onComplete?: () => void): void;
|
|
194
293
|
/**
|
|
195
294
|
* fadeIn effect <p>
|
|
196
295
|
* fade to the specified color
|
|
197
|
-
* @param
|
|
198
|
-
* @param
|
|
199
|
-
* @param
|
|
296
|
+
* @param color - a CSS color value
|
|
297
|
+
* @param [duration=1000] - expressed in milliseconds
|
|
298
|
+
* @param [onComplete] - callback once effect is over
|
|
200
299
|
* @example
|
|
201
300
|
* // flash the camera to white for 75ms
|
|
202
301
|
* me.game.viewport.fadeIn("#FFFFFF", 75);
|
|
203
302
|
*/
|
|
204
|
-
fadeIn(color: Color | string, duration?: number, onComplete?:
|
|
303
|
+
fadeIn(color: Color | string, duration?: number, onComplete?: () => void): void;
|
|
205
304
|
/**
|
|
206
305
|
* set the camera position around the specified object
|
|
207
|
-
* @param
|
|
306
|
+
* @param target - the renderable to focus the camera on
|
|
208
307
|
*/
|
|
209
|
-
focusOn(target: Renderable
|
|
308
|
+
focusOn(target: Renderable): void;
|
|
210
309
|
/**
|
|
211
310
|
* check if the specified renderable is in the camera
|
|
212
|
-
* @param
|
|
213
|
-
* @param
|
|
214
|
-
* @returns
|
|
311
|
+
* @param obj - to be checked against
|
|
312
|
+
* @param [floating = obj.floating] - if visibility check should be done against screen coordinates
|
|
313
|
+
* @returns true if within the viewport
|
|
215
314
|
*/
|
|
216
|
-
isVisible(obj: Renderable
|
|
315
|
+
isVisible(obj: Renderable, floating?: boolean): boolean;
|
|
217
316
|
/**
|
|
218
317
|
* convert the given "local" (screen) coordinates into world coordinates
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
* @returns
|
|
318
|
+
* @param x - the x coordinate of the local point to be converted
|
|
319
|
+
* @param y - the y coordinate of the local point to be converted
|
|
320
|
+
* @param [v] - an optional vector object where to set the converted value
|
|
321
|
+
* @returns the converted world coordinates as a Vector2d
|
|
223
322
|
*/
|
|
224
323
|
localToWorld(x: number, y: number, v?: Vector2d): Vector2d;
|
|
225
324
|
/**
|
|
226
325
|
* convert the given world coordinates into "local" (screen) coordinates
|
|
227
|
-
* @param
|
|
228
|
-
* @param
|
|
229
|
-
* @param
|
|
230
|
-
* @returns
|
|
326
|
+
* @param x - the x world coordinate to be converted
|
|
327
|
+
* @param y - the y world coordinate to be converted
|
|
328
|
+
* @param [v] - an optional vector object where to set the converted value
|
|
329
|
+
* @returns a vector with the converted local coordinates
|
|
231
330
|
*/
|
|
232
|
-
worldToLocal(x: number, y: number, v?:
|
|
331
|
+
worldToLocal(x: number, y: number, v?: Vector2d): Vector2d;
|
|
233
332
|
/**
|
|
234
333
|
* render the camera effects
|
|
235
334
|
* @ignore
|
|
236
335
|
*/
|
|
237
|
-
drawFX(renderer:
|
|
336
|
+
drawFX(renderer: Renderer): void;
|
|
238
337
|
/**
|
|
239
338
|
* draw all objects visible in this viewport
|
|
240
339
|
* @ignore
|
|
241
340
|
*/
|
|
242
|
-
draw(renderer:
|
|
341
|
+
draw(renderer: Renderer, container: Container): void;
|
|
243
342
|
}
|
|
244
|
-
|
|
245
|
-
import type { Bounds } from "./../physics/bounds.ts";
|
|
246
|
-
import { Matrix3d } from "../math/matrix3d.ts";
|
|
247
|
-
import { Matrix2d } from "../math/matrix2d.ts";
|
|
248
|
-
import { Vector2d } from "../math/vector2d.ts";
|
|
249
|
-
import { Rect } from "./../geometries/rectangle.ts";
|
|
250
|
-
import type { Color } from "./../math/color.ts";
|
|
251
|
-
import type Entity from "./../renderable/entity/entity.js";
|
|
252
|
-
import type Sprite from "./../renderable/sprite.js";
|
|
253
|
-
import type NineSliceSprite from "./../renderable/nineslicesprite.js";
|
|
343
|
+
export {};
|
|
254
344
|
//# sourceMappingURL=camera2d.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../../src/camera/camera2d.
|
|
1
|
+
{"version":3,"file":"camera2d.d.ts","sourceRoot":"","sources":["../../src/camera/camera2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAq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vB,KAAK,CAAC,EAAE,OAAO,GACb,IAAI;IAUP;;;;;;;;;;;;;OAaG;IACH,OAAO,CACN,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,QAAQ,GAAE,MAAa,EACvB,UAAU,CAAC,EAAE,MAAM,IAAI,GACrB,IAAI;IAYP;;;;;;;;;OASG;IACH,MAAM,CACL,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,QAAQ,GAAE,MAAa,EACvB,UAAU,CAAC,EAAE,MAAM,IAAI,GACrB,IAAI;IAcP;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAQjC;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,GAAE,OAAsB,GAAG,OAAO;IASrE;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAS1D;;;;;;OAMG;IACH,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ;IAS1D;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAsChC;;;OAGG;IACM,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI;CA8E7D"}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { Vector2d } from "../math/vector2d.ts";
|
|
2
|
-
import {
|
|
2
|
+
import { Polygon } from "./polygon.ts";
|
|
3
3
|
/**
|
|
4
4
|
* a rectangle object with rounded corners
|
|
5
5
|
* @category Geometry
|
|
6
6
|
*/
|
|
7
|
-
export declare class RoundRect extends
|
|
7
|
+
export declare class RoundRect extends Polygon {
|
|
8
8
|
/**
|
|
9
9
|
* Corner radius.
|
|
10
10
|
*/
|
|
11
11
|
_radius: number;
|
|
12
|
+
/**
|
|
13
|
+
* stored width
|
|
14
|
+
*/
|
|
15
|
+
_width: number;
|
|
16
|
+
/**
|
|
17
|
+
* stored height
|
|
18
|
+
*/
|
|
19
|
+
_height: number;
|
|
12
20
|
/**
|
|
13
21
|
* the shape type (used internally)
|
|
14
22
|
*/
|
|
@@ -21,37 +29,94 @@ export declare class RoundRect extends Rect {
|
|
|
21
29
|
* @param [radius=20] - the radius of the rounded corner
|
|
22
30
|
*/
|
|
23
31
|
constructor(x: number, y: number, width: number, height: number, radius?: number);
|
|
32
|
+
/**
|
|
33
|
+
* width of the RoundRect
|
|
34
|
+
*/
|
|
35
|
+
get width(): number;
|
|
36
|
+
set width(value: number);
|
|
37
|
+
/**
|
|
38
|
+
* height of the RoundRect
|
|
39
|
+
*/
|
|
40
|
+
get height(): number;
|
|
41
|
+
set height(value: number);
|
|
42
|
+
/**
|
|
43
|
+
* left coordinate of the RoundRect
|
|
44
|
+
*/
|
|
45
|
+
get left(): number;
|
|
46
|
+
/**
|
|
47
|
+
* right coordinate of the RoundRect
|
|
48
|
+
*/
|
|
49
|
+
get right(): number;
|
|
50
|
+
/**
|
|
51
|
+
* top coordinate of the RoundRect
|
|
52
|
+
*/
|
|
53
|
+
get top(): number;
|
|
54
|
+
/**
|
|
55
|
+
* bottom coordinate of the RoundRect
|
|
56
|
+
*/
|
|
57
|
+
get bottom(): number;
|
|
58
|
+
/**
|
|
59
|
+
* absolute center of this RoundRect on the horizontal axis
|
|
60
|
+
*/
|
|
61
|
+
get centerX(): number;
|
|
62
|
+
/**
|
|
63
|
+
* absolute center of this RoundRect on the vertical axis
|
|
64
|
+
*/
|
|
65
|
+
get centerY(): number;
|
|
24
66
|
/**
|
|
25
67
|
* the radius of the rounded corner
|
|
26
68
|
* @default 20
|
|
27
69
|
*/
|
|
28
70
|
get radius(): number;
|
|
29
71
|
set radius(value: number);
|
|
72
|
+
/**
|
|
73
|
+
* Rebuild polygon vertices to approximate the rounded corners.
|
|
74
|
+
* Reuses existing Vector2d instances when the vertex count matches.
|
|
75
|
+
* @ignore
|
|
76
|
+
*/
|
|
77
|
+
_updateVertices(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Set new dimensions for the rounded rectangle.
|
|
80
|
+
* @param width - The new width.
|
|
81
|
+
* @param height - The new height.
|
|
82
|
+
*/
|
|
83
|
+
setSize(width: number, height: number): this;
|
|
84
|
+
/**
|
|
85
|
+
* resize the rounded rectangle
|
|
86
|
+
* @param w - new width
|
|
87
|
+
* @param h - new height
|
|
88
|
+
* @returns this rounded rectangle
|
|
89
|
+
*/
|
|
90
|
+
resize(w: number, h: number): this;
|
|
30
91
|
/**
|
|
31
92
|
* copy the position, size and radius of the given rounded rectangle into this one
|
|
32
93
|
* @param rrect - source rounded rectangle
|
|
33
|
-
* @returns
|
|
94
|
+
* @returns this rounded rectangle
|
|
34
95
|
*/
|
|
35
96
|
copy(rrect: RoundRect): this;
|
|
36
97
|
/**
|
|
37
|
-
* Returns true if the rounded rectangle contains the given point
|
|
38
|
-
* @param x -
|
|
98
|
+
* Returns true if the rounded rectangle contains the given point
|
|
99
|
+
* @param x - x coordinate or a vector point
|
|
39
100
|
* @param [y] - y coordinate
|
|
40
|
-
* @returns True if the rounded rectangle
|
|
41
|
-
* @example
|
|
42
|
-
* if (rect.contains(10, 10)) {
|
|
43
|
-
* // do something
|
|
44
|
-
* }
|
|
45
|
-
* // or
|
|
46
|
-
* if (rect.contains(myVector2d)) {
|
|
47
|
-
* // do something
|
|
48
|
-
* }
|
|
49
|
-
* if (rect.contains(myRect)) {
|
|
50
|
-
* // do something
|
|
51
|
-
* }
|
|
101
|
+
* @returns True if the rounded rectangle contains the given point
|
|
52
102
|
*/
|
|
53
103
|
contains(x: number, y: number): boolean;
|
|
54
104
|
contains(vector: Vector2d): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Returns true if the rounded rectangle contains the given rectangle
|
|
107
|
+
* @param rectangle - rectangle to test
|
|
108
|
+
* @param rectangle.left - left coordinate
|
|
109
|
+
* @param rectangle.right - right coordinate
|
|
110
|
+
* @param rectangle.top - top coordinate
|
|
111
|
+
* @param rectangle.bottom - bottom coordinate
|
|
112
|
+
* @returns true if contained
|
|
113
|
+
*/
|
|
114
|
+
containsRectangle(rectangle: {
|
|
115
|
+
left: number;
|
|
116
|
+
right: number;
|
|
117
|
+
top: number;
|
|
118
|
+
bottom: number;
|
|
119
|
+
}): boolean;
|
|
55
120
|
/**
|
|
56
121
|
* check if this RoundRect is identical to the specified one
|
|
57
122
|
* @param rrect - Other rounded rectangle.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roundrect.d.ts","sourceRoot":"","sources":["../../src/geometries/roundrect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"roundrect.d.ts","sourceRoot":"","sources":["../../src/geometries/roundrect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAkGvC;;;GAGG;AACH,qBAAa,SAAU,SAAQ,OAAO;IACrC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACM,IAAI,SAAe;IAE5B;;;;;;OAMG;gBAEF,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,SAAiB;IAexB;;OAEG;IACH,IAAI,KAAK,WAER;IACD,IAAI,KAAK,CAAC,KAAK,QAAA,EAId;IAED;;OAEG;IACH,IAAI,MAAM,WAET;IACD,IAAI,MAAM,CAAC,KAAK,QAAA,EAIf;IAED;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IA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