melonjs 10.2.2 → 10.4.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 +6 -6
- package/dist/melonjs.js +2907 -3383
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3620 -4528
- package/dist/melonjs.module.js +3210 -3331
- package/package.json +19 -19
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- package/src/entity/draggable.js +11 -21
- package/src/entity/droptarget.js +12 -22
- package/src/entity/entity.js +32 -38
- package/src/game.js +21 -22
- package/src/{shapes → geometries}/ellipse.js +40 -47
- package/src/{shapes → geometries}/line.js +9 -12
- package/src/{shapes → geometries}/poly.js +100 -53
- package/src/{shapes → geometries}/rectangle.js +42 -45
- package/src/index.js +9 -20
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +61 -29
- package/src/input/pointerevent.js +92 -29
- package/src/lang/deprecated.js +44 -14
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -9
- package/src/level/tiled/TMXLayer.js +30 -33
- package/src/level/tiled/TMXObject.js +59 -53
- package/src/level/tiled/TMXTile.js +18 -19
- package/src/level/tiled/TMXTileMap.js +38 -46
- package/src/level/tiled/TMXTileset.js +12 -16
- package/src/level/tiled/TMXTilesetGroup.js +9 -10
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
- package/src/level/tiled/renderer/TMXRenderer.js +24 -26
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
- package/src/loader/loader.js +17 -16
- package/src/loader/loadingscreen.js +8 -10
- package/src/math/color.js +47 -67
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -59
- package/src/math/matrix3.js +56 -63
- package/src/math/observable_vector2.js +87 -77
- package/src/math/observable_vector3.js +97 -80
- package/src/math/vector2.js +107 -97
- package/src/math/vector3.js +116 -100
- package/src/particles/emitter.js +66 -76
- package/src/particles/particle.js +4 -6
- package/src/particles/particlecontainer.js +2 -4
- package/src/physics/body.js +47 -146
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +14 -14
- package/src/physics/quadtree.js +18 -21
- package/src/physics/sat.js +30 -30
- package/src/physics/world.js +24 -29
- package/src/plugin/plugin.js +11 -15
- package/src/renderable/GUI.js +41 -47
- package/src/renderable/collectable.js +5 -10
- package/src/renderable/colorlayer.js +10 -15
- package/src/renderable/container.js +87 -73
- package/src/renderable/imagelayer.js +25 -32
- package/src/renderable/nineslicesprite.js +41 -42
- package/src/renderable/renderable.js +113 -124
- package/src/renderable/sprite.js +62 -69
- package/src/renderable/trigger.js +26 -32
- package/src/state/stage.js +13 -18
- package/src/state/state.js +26 -27
- package/src/system/device.js +76 -133
- package/src/system/event.js +81 -70
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -55
- package/src/text/bitmaptextdata.js +10 -11
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +49 -55
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +44 -46
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +60 -62
- package/src/video/renderer.js +53 -58
- package/src/video/texture.js +98 -112
- package/src/video/texture_cache.js +4 -6
- package/src/video/video.js +16 -17
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +37 -39
- package/src/video/webgl/webgl_compositor.js +128 -110
- package/src/video/webgl/webgl_renderer.js +126 -106
package/src/system/event.js
CHANGED
|
@@ -3,7 +3,6 @@ import EventEmitter from "eventemitter3";
|
|
|
3
3
|
/**
|
|
4
4
|
* an event system based on nodeJS EventEmitter interface
|
|
5
5
|
* @namespace event
|
|
6
|
-
* @memberOf me
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
// internal instance of the event emiter
|
|
@@ -15,8 +14,8 @@ var eventEmitter = new EventEmitter();
|
|
|
15
14
|
* @constant
|
|
16
15
|
* @type {string}
|
|
17
16
|
* @name BOOT
|
|
18
|
-
* @
|
|
19
|
-
* @see
|
|
17
|
+
* @memberof event
|
|
18
|
+
* @see event.on
|
|
20
19
|
*/
|
|
21
20
|
export const BOOT = "me.boot";
|
|
22
21
|
|
|
@@ -27,8 +26,8 @@ export const BOOT = "me.boot";
|
|
|
27
26
|
* @constant
|
|
28
27
|
* @type {string}
|
|
29
28
|
* @name STATE_PAUSE
|
|
30
|
-
* @
|
|
31
|
-
* @see
|
|
29
|
+
* @memberof event
|
|
30
|
+
* @see event.on
|
|
32
31
|
*/
|
|
33
32
|
export const STATE_PAUSE = "me.state.onPause";
|
|
34
33
|
|
|
@@ -39,8 +38,8 @@ export const STATE_PAUSE = "me.state.onPause";
|
|
|
39
38
|
* @constant
|
|
40
39
|
* @type {string}
|
|
41
40
|
* @name STATE_RESUME
|
|
42
|
-
* @
|
|
43
|
-
* @see
|
|
41
|
+
* @memberof event
|
|
42
|
+
* @see event.on
|
|
44
43
|
*/
|
|
45
44
|
export const STATE_RESUME = "me.state.onResume";
|
|
46
45
|
|
|
@@ -51,8 +50,8 @@ export const STATE_RESUME = "me.state.onResume";
|
|
|
51
50
|
* @constant
|
|
52
51
|
* @type {string}
|
|
53
52
|
* @name STATE_STOP
|
|
54
|
-
* @
|
|
55
|
-
* @see
|
|
53
|
+
* @memberof event
|
|
54
|
+
* @see event.on
|
|
56
55
|
*/
|
|
57
56
|
export const STATE_STOP = "me.state.onStop";
|
|
58
57
|
|
|
@@ -63,8 +62,8 @@ export const STATE_STOP = "me.state.onStop";
|
|
|
63
62
|
* @constant
|
|
64
63
|
* @type {string}
|
|
65
64
|
* @name STATE_RESTART
|
|
66
|
-
* @
|
|
67
|
-
* @see
|
|
65
|
+
* @memberof event
|
|
66
|
+
* @see event.on
|
|
68
67
|
*/
|
|
69
68
|
export const STATE_RESTART = "me.state.onRestart";
|
|
70
69
|
|
|
@@ -75,9 +74,9 @@ export const STATE_RESTART = "me.state.onRestart";
|
|
|
75
74
|
* @constant
|
|
76
75
|
* @type {string}
|
|
77
76
|
* @name VIDEO_INIT
|
|
78
|
-
* @
|
|
79
|
-
* @see
|
|
80
|
-
* @see
|
|
77
|
+
* @memberof event
|
|
78
|
+
* @see video.init
|
|
79
|
+
* @see event.on
|
|
81
80
|
*/
|
|
82
81
|
export const VIDEO_INIT = "me.video.onInit";
|
|
83
82
|
|
|
@@ -88,8 +87,8 @@ export const VIDEO_INIT = "me.video.onInit";
|
|
|
88
87
|
* @constant
|
|
89
88
|
* @type {string}
|
|
90
89
|
* @name GAME_INIT
|
|
91
|
-
* @
|
|
92
|
-
* @see
|
|
90
|
+
* @memberof event
|
|
91
|
+
* @see event.on
|
|
93
92
|
*/
|
|
94
93
|
export const GAME_INIT = "me.game.onInit";
|
|
95
94
|
|
|
@@ -100,8 +99,8 @@ export const GAME_INIT = "me.game.onInit";
|
|
|
100
99
|
* @constant
|
|
101
100
|
* @type {string}
|
|
102
101
|
* @name GAME_RESET
|
|
103
|
-
* @
|
|
104
|
-
* @see
|
|
102
|
+
* @memberof event
|
|
103
|
+
* @see event.on
|
|
105
104
|
*/
|
|
106
105
|
export const GAME_RESET = "me.game.onReset";
|
|
107
106
|
|
|
@@ -112,8 +111,8 @@ export const GAME_RESET = "me.game.onReset";
|
|
|
112
111
|
* @constant
|
|
113
112
|
* @type {string}
|
|
114
113
|
* @name GAME_BEFORE_UPDATE
|
|
115
|
-
* @
|
|
116
|
-
* @see
|
|
114
|
+
* @memberof event
|
|
115
|
+
* @see event.on
|
|
117
116
|
*/
|
|
118
117
|
export const GAME_BEFORE_UPDATE = "me.game.beforeUpdate";
|
|
119
118
|
|
|
@@ -124,8 +123,8 @@ export const GAME_BEFORE_UPDATE = "me.game.beforeUpdate";
|
|
|
124
123
|
* @constant
|
|
125
124
|
* @type {string}
|
|
126
125
|
* @name GAME_AFTER_UPDATE
|
|
127
|
-
* @
|
|
128
|
-
* @see
|
|
126
|
+
* @memberof event
|
|
127
|
+
* @see event.on
|
|
129
128
|
*/
|
|
130
129
|
export const GAME_AFTER_UPDATE = "me.game.afterUpdate";
|
|
131
130
|
|
|
@@ -136,8 +135,8 @@ export const GAME_AFTER_UPDATE = "me.game.afterUpdate";
|
|
|
136
135
|
* @constant
|
|
137
136
|
* @type {string}
|
|
138
137
|
* @name GAME_UPDATE
|
|
139
|
-
* @
|
|
140
|
-
* @see
|
|
138
|
+
* @memberof event
|
|
139
|
+
* @see event.on
|
|
141
140
|
*/
|
|
142
141
|
export const GAME_UPDATE = "me.game.onUpdate";
|
|
143
142
|
|
|
@@ -148,8 +147,8 @@ export const GAME_UPDATE = "me.game.onUpdate";
|
|
|
148
147
|
* @constant
|
|
149
148
|
* @type {string}
|
|
150
149
|
* @name GAME_BEFORE_DRAW
|
|
151
|
-
* @
|
|
152
|
-
* @see
|
|
150
|
+
* @memberof event
|
|
151
|
+
* @see event.on
|
|
153
152
|
*/
|
|
154
153
|
export const GAME_BEFORE_DRAW = "me.game.beforeDraw";
|
|
155
154
|
|
|
@@ -160,8 +159,8 @@ export const GAME_BEFORE_DRAW = "me.game.beforeDraw";
|
|
|
160
159
|
* @constant
|
|
161
160
|
* @type {string}
|
|
162
161
|
* @name GAME_AFTER_DRAW
|
|
163
|
-
* @
|
|
164
|
-
* @see
|
|
162
|
+
* @memberof event
|
|
163
|
+
* @see event.on
|
|
165
164
|
*/
|
|
166
165
|
export const GAME_AFTER_DRAW = "me.game.afterDraw";
|
|
167
166
|
|
|
@@ -172,8 +171,8 @@ export const GAME_AFTER_DRAW = "me.game.afterDraw";
|
|
|
172
171
|
* @constant
|
|
173
172
|
* @type {string}
|
|
174
173
|
* @name LEVEL_LOADED
|
|
175
|
-
* @
|
|
176
|
-
* @see
|
|
174
|
+
* @memberof event
|
|
175
|
+
* @see event.on
|
|
177
176
|
*/
|
|
178
177
|
export const LEVEL_LOADED = "me.game.onLevelLoaded";
|
|
179
178
|
|
|
@@ -184,8 +183,8 @@ export const LEVEL_LOADED = "me.game.onLevelLoaded";
|
|
|
184
183
|
* @constant
|
|
185
184
|
* @type {string}
|
|
186
185
|
* @name LOADER_COMPLETE
|
|
187
|
-
* @
|
|
188
|
-
* @see
|
|
186
|
+
* @memberof event
|
|
187
|
+
* @see event.on
|
|
189
188
|
*/
|
|
190
189
|
export const LOADER_COMPLETE = "me.loader.onload";
|
|
191
190
|
|
|
@@ -196,8 +195,8 @@ export const LOADER_COMPLETE = "me.loader.onload";
|
|
|
196
195
|
* @constant
|
|
197
196
|
* @type {string}
|
|
198
197
|
* @name LOADER_PROGRESS
|
|
199
|
-
* @
|
|
200
|
-
* @see
|
|
198
|
+
* @memberof event
|
|
199
|
+
* @see event.on
|
|
201
200
|
*/
|
|
202
201
|
export const LOADER_PROGRESS = "me.loader.onProgress";
|
|
203
202
|
|
|
@@ -213,8 +212,8 @@ export const LOADER_PROGRESS = "me.loader.onProgress";
|
|
|
213
212
|
* @constant
|
|
214
213
|
* @type {string}
|
|
215
214
|
* @name KEYDOWN
|
|
216
|
-
* @
|
|
217
|
-
* @see
|
|
215
|
+
* @memberof event
|
|
216
|
+
* @see event.on
|
|
218
217
|
* @example
|
|
219
218
|
* me.input.bindKey(me.input.KEY.X, "jump", true); // Edge-triggered
|
|
220
219
|
* me.input.bindKey(me.input.KEY.Z, "shoot"); // Level-triggered
|
|
@@ -239,8 +238,8 @@ export const KEYDOWN = "me.input.keydown";
|
|
|
239
238
|
* @constant
|
|
240
239
|
* @type {string}
|
|
241
240
|
* @name KEYUP
|
|
242
|
-
* @
|
|
243
|
-
* @see
|
|
241
|
+
* @memberof event
|
|
242
|
+
* @see event.on
|
|
244
243
|
* @example
|
|
245
244
|
* me.event.on(me.event.KEYUP, (action, keyCode) => {
|
|
246
245
|
* // Checking unbound keys
|
|
@@ -263,8 +262,8 @@ export const KEYUP = "me.input.keyup";
|
|
|
263
262
|
* @constant
|
|
264
263
|
* @type {string}
|
|
265
264
|
* @name GAMEPAD_CONNECTED
|
|
266
|
-
* @
|
|
267
|
-
* @see
|
|
265
|
+
* @memberof event
|
|
266
|
+
* @see event.on
|
|
268
267
|
*/
|
|
269
268
|
export const GAMEPAD_CONNECTED = "gamepad.connected";
|
|
270
269
|
|
|
@@ -275,8 +274,8 @@ export const GAMEPAD_CONNECTED = "gamepad.connected";
|
|
|
275
274
|
* @constant
|
|
276
275
|
* @type {string}
|
|
277
276
|
* @name GAMEPAD_DISCONNECTED
|
|
278
|
-
* @
|
|
279
|
-
* @see
|
|
277
|
+
* @memberof event
|
|
278
|
+
* @see event.on
|
|
280
279
|
*/
|
|
281
280
|
export const GAMEPAD_DISCONNECTED = "gamepad.disconnected";
|
|
282
281
|
|
|
@@ -291,8 +290,8 @@ export const GAMEPAD_DISCONNECTED = "gamepad.disconnected";
|
|
|
291
290
|
* @constant
|
|
292
291
|
* @type {string}
|
|
293
292
|
* @name GAMEPAD_UPDATE
|
|
294
|
-
* @
|
|
295
|
-
* @see
|
|
293
|
+
* @memberof event
|
|
294
|
+
* @see event.on
|
|
296
295
|
*/
|
|
297
296
|
export const GAMEPAD_UPDATE = "gamepad.update";
|
|
298
297
|
|
|
@@ -303,11 +302,23 @@ export const GAMEPAD_UPDATE = "gamepad.update";
|
|
|
303
302
|
* @constant
|
|
304
303
|
* @type {string}
|
|
305
304
|
* @name POINTERMOVE
|
|
306
|
-
* @
|
|
307
|
-
* @see
|
|
305
|
+
* @memberof event
|
|
306
|
+
* @see event.on
|
|
308
307
|
*/
|
|
309
308
|
export const POINTERMOVE = "me.event.pointermove";
|
|
310
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Event for onPointerLockChange event <br>
|
|
312
|
+
* Data passed : {boolean} pointer lock status (true/false)
|
|
313
|
+
* @public
|
|
314
|
+
* @constant
|
|
315
|
+
* @type {string}
|
|
316
|
+
* @name POINTERLOCKCHANGE
|
|
317
|
+
* @memberof event
|
|
318
|
+
* @see event.on
|
|
319
|
+
*/
|
|
320
|
+
export const POINTERLOCKCHANGE = "me.event.pointerlockChange";
|
|
321
|
+
|
|
311
322
|
/**
|
|
312
323
|
* Event for dragstart events on a Draggable entity <br>
|
|
313
324
|
* Data passed:
|
|
@@ -317,8 +328,8 @@ export const POINTERMOVE = "me.event.pointermove";
|
|
|
317
328
|
* @constant
|
|
318
329
|
* @type {string}
|
|
319
330
|
* @name DRAGSTART
|
|
320
|
-
* @
|
|
321
|
-
* @see
|
|
331
|
+
* @memberof event
|
|
332
|
+
* @see event.on
|
|
322
333
|
*/
|
|
323
334
|
export const DRAGSTART = "me.game.dragstart";
|
|
324
335
|
|
|
@@ -331,8 +342,8 @@ export const DRAGSTART = "me.game.dragstart";
|
|
|
331
342
|
* @constant
|
|
332
343
|
* @type {string}
|
|
333
344
|
* @name DRAGEND
|
|
334
|
-
* @
|
|
335
|
-
* @see
|
|
345
|
+
* @memberof event
|
|
346
|
+
* @see event.on
|
|
336
347
|
*/
|
|
337
348
|
export const DRAGEND = "me.game.dragend";
|
|
338
349
|
|
|
@@ -343,8 +354,8 @@ export const DRAGEND = "me.game.dragend";
|
|
|
343
354
|
* @constant
|
|
344
355
|
* @type {string}
|
|
345
356
|
* @name WINDOW_ONRESIZE
|
|
346
|
-
* @
|
|
347
|
-
* @see
|
|
357
|
+
* @memberof event
|
|
358
|
+
* @see event.on
|
|
348
359
|
*/
|
|
349
360
|
export const WINDOW_ONRESIZE = "window.onresize";
|
|
350
361
|
|
|
@@ -357,8 +368,8 @@ export const WINDOW_ONRESIZE = "window.onresize";
|
|
|
357
368
|
* @constant
|
|
358
369
|
* @type {string}
|
|
359
370
|
* @name CANVAS_ONRESIZE
|
|
360
|
-
* @
|
|
361
|
-
* @see
|
|
371
|
+
* @memberof event
|
|
372
|
+
* @see event.on
|
|
362
373
|
*/
|
|
363
374
|
export const CANVAS_ONRESIZE = "canvas.onresize";
|
|
364
375
|
|
|
@@ -371,8 +382,8 @@ export const CANVAS_ONRESIZE = "canvas.onresize";
|
|
|
371
382
|
* @constant
|
|
372
383
|
* @type {string}
|
|
373
384
|
* @name VIEWPORT_ONRESIZE
|
|
374
|
-
* @
|
|
375
|
-
* @see
|
|
385
|
+
* @memberof event
|
|
386
|
+
* @see event.on
|
|
376
387
|
*/
|
|
377
388
|
export const VIEWPORT_ONRESIZE = "viewport.onresize";
|
|
378
389
|
|
|
@@ -383,8 +394,8 @@ export const VIEWPORT_ONRESIZE = "viewport.onresize";
|
|
|
383
394
|
* @constant
|
|
384
395
|
* @type {string}
|
|
385
396
|
* @name WINDOW_ONORIENTATION_CHANGE
|
|
386
|
-
* @
|
|
387
|
-
* @see
|
|
397
|
+
* @memberof event
|
|
398
|
+
* @see event.on
|
|
388
399
|
*/
|
|
389
400
|
export const WINDOW_ONORIENTATION_CHANGE = "window.orientationchange";
|
|
390
401
|
|
|
@@ -395,8 +406,8 @@ export const WINDOW_ONORIENTATION_CHANGE = "window.orientationchange";
|
|
|
395
406
|
* @constant
|
|
396
407
|
* @type {string}
|
|
397
408
|
* @name WINDOW_ONSCROLL
|
|
398
|
-
* @
|
|
399
|
-
* @see
|
|
409
|
+
* @memberof event
|
|
410
|
+
* @see event.on
|
|
400
411
|
*/
|
|
401
412
|
export const WINDOW_ONSCROLL = "window.onscroll";
|
|
402
413
|
|
|
@@ -407,8 +418,8 @@ export const WINDOW_ONSCROLL = "window.onscroll";
|
|
|
407
418
|
* @constant
|
|
408
419
|
* @type {string}
|
|
409
420
|
* @name VIEWPORT_ONCHANGE
|
|
410
|
-
* @
|
|
411
|
-
* @see
|
|
421
|
+
* @memberof event
|
|
422
|
+
* @see event.on
|
|
412
423
|
*/
|
|
413
424
|
export const VIEWPORT_ONCHANGE = "viewport.onchange";
|
|
414
425
|
|
|
@@ -419,8 +430,8 @@ export const VIEWPORT_ONCHANGE = "viewport.onchange";
|
|
|
419
430
|
* @constant
|
|
420
431
|
* @type {string}
|
|
421
432
|
* @name WEBGL_ONCONTEXT_LOST
|
|
422
|
-
* @
|
|
423
|
-
* @see
|
|
433
|
+
* @memberof event
|
|
434
|
+
* @see event.on
|
|
424
435
|
*/
|
|
425
436
|
export const WEBGL_ONCONTEXT_LOST = "renderer.webglcontextlost";
|
|
426
437
|
|
|
@@ -431,14 +442,14 @@ export const WEBGL_ONCONTEXT_LOST = "renderer.webglcontextlost";
|
|
|
431
442
|
* @constant
|
|
432
443
|
* @type {string}
|
|
433
444
|
* @name WEBGL_ONCONTEXT_RESTORED
|
|
434
|
-
* @
|
|
435
|
-
* @see
|
|
445
|
+
* @memberof event
|
|
446
|
+
* @see event.on
|
|
436
447
|
*/
|
|
437
448
|
export const WEBGL_ONCONTEXT_RESTORED = "renderer.webglcontextrestored";
|
|
438
449
|
|
|
439
450
|
/**
|
|
440
451
|
* calls each of the listeners registered for a given event.
|
|
441
|
-
* @function
|
|
452
|
+
* @function event.emit
|
|
442
453
|
* @param {string|symbol} eventName The event name.
|
|
443
454
|
* @param {object} [...arguments] arguments to be passed to all listeners
|
|
444
455
|
* @returns {boolean} true if the event had listeners, false otherwise.
|
|
@@ -451,7 +462,7 @@ export function emit(eventName, ...args) {
|
|
|
451
462
|
|
|
452
463
|
/**
|
|
453
464
|
* Add a listener for a given event.
|
|
454
|
-
* @function
|
|
465
|
+
* @function event.on
|
|
455
466
|
* @param {string|symbol} eventName The event name.
|
|
456
467
|
* @param {Function} listener The listener function.
|
|
457
468
|
* @param {*} [context=this] The context to invoke the listener with.
|
|
@@ -466,7 +477,7 @@ export function on(eventName, listener, context) {
|
|
|
466
477
|
|
|
467
478
|
/**
|
|
468
479
|
* Add a one-time listener for a given event.
|
|
469
|
-
* @function
|
|
480
|
+
* @function event.once
|
|
470
481
|
* @param {string|symbol} eventName The event name.
|
|
471
482
|
* @param {Function} listener The listener function.
|
|
472
483
|
* @param {*} [context=this] The context to invoke the listener with.
|
|
@@ -481,7 +492,7 @@ export function once(eventName, listener, context) {
|
|
|
481
492
|
|
|
482
493
|
/**
|
|
483
494
|
* remove the given listener for a given event.
|
|
484
|
-
* @function
|
|
495
|
+
* @function event.off
|
|
485
496
|
* @param {string|symbol} eventName The event name.
|
|
486
497
|
* @param {Function} listener The listener function.
|
|
487
498
|
* @returns {EventEmitter} `this`.
|
package/src/system/pooling.js
CHANGED
|
@@ -12,8 +12,7 @@ var instance_counter = 0;
|
|
|
12
12
|
* which means, that on level loading the engine will try to instantiate every object
|
|
13
13
|
* found in the map, based on the user defined name in each Object Properties<br>
|
|
14
14
|
* <img src="images/object_properties.png"/><br>
|
|
15
|
-
* @namespace
|
|
16
|
-
* @memberOf me
|
|
15
|
+
* @namespace pool
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
18
|
var pool = {
|
|
@@ -22,7 +21,7 @@ var pool = {
|
|
|
22
21
|
* register an object to the pool. <br>
|
|
23
22
|
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
24
23
|
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
25
|
-
* @function
|
|
24
|
+
* @function pool.register
|
|
26
25
|
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
27
26
|
* @param {object} classObj corresponding Class to be instantiated
|
|
28
27
|
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
@@ -50,8 +49,8 @@ var pool = {
|
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
51
|
* Pull a new instance of the requested object (if added into the object pool)
|
|
53
|
-
* @function
|
|
54
|
-
* @param {string} name as used in {@link
|
|
52
|
+
* @function pool.pull
|
|
53
|
+
* @param {string} name as used in {@link pool.register}
|
|
55
54
|
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
56
55
|
* @returns {object} the instance of the requested object
|
|
57
56
|
* @example
|
|
@@ -107,7 +106,7 @@ var pool = {
|
|
|
107
106
|
* purge the object pool from any inactive object <br>
|
|
108
107
|
* Object pooling must be enabled for this function to work<br>
|
|
109
108
|
* note: this will trigger the garbage collector
|
|
110
|
-
* @function
|
|
109
|
+
* @function pool.purge
|
|
111
110
|
*/
|
|
112
111
|
purge() {
|
|
113
112
|
for (var className in objectClass) {
|
|
@@ -121,9 +120,9 @@ var pool = {
|
|
|
121
120
|
/**
|
|
122
121
|
* Push back an object instance into the object pool <br>
|
|
123
122
|
* Object pooling for the object class must be enabled,
|
|
124
|
-
* and object must have been instantiated using {@link
|
|
123
|
+
* and object must have been instantiated using {@link pool#pull},
|
|
125
124
|
* otherwise this function won't work
|
|
126
|
-
* @function
|
|
125
|
+
* @function pool.push
|
|
127
126
|
* @throws will throw an error if the object cannot be recycled
|
|
128
127
|
* @param {object} obj instance to be recycled
|
|
129
128
|
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
@@ -147,7 +146,7 @@ var pool = {
|
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
148
|
* Check if an object with the provided name is registered
|
|
150
|
-
* @function
|
|
149
|
+
* @function pool.exists
|
|
151
150
|
* @param {string} name of the registered object class
|
|
152
151
|
* @returns {boolean} true if the classname is registered
|
|
153
152
|
*/
|
|
@@ -158,8 +157,8 @@ var pool = {
|
|
|
158
157
|
/**
|
|
159
158
|
* Check if an object is poolable
|
|
160
159
|
* (was properly registered with the recycling feature enable)
|
|
161
|
-
* @function
|
|
162
|
-
* @see
|
|
160
|
+
* @function pool.poolable
|
|
161
|
+
* @see pool.register
|
|
163
162
|
* @param {object} obj object to be checked
|
|
164
163
|
* @returns {boolean} true if the object is poolable
|
|
165
164
|
* @example
|
|
@@ -178,7 +177,7 @@ var pool = {
|
|
|
178
177
|
|
|
179
178
|
/**
|
|
180
179
|
* returns the amount of object instance currently in the pool
|
|
181
|
-
* @function
|
|
180
|
+
* @function pool.getInstanceCount
|
|
182
181
|
* @returns {number} amount of object instance
|
|
183
182
|
*/
|
|
184
183
|
getInstanceCount() {
|
package/src/system/save.js
CHANGED
|
@@ -29,8 +29,7 @@ import * as event from "./../system/event.js";
|
|
|
29
29
|
*
|
|
30
30
|
* // Remove "lives" from localStorage
|
|
31
31
|
* me.save.remove("lives");
|
|
32
|
-
* @namespace
|
|
33
|
-
* @memberOf me
|
|
32
|
+
* @namespace save
|
|
34
33
|
*/
|
|
35
34
|
|
|
36
35
|
// Variable to hold the object data
|
|
@@ -65,7 +64,7 @@ var save = {
|
|
|
65
64
|
/**
|
|
66
65
|
* Add new keys to localStorage and set them to the given default values if they do not exist
|
|
67
66
|
* @name add
|
|
68
|
-
* @
|
|
67
|
+
* @memberof save
|
|
69
68
|
* @function
|
|
70
69
|
* @param {object} props key and corresponding values
|
|
71
70
|
* @example
|
|
@@ -119,7 +118,7 @@ var save = {
|
|
|
119
118
|
/**
|
|
120
119
|
* Remove a key from localStorage
|
|
121
120
|
* @name remove
|
|
122
|
-
* @
|
|
121
|
+
* @memberof save
|
|
123
122
|
* @function
|
|
124
123
|
* @param {string} key key to be removed
|
|
125
124
|
* @example
|
package/src/system/timer.js
CHANGED
|
@@ -87,22 +87,21 @@ event.on(event.BOOT, () => {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* a Timer class to manage timing related function (FPS, Game Tick, Time...)
|
|
90
|
-
* @namespace
|
|
91
|
-
* @memberOf me
|
|
90
|
+
* @namespace timer
|
|
92
91
|
*/
|
|
93
92
|
var timer = {
|
|
94
93
|
|
|
95
94
|
/**
|
|
96
95
|
* Last game tick value.<br/>
|
|
97
96
|
* Use this value to scale velocities during frame drops due to slow
|
|
98
|
-
* hardware or when setting an FPS limit. (See {@link
|
|
97
|
+
* hardware or when setting an FPS limit. (See {@link timer.maxfps})
|
|
99
98
|
* This feature is disabled by default. Enable me.timer.interpolation to
|
|
100
99
|
* use it.
|
|
101
100
|
* @public
|
|
102
|
-
* @see
|
|
101
|
+
* @see timer.interpolation
|
|
103
102
|
* @type {number}
|
|
104
103
|
* @name tick
|
|
105
|
-
* @
|
|
104
|
+
* @memberof timer
|
|
106
105
|
*/
|
|
107
106
|
tick : 1.0,
|
|
108
107
|
|
|
@@ -112,35 +111,35 @@ var timer = {
|
|
|
112
111
|
* @public
|
|
113
112
|
* @type {number}
|
|
114
113
|
* @name fps
|
|
115
|
-
* @
|
|
114
|
+
* @memberof timer
|
|
116
115
|
*/
|
|
117
116
|
fps : 0,
|
|
118
117
|
|
|
119
118
|
/**
|
|
120
119
|
* Set the maximum target display frame per second
|
|
121
120
|
* @public
|
|
122
|
-
* @see
|
|
121
|
+
* @see timer.tick
|
|
123
122
|
* @type {number}
|
|
124
123
|
* @name maxfps
|
|
125
124
|
* @default 60
|
|
126
|
-
* @
|
|
125
|
+
* @memberof timer
|
|
127
126
|
*/
|
|
128
127
|
maxfps : 60,
|
|
129
128
|
|
|
130
129
|
/**
|
|
131
130
|
* Enable/disable frame interpolation
|
|
132
|
-
* @see
|
|
131
|
+
* @see timer.tick
|
|
133
132
|
* @type {boolean}
|
|
134
133
|
* @default false
|
|
135
134
|
* @name interpolation
|
|
136
|
-
* @
|
|
135
|
+
* @memberof timer
|
|
137
136
|
*/
|
|
138
137
|
interpolation : false,
|
|
139
138
|
|
|
140
139
|
/**
|
|
141
140
|
* reset time (e.g. usefull in case of pause)
|
|
142
141
|
* @name reset
|
|
143
|
-
* @
|
|
142
|
+
* @memberof timer
|
|
144
143
|
* @ignore
|
|
145
144
|
* @function
|
|
146
145
|
*/
|
|
@@ -159,11 +158,11 @@ var timer = {
|
|
|
159
158
|
/**
|
|
160
159
|
* Calls a function once after a specified delay. See me.timer.setInterval to repeativly call a function.
|
|
161
160
|
* @name setTimeout
|
|
162
|
-
* @
|
|
161
|
+
* @memberof timer
|
|
163
162
|
* @param {Function} fn the function you want to execute after delay milliseconds.
|
|
164
163
|
* @param {number} delay the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
165
164
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
166
|
-
* @param {
|
|
165
|
+
* @param {...*} args optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
167
166
|
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearTimeout().
|
|
168
167
|
* @function
|
|
169
168
|
* @example
|
|
@@ -188,11 +187,11 @@ var timer = {
|
|
|
188
187
|
/**
|
|
189
188
|
* Calls a function continously at the specified interval. See setTimeout to call function a single time.
|
|
190
189
|
* @name setInterval
|
|
191
|
-
* @
|
|
190
|
+
* @memberof timer
|
|
192
191
|
* @param {Function} fn the function to execute
|
|
193
192
|
* @param {number} delay the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
194
193
|
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
195
|
-
* @param {
|
|
194
|
+
* @param {...*} args optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
196
195
|
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearInterval().
|
|
197
196
|
* @function
|
|
198
197
|
* @example
|
|
@@ -217,7 +216,7 @@ var timer = {
|
|
|
217
216
|
/**
|
|
218
217
|
* Clears the delay set by me.timer.setTimeout().
|
|
219
218
|
* @name clearTimeout
|
|
220
|
-
* @
|
|
219
|
+
* @memberof timer
|
|
221
220
|
* @function
|
|
222
221
|
* @param {number} timeoutID ID of the timeout to be cleared
|
|
223
222
|
*/
|
|
@@ -228,7 +227,7 @@ var timer = {
|
|
|
228
227
|
/**
|
|
229
228
|
* Clears the Interval set by me.timer.setInterval().
|
|
230
229
|
* @name clearInterval
|
|
231
|
-
* @
|
|
230
|
+
* @memberof timer
|
|
232
231
|
* @function
|
|
233
232
|
* @param {number} intervalID ID of the interval to be cleared
|
|
234
233
|
*/
|
|
@@ -240,7 +239,7 @@ var timer = {
|
|
|
240
239
|
* Return the current timestamp in milliseconds <br>
|
|
241
240
|
* since the game has started or since linux epoch (based on browser support for High Resolution Timer)
|
|
242
241
|
* @name getTime
|
|
243
|
-
* @
|
|
242
|
+
* @memberof timer
|
|
244
243
|
* @returns {number}
|
|
245
244
|
* @function
|
|
246
245
|
*/
|
|
@@ -251,7 +250,7 @@ var timer = {
|
|
|
251
250
|
/**
|
|
252
251
|
* Return elapsed time in milliseconds since the last update
|
|
253
252
|
* @name getDelta
|
|
254
|
-
* @
|
|
253
|
+
* @memberof timer
|
|
255
254
|
* @returns {number}
|
|
256
255
|
* @function
|
|
257
256
|
*/
|
|
@@ -263,7 +262,7 @@ var timer = {
|
|
|
263
262
|
* compute the actual frame time and fps rate
|
|
264
263
|
* @name computeFPS
|
|
265
264
|
* @ignore
|
|
266
|
-
* @
|
|
265
|
+
* @memberof timer
|
|
267
266
|
* @function
|
|
268
267
|
*/
|
|
269
268
|
countFPS() {
|