melonjs 10.2.1 → 10.2.2
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 +1 -1
- package/dist/melonjs.js +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
package/src/system/event.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import EventEmitter from "eventemitter3";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* an event system based on nodeJS EventEmitter interface
|
|
5
|
-
* @namespace event
|
|
6
|
-
* @memberOf me
|
|
7
|
-
*/
|
|
4
|
+
* an event system based on nodeJS EventEmitter interface
|
|
5
|
+
* @namespace event
|
|
6
|
+
* @memberOf me
|
|
7
|
+
*/
|
|
8
8
|
|
|
9
9
|
// internal instance of the event emiter
|
|
10
10
|
var eventEmitter = new EventEmitter();
|
|
@@ -13,7 +13,7 @@ var eventEmitter = new EventEmitter();
|
|
|
13
13
|
* event when the system is booting
|
|
14
14
|
* @public
|
|
15
15
|
* @constant
|
|
16
|
-
* @type
|
|
16
|
+
* @type {string}
|
|
17
17
|
* @name BOOT
|
|
18
18
|
* @memberOf me.event
|
|
19
19
|
* @see me.event.on
|
|
@@ -25,7 +25,7 @@ export const BOOT = "me.boot";
|
|
|
25
25
|
* Data passed : none <br>
|
|
26
26
|
* @public
|
|
27
27
|
* @constant
|
|
28
|
-
* @type
|
|
28
|
+
* @type {string}
|
|
29
29
|
* @name STATE_PAUSE
|
|
30
30
|
* @memberOf me.event
|
|
31
31
|
* @see me.event.on
|
|
@@ -34,10 +34,10 @@ export const STATE_PAUSE = "me.state.onPause";
|
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* event for when the game is resumed <br>
|
|
37
|
-
* Data passed : {
|
|
37
|
+
* Data passed : {number} time in ms the game was paused
|
|
38
38
|
* @public
|
|
39
39
|
* @constant
|
|
40
|
-
* @type
|
|
40
|
+
* @type {string}
|
|
41
41
|
* @name STATE_RESUME
|
|
42
42
|
* @memberOf me.event
|
|
43
43
|
* @see me.event.on
|
|
@@ -49,7 +49,7 @@ export const STATE_RESUME = "me.state.onResume";
|
|
|
49
49
|
* Data passed : none <br>
|
|
50
50
|
* @public
|
|
51
51
|
* @constant
|
|
52
|
-
* @type
|
|
52
|
+
* @type {string}
|
|
53
53
|
* @name STATE_STOP
|
|
54
54
|
* @memberOf me.event
|
|
55
55
|
* @see me.event.on
|
|
@@ -58,10 +58,10 @@ export const STATE_STOP = "me.state.onStop";
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* event for when the game is restarted <br>
|
|
61
|
-
* Data passed : {
|
|
61
|
+
* Data passed : {number} time in ms the game was stopped
|
|
62
62
|
* @public
|
|
63
63
|
* @constant
|
|
64
|
-
* @type
|
|
64
|
+
* @type {string}
|
|
65
65
|
* @name STATE_RESTART
|
|
66
66
|
* @memberOf me.event
|
|
67
67
|
* @see me.event.on
|
|
@@ -73,7 +73,7 @@ export const STATE_RESTART = "me.state.onRestart";
|
|
|
73
73
|
* Data passed : none <br>
|
|
74
74
|
* @public
|
|
75
75
|
* @constant
|
|
76
|
-
* @type
|
|
76
|
+
* @type {string}
|
|
77
77
|
* @name VIDEO_INIT
|
|
78
78
|
* @memberOf me.event
|
|
79
79
|
* @see me.video.init
|
|
@@ -86,7 +86,7 @@ export const VIDEO_INIT = "me.video.onInit";
|
|
|
86
86
|
* Data passed : none <br>
|
|
87
87
|
* @public
|
|
88
88
|
* @constant
|
|
89
|
-
* @type
|
|
89
|
+
* @type {string}
|
|
90
90
|
* @name GAME_INIT
|
|
91
91
|
* @memberOf me.event
|
|
92
92
|
* @see me.event.on
|
|
@@ -98,7 +98,7 @@ export const GAME_INIT = "me.game.onInit";
|
|
|
98
98
|
* Data passed : none <br>
|
|
99
99
|
* @public
|
|
100
100
|
* @constant
|
|
101
|
-
* @type
|
|
101
|
+
* @type {string}
|
|
102
102
|
* @name GAME_RESET
|
|
103
103
|
* @memberOf me.event
|
|
104
104
|
* @see me.event.on
|
|
@@ -107,10 +107,10 @@ export const GAME_RESET = "me.game.onReset";
|
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* event for when the engine is about to start a new game loop
|
|
110
|
-
* Data passed : {
|
|
110
|
+
* Data passed : {number} time the current time stamp
|
|
111
111
|
* @public
|
|
112
112
|
* @constant
|
|
113
|
-
* @type
|
|
113
|
+
* @type {string}
|
|
114
114
|
* @name GAME_BEFORE_UPDATE
|
|
115
115
|
* @memberOf me.event
|
|
116
116
|
* @see me.event.on
|
|
@@ -119,10 +119,10 @@ export const GAME_BEFORE_UPDATE = "me.game.beforeUpdate";
|
|
|
119
119
|
|
|
120
120
|
/**
|
|
121
121
|
* event for the end of the update loop
|
|
122
|
-
* Data passed : {
|
|
122
|
+
* Data passed : {number} time the current time stamp
|
|
123
123
|
* @public
|
|
124
124
|
* @constant
|
|
125
|
-
* @type
|
|
125
|
+
* @type {string}
|
|
126
126
|
* @name GAME_AFTER_UPDATE
|
|
127
127
|
* @memberOf me.event
|
|
128
128
|
* @see me.event.on
|
|
@@ -131,10 +131,10 @@ export const GAME_AFTER_UPDATE = "me.game.afterUpdate";
|
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
* Event for when the game is updated (will be impacted by frame skip, frame interpolation and pause/resume state) <br>
|
|
134
|
-
* Data passed : {
|
|
134
|
+
* Data passed : {number} time the current time stamp
|
|
135
135
|
* @public
|
|
136
136
|
* @constant
|
|
137
|
-
* @type
|
|
137
|
+
* @type {string}
|
|
138
138
|
* @name GAME_UPDATE
|
|
139
139
|
* @memberOf me.event
|
|
140
140
|
* @see me.event.on
|
|
@@ -143,10 +143,10 @@ export const GAME_UPDATE = "me.game.onUpdate";
|
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
145
|
* Event for the end of the draw loop
|
|
146
|
-
* Data passed : {
|
|
146
|
+
* Data passed : {number} time the current time stamp
|
|
147
147
|
* @public
|
|
148
148
|
* @constant
|
|
149
|
-
* @type
|
|
149
|
+
* @type {string}
|
|
150
150
|
* @name GAME_BEFORE_DRAW
|
|
151
151
|
* @memberOf me.event
|
|
152
152
|
* @see me.event.on
|
|
@@ -155,10 +155,10 @@ export const GAME_BEFORE_DRAW = "me.game.beforeDraw";
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* Event for the start of the draw loop
|
|
158
|
-
* Data passed : {
|
|
158
|
+
* Data passed : {number} time the current time stamp
|
|
159
159
|
* @public
|
|
160
160
|
* @constant
|
|
161
|
-
* @type
|
|
161
|
+
* @type {string}
|
|
162
162
|
* @name GAME_AFTER_DRAW
|
|
163
163
|
* @memberOf me.event
|
|
164
164
|
* @see me.event.on
|
|
@@ -167,10 +167,10 @@ export const GAME_AFTER_DRAW = "me.game.afterDraw";
|
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* Event for when a level is loaded <br>
|
|
170
|
-
* Data passed : {
|
|
170
|
+
* Data passed : {string} Level Name
|
|
171
171
|
* @public
|
|
172
172
|
* @constant
|
|
173
|
-
* @type
|
|
173
|
+
* @type {string}
|
|
174
174
|
* @name LEVEL_LOADED
|
|
175
175
|
* @memberOf me.event
|
|
176
176
|
* @see me.event.on
|
|
@@ -182,7 +182,7 @@ export const LEVEL_LOADED = "me.game.onLevelLoaded";
|
|
|
182
182
|
* Data passed : none <br>
|
|
183
183
|
* @public
|
|
184
184
|
* @constant
|
|
185
|
-
* @type
|
|
185
|
+
* @type {string}
|
|
186
186
|
* @name LOADER_COMPLETE
|
|
187
187
|
* @memberOf me.event
|
|
188
188
|
* @see me.event.on
|
|
@@ -191,10 +191,10 @@ export const LOADER_COMPLETE = "me.loader.onload";
|
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Event for displaying a load progress indicator <br>
|
|
194
|
-
* Data passed : {
|
|
194
|
+
* Data passed : {number} [0 .. 1], {Resource} resource object<br>
|
|
195
195
|
* @public
|
|
196
196
|
* @constant
|
|
197
|
-
* @type
|
|
197
|
+
* @type {string}
|
|
198
198
|
* @name LOADER_PROGRESS
|
|
199
199
|
* @memberOf me.event
|
|
200
200
|
* @see me.event.on
|
|
@@ -203,15 +203,15 @@ export const LOADER_PROGRESS = "me.loader.onProgress";
|
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* Event for pressing a binded key <br>
|
|
206
|
-
* Data passed : {
|
|
207
|
-
* {
|
|
206
|
+
* Data passed : {string} user-defined action, {number} keyCode,
|
|
207
|
+
* {boolean} edge state <br>
|
|
208
208
|
* Edge-state is for detecting "locked" key bindings. When a locked key
|
|
209
209
|
* is pressed and held, the first event will have the third argument
|
|
210
210
|
* set true. Subsequent events will continue firing with the third
|
|
211
211
|
* argument set false.
|
|
212
212
|
* @public
|
|
213
213
|
* @constant
|
|
214
|
-
* @type
|
|
214
|
+
* @type {string}
|
|
215
215
|
* @name KEYDOWN
|
|
216
216
|
* @memberOf me.event
|
|
217
217
|
* @see me.event.on
|
|
@@ -234,10 +234,10 @@ export const KEYDOWN = "me.input.keydown";
|
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Event for releasing a binded key <br>
|
|
237
|
-
* Data passed : {
|
|
237
|
+
* Data passed : {string} user-defined action, {number} keyCode
|
|
238
238
|
* @public
|
|
239
239
|
* @constant
|
|
240
|
-
* @type
|
|
240
|
+
* @type {string}
|
|
241
241
|
* @name KEYUP
|
|
242
242
|
* @memberOf me.event
|
|
243
243
|
* @see me.event.on
|
|
@@ -258,10 +258,10 @@ export const KEYUP = "me.input.keyup";
|
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
* Event for when a gamepad is connected <br>
|
|
261
|
-
* Data passed : {
|
|
261
|
+
* Data passed : {object} gamepad object
|
|
262
262
|
* @public
|
|
263
263
|
* @constant
|
|
264
|
-
* @type
|
|
264
|
+
* @type {string}
|
|
265
265
|
* @name GAMEPAD_CONNECTED
|
|
266
266
|
* @memberOf me.event
|
|
267
267
|
* @see me.event.on
|
|
@@ -270,10 +270,10 @@ export const GAMEPAD_CONNECTED = "gamepad.connected";
|
|
|
270
270
|
|
|
271
271
|
/**
|
|
272
272
|
* Event for when a gamepad is disconnected <br>
|
|
273
|
-
* Data passed : {
|
|
273
|
+
* Data passed : {object} gamepad object
|
|
274
274
|
* @public
|
|
275
275
|
* @constant
|
|
276
|
-
* @type
|
|
276
|
+
* @type {string}
|
|
277
277
|
* @name GAMEPAD_DISCONNECTED
|
|
278
278
|
* @memberOf me.event
|
|
279
279
|
* @see me.event.on
|
|
@@ -282,14 +282,14 @@ export const GAMEPAD_DISCONNECTED = "gamepad.disconnected";
|
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
284
|
* Event for when gamepad button/axis state is updated <br>
|
|
285
|
-
* Data passed : {
|
|
286
|
-
* Data passed : {
|
|
287
|
-
* Data passed : {
|
|
288
|
-
* Data passed : {
|
|
289
|
-
* Data passed : {
|
|
285
|
+
* Data passed : {number} index <br>
|
|
286
|
+
* Data passed : {string} type : "axes" or "buttons" <br>
|
|
287
|
+
* Data passed : {number} button <br>
|
|
288
|
+
* Data passed : {number} current.value <br>
|
|
289
|
+
* Data passed : {boolean} current.pressed
|
|
290
290
|
* @public
|
|
291
291
|
* @constant
|
|
292
|
-
* @type
|
|
292
|
+
* @type {string}
|
|
293
293
|
* @name GAMEPAD_UPDATE
|
|
294
294
|
* @memberOf me.event
|
|
295
295
|
* @see me.event.on
|
|
@@ -301,7 +301,7 @@ export const GAMEPAD_UPDATE = "gamepad.update";
|
|
|
301
301
|
* Data passed : {me.Pointer} a Pointer object
|
|
302
302
|
* @public
|
|
303
303
|
* @constant
|
|
304
|
-
* @type
|
|
304
|
+
* @type {string}
|
|
305
305
|
* @name POINTERMOVE
|
|
306
306
|
* @memberOf me.event
|
|
307
307
|
* @see me.event.on
|
|
@@ -311,11 +311,11 @@ export const POINTERMOVE = "me.event.pointermove";
|
|
|
311
311
|
/**
|
|
312
312
|
* Event for dragstart events on a Draggable entity <br>
|
|
313
313
|
* Data passed:
|
|
314
|
-
* {
|
|
315
|
-
* {
|
|
314
|
+
* {object} the drag event <br>
|
|
315
|
+
* {object} the Draggable entity
|
|
316
316
|
* @public
|
|
317
317
|
* @constant
|
|
318
|
-
* @type
|
|
318
|
+
* @type {string}
|
|
319
319
|
* @name DRAGSTART
|
|
320
320
|
* @memberOf me.event
|
|
321
321
|
* @see me.event.on
|
|
@@ -325,11 +325,11 @@ export const DRAGSTART = "me.game.dragstart";
|
|
|
325
325
|
/**
|
|
326
326
|
* Event for dragend events on a Draggable entity <br>
|
|
327
327
|
* Data passed:
|
|
328
|
-
* {
|
|
329
|
-
* {
|
|
328
|
+
* {object} the drag event <br>
|
|
329
|
+
* {object} the Draggable entity
|
|
330
330
|
* @public
|
|
331
331
|
* @constant
|
|
332
|
-
* @type
|
|
332
|
+
* @type {string}
|
|
333
333
|
* @name DRAGEND
|
|
334
334
|
* @memberOf me.event
|
|
335
335
|
* @see me.event.on
|
|
@@ -341,7 +341,7 @@ export const DRAGEND = "me.game.dragend";
|
|
|
341
341
|
* Data passed : {Event} Event object
|
|
342
342
|
* @public
|
|
343
343
|
* @constant
|
|
344
|
-
* @type
|
|
344
|
+
* @type {string}
|
|
345
345
|
* @name WINDOW_ONRESIZE
|
|
346
346
|
* @memberOf me.event
|
|
347
347
|
* @see me.event.on
|
|
@@ -351,11 +351,11 @@ export const WINDOW_ONRESIZE = "window.onresize";
|
|
|
351
351
|
/**
|
|
352
352
|
* Event for when the canvas is resized <br>
|
|
353
353
|
* (this usually follows a WINDOW_ONRESIZE event).<br>
|
|
354
|
-
* Data passed : {
|
|
355
|
-
* Data passed : {
|
|
354
|
+
* Data passed : {number} canvas width <br>
|
|
355
|
+
* Data passed : {number} canvas height
|
|
356
356
|
* @public
|
|
357
357
|
* @constant
|
|
358
|
-
* @type
|
|
358
|
+
* @type {string}
|
|
359
359
|
* @name CANVAS_ONRESIZE
|
|
360
360
|
* @memberOf me.event
|
|
361
361
|
* @see me.event.on
|
|
@@ -365,11 +365,11 @@ export const CANVAS_ONRESIZE = "canvas.onresize";
|
|
|
365
365
|
/**
|
|
366
366
|
* Event for when the viewport is resized <br>
|
|
367
367
|
* (this usually follows a WINDOW_ONRESIZE event, when using the `flex` scaling mode is used and after the viewport was updated).<br>
|
|
368
|
-
* Data passed : {
|
|
369
|
-
* Data passed : {
|
|
368
|
+
* Data passed : {number} viewport width <br>
|
|
369
|
+
* Data passed : {number} viewport height
|
|
370
370
|
* @public
|
|
371
371
|
* @constant
|
|
372
|
-
* @type
|
|
372
|
+
* @type {string}
|
|
373
373
|
* @name VIEWPORT_ONRESIZE
|
|
374
374
|
* @memberOf me.event
|
|
375
375
|
* @see me.event.on
|
|
@@ -381,7 +381,7 @@ export const VIEWPORT_ONRESIZE = "viewport.onresize";
|
|
|
381
381
|
* Data passed : {Event} Event object <br>
|
|
382
382
|
* @public
|
|
383
383
|
* @constant
|
|
384
|
-
* @type
|
|
384
|
+
* @type {string}
|
|
385
385
|
* @name WINDOW_ONORIENTATION_CHANGE
|
|
386
386
|
* @memberOf me.event
|
|
387
387
|
* @see me.event.on
|
|
@@ -393,7 +393,7 @@ export const WINDOW_ONORIENTATION_CHANGE = "window.orientationchange";
|
|
|
393
393
|
* Data passed : {Event} Event object
|
|
394
394
|
* @public
|
|
395
395
|
* @constant
|
|
396
|
-
* @type
|
|
396
|
+
* @type {string}
|
|
397
397
|
* @name WINDOW_ONSCROLL
|
|
398
398
|
* @memberOf me.event
|
|
399
399
|
* @see me.event.on
|
|
@@ -405,7 +405,7 @@ export const WINDOW_ONSCROLL = "window.onscroll";
|
|
|
405
405
|
* Data passed : {me.Vector2d} viewport position vector
|
|
406
406
|
* @public
|
|
407
407
|
* @constant
|
|
408
|
-
* @type
|
|
408
|
+
* @type {string}
|
|
409
409
|
* @name VIEWPORT_ONCHANGE
|
|
410
410
|
* @memberOf me.event
|
|
411
411
|
* @see me.event.on
|
|
@@ -417,7 +417,7 @@ export const VIEWPORT_ONCHANGE = "viewport.onchange";
|
|
|
417
417
|
* Data passed : {me.WebGLRenderer} the current webgl renderer instance`
|
|
418
418
|
* @public
|
|
419
419
|
* @constant
|
|
420
|
-
* @type
|
|
420
|
+
* @type {string}
|
|
421
421
|
* @name WEBGL_ONCONTEXT_LOST
|
|
422
422
|
* @memberOf me.event
|
|
423
423
|
* @see me.event.on
|
|
@@ -429,7 +429,7 @@ export const WEBGL_ONCONTEXT_LOST = "renderer.webglcontextlost";
|
|
|
429
429
|
* Data passed : {me.WebGLRenderer} the current webgl renderer instance`
|
|
430
430
|
* @public
|
|
431
431
|
* @constant
|
|
432
|
-
* @type
|
|
432
|
+
* @type {string}
|
|
433
433
|
* @name WEBGL_ONCONTEXT_RESTORED
|
|
434
434
|
* @memberOf me.event
|
|
435
435
|
* @see me.event.on
|
|
@@ -439,9 +439,9 @@ export const WEBGL_ONCONTEXT_RESTORED = "renderer.webglcontextrestored";
|
|
|
439
439
|
/**
|
|
440
440
|
* calls each of the listeners registered for a given event.
|
|
441
441
|
* @function me.event.emit
|
|
442
|
-
* @param {
|
|
443
|
-
* @param {
|
|
444
|
-
* @
|
|
442
|
+
* @param {string|symbol} eventName The event name.
|
|
443
|
+
* @param {object} [...arguments] arguments to be passed to all listeners
|
|
444
|
+
* @returns {boolean} true if the event had listeners, false otherwise.
|
|
445
445
|
* @example
|
|
446
446
|
* me.event.emit("event-name", a, b, c);
|
|
447
447
|
*/
|
|
@@ -452,8 +452,8 @@ export function emit(eventName, ...args) {
|
|
|
452
452
|
/**
|
|
453
453
|
* Add a listener for a given event.
|
|
454
454
|
* @function me.event.on
|
|
455
|
-
* @param {
|
|
456
|
-
* @param {Function}
|
|
455
|
+
* @param {string|symbol} eventName The event name.
|
|
456
|
+
* @param {Function} listener The listener function.
|
|
457
457
|
* @param {*} [context=this] The context to invoke the listener with.
|
|
458
458
|
* @returns {EventEmitter} `this`.
|
|
459
459
|
* @public
|
|
@@ -467,8 +467,8 @@ export function on(eventName, listener, context) {
|
|
|
467
467
|
/**
|
|
468
468
|
* Add a one-time listener for a given event.
|
|
469
469
|
* @function me.event.once
|
|
470
|
-
* @param {
|
|
471
|
-
* @param {Function}
|
|
470
|
+
* @param {string|symbol} eventName The event name.
|
|
471
|
+
* @param {Function} listener The listener function.
|
|
472
472
|
* @param {*} [context=this] The context to invoke the listener with.
|
|
473
473
|
* @returns {EventEmitter} `this`.
|
|
474
474
|
* @public
|
|
@@ -482,8 +482,8 @@ export function once(eventName, listener, context) {
|
|
|
482
482
|
/**
|
|
483
483
|
* remove the given listener for a given event.
|
|
484
484
|
* @function me.event.off
|
|
485
|
-
* @param {
|
|
486
|
-
* @param {Function}
|
|
485
|
+
* @param {string|symbol} eventName The event name.
|
|
486
|
+
* @param {Function} listener The listener function.
|
|
487
487
|
* @returns {EventEmitter} `this`.
|
|
488
488
|
* @public
|
|
489
489
|
* @example
|
package/src/system/pooling.js
CHANGED
|
@@ -23,9 +23,9 @@ var pool = {
|
|
|
23
23
|
* Pooling must be set to true if more than one such objects will be created. <br>
|
|
24
24
|
* (Note: for an object to be poolable, it must implements a `onResetEvent` method)
|
|
25
25
|
* @function me.pool.register
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
26
|
+
* @param {string} className as defined in the Name field of the Object Properties (in Tiled)
|
|
27
|
+
* @param {object} classObj corresponding Class to be instantiated
|
|
28
|
+
* @param {boolean} [recycling=false] enables object recycling for the specified class
|
|
29
29
|
* @example
|
|
30
30
|
* // implement CherryEntity
|
|
31
31
|
* class CherryEntity extends Spritesheet {
|
|
@@ -51,9 +51,9 @@ var pool = {
|
|
|
51
51
|
/**
|
|
52
52
|
* Pull a new instance of the requested object (if added into the object pool)
|
|
53
53
|
* @function me.pool.pull
|
|
54
|
-
* @param {
|
|
55
|
-
* @param {} [arguments
|
|
56
|
-
* @
|
|
54
|
+
* @param {string} name as used in {@link me.pool.register}
|
|
55
|
+
* @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
|
|
56
|
+
* @returns {object} the instance of the requested object
|
|
57
57
|
* @example
|
|
58
58
|
* me.pool.register("bullet", BulletEntity, true);
|
|
59
59
|
* me.pool.register("enemy", EnemyEntity, true);
|
|
@@ -125,9 +125,9 @@ var pool = {
|
|
|
125
125
|
* otherwise this function won't work
|
|
126
126
|
* @function me.pool.push
|
|
127
127
|
* @throws will throw an error if the object cannot be recycled
|
|
128
|
-
* @param {
|
|
129
|
-
* @param {
|
|
130
|
-
* @
|
|
128
|
+
* @param {object} obj instance to be recycled
|
|
129
|
+
* @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
|
|
130
|
+
* @returns {boolean} true if the object was successfully recycled in the object pool
|
|
131
131
|
*/
|
|
132
132
|
push(obj, throwOnError = true) {
|
|
133
133
|
if (!this.poolable(obj)) {
|
|
@@ -148,8 +148,8 @@ var pool = {
|
|
|
148
148
|
/**
|
|
149
149
|
* Check if an object with the provided name is registered
|
|
150
150
|
* @function me.pool.exists
|
|
151
|
-
* @param {
|
|
152
|
-
* @
|
|
151
|
+
* @param {string} name of the registered object class
|
|
152
|
+
* @returns {boolean} true if the classname is registered
|
|
153
153
|
*/
|
|
154
154
|
exists(name) {
|
|
155
155
|
return name in objectClass;
|
|
@@ -160,8 +160,8 @@ var pool = {
|
|
|
160
160
|
* (was properly registered with the recycling feature enable)
|
|
161
161
|
* @function me.pool.poolable
|
|
162
162
|
* @see me.pool.register
|
|
163
|
-
* @param {
|
|
164
|
-
* @
|
|
163
|
+
* @param {object} obj object to be checked
|
|
164
|
+
* @returns {boolean} true if the object is poolable
|
|
165
165
|
* @example
|
|
166
166
|
* if (!me.pool.poolable(myCherryEntity)) {
|
|
167
167
|
* // object was not properly registered
|
|
@@ -179,7 +179,7 @@ var pool = {
|
|
|
179
179
|
/**
|
|
180
180
|
* returns the amount of object instance currently in the pool
|
|
181
181
|
* @function me.pool.getInstanceCount
|
|
182
|
-
* @
|
|
182
|
+
* @returns {number} amount of object instance
|
|
183
183
|
*/
|
|
184
184
|
getInstanceCount() {
|
|
185
185
|
return instance_counter;
|
package/src/system/save.js
CHANGED
|
@@ -36,7 +36,10 @@ import * as event from "./../system/event.js";
|
|
|
36
36
|
// Variable to hold the object data
|
|
37
37
|
var data = {};
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* a function to check if the given key is a reserved word
|
|
41
|
+
* @ignore
|
|
42
|
+
*/
|
|
40
43
|
function isReserved(key) {
|
|
41
44
|
return (key === "add" || key === "remove");
|
|
42
45
|
}
|
|
@@ -64,7 +67,7 @@ var save = {
|
|
|
64
67
|
* @name add
|
|
65
68
|
* @memberOf me.save
|
|
66
69
|
* @function
|
|
67
|
-
* @param {
|
|
70
|
+
* @param {object} props key and corresponding values
|
|
68
71
|
* @example
|
|
69
72
|
* // Initialize "score" and "lives" with default values
|
|
70
73
|
* me.save.add({ score : 0, lives : 3 });
|
|
@@ -118,7 +121,7 @@ var save = {
|
|
|
118
121
|
* @name remove
|
|
119
122
|
* @memberOf me.save
|
|
120
123
|
* @function
|
|
121
|
-
* @param {
|
|
124
|
+
* @param {string} key key to be removed
|
|
122
125
|
* @example
|
|
123
126
|
* // Remove the "score" key from localStorage
|
|
124
127
|
* me.save.remove("score");
|
package/src/system/timer.js
CHANGED
|
@@ -100,7 +100,7 @@ var timer = {
|
|
|
100
100
|
* use it.
|
|
101
101
|
* @public
|
|
102
102
|
* @see me.timer.interpolation
|
|
103
|
-
* @type {
|
|
103
|
+
* @type {number}
|
|
104
104
|
* @name tick
|
|
105
105
|
* @memberOf me.timer
|
|
106
106
|
*/
|
|
@@ -110,7 +110,7 @@ var timer = {
|
|
|
110
110
|
* Last measured fps rate.<br/>
|
|
111
111
|
* This feature is disabled by default, unless the debugPanel is enabled/visible
|
|
112
112
|
* @public
|
|
113
|
-
* @type {
|
|
113
|
+
* @type {number}
|
|
114
114
|
* @name fps
|
|
115
115
|
* @memberOf me.timer
|
|
116
116
|
*/
|
|
@@ -120,7 +120,7 @@ var timer = {
|
|
|
120
120
|
* Set the maximum target display frame per second
|
|
121
121
|
* @public
|
|
122
122
|
* @see me.timer.tick
|
|
123
|
-
* @type {
|
|
123
|
+
* @type {number}
|
|
124
124
|
* @name maxfps
|
|
125
125
|
* @default 60
|
|
126
126
|
* @memberOf me.timer
|
|
@@ -130,7 +130,7 @@ var timer = {
|
|
|
130
130
|
/**
|
|
131
131
|
* Enable/disable frame interpolation
|
|
132
132
|
* @see me.timer.tick
|
|
133
|
-
* @type {
|
|
133
|
+
* @type {boolean}
|
|
134
134
|
* @default false
|
|
135
135
|
* @name interpolation
|
|
136
136
|
* @memberOf me.timer
|
|
@@ -161,10 +161,10 @@ var timer = {
|
|
|
161
161
|
* @name setTimeout
|
|
162
162
|
* @memberOf me.timer
|
|
163
163
|
* @param {Function} fn the function you want to execute after delay milliseconds.
|
|
164
|
-
* @param {
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {
|
|
167
|
-
* @
|
|
164
|
+
* @param {number} delay the number of milliseconds (thousandths of a second) that the function call should be delayed by.
|
|
165
|
+
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
166
|
+
* @param {object} [args] optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
167
|
+
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearTimeout().
|
|
168
168
|
* @function
|
|
169
169
|
* @example
|
|
170
170
|
* // set a timer to call "myFunction" after 1000ms
|
|
@@ -172,7 +172,7 @@ var timer = {
|
|
|
172
172
|
* // set a timer to call "myFunction" after 1000ms (respecting the pause state) and passing param1 and param2
|
|
173
173
|
* me.timer.setTimeout(myFunction, 1000, true, param1, param2);
|
|
174
174
|
*/
|
|
175
|
-
setTimeout(fn, delay, pauseable) {
|
|
175
|
+
setTimeout(fn, delay, pauseable, ...args) {
|
|
176
176
|
timers.push({
|
|
177
177
|
fn : fn,
|
|
178
178
|
delay : delay,
|
|
@@ -180,7 +180,7 @@ var timer = {
|
|
|
180
180
|
repeat : false,
|
|
181
181
|
timerId : ++timerId,
|
|
182
182
|
pauseable : pauseable === true || true,
|
|
183
|
-
args :
|
|
183
|
+
args : args
|
|
184
184
|
});
|
|
185
185
|
return timerId;
|
|
186
186
|
},
|
|
@@ -190,10 +190,10 @@ var timer = {
|
|
|
190
190
|
* @name setInterval
|
|
191
191
|
* @memberOf me.timer
|
|
192
192
|
* @param {Function} fn the function to execute
|
|
193
|
-
* @param {
|
|
194
|
-
* @param {
|
|
195
|
-
* @param {
|
|
196
|
-
* @
|
|
193
|
+
* @param {number} delay the number of milliseconds (thousandths of a second) on how often to execute the function
|
|
194
|
+
* @param {boolean} [pauseable=true] respects the pause state of the engine.
|
|
195
|
+
* @param {object} [args] optional parameters which are passed through to the function specified by fn once the timer expires.
|
|
196
|
+
* @returns {number} The numerical ID of the timer, which can be used later with me.timer.clearInterval().
|
|
197
197
|
* @function
|
|
198
198
|
* @example
|
|
199
199
|
* // set a timer to call "myFunction" every 1000ms
|
|
@@ -201,7 +201,7 @@ var timer = {
|
|
|
201
201
|
* // set a timer to call "myFunction" every 1000ms (respecting the pause state) and passing param1 and param2
|
|
202
202
|
* me.timer.setInterval(myFunction, 1000, true, param1, param2);
|
|
203
203
|
*/
|
|
204
|
-
setInterval(fn, delay, pauseable) {
|
|
204
|
+
setInterval(fn, delay, pauseable, ...args) {
|
|
205
205
|
timers.push({
|
|
206
206
|
fn : fn,
|
|
207
207
|
delay : delay,
|
|
@@ -209,7 +209,7 @@ var timer = {
|
|
|
209
209
|
repeat : true,
|
|
210
210
|
timerId : ++timerId,
|
|
211
211
|
pauseable : pauseable === true || true,
|
|
212
|
-
args :
|
|
212
|
+
args : args
|
|
213
213
|
});
|
|
214
214
|
return timerId;
|
|
215
215
|
},
|
|
@@ -219,7 +219,7 @@ var timer = {
|
|
|
219
219
|
* @name clearTimeout
|
|
220
220
|
* @memberOf me.timer
|
|
221
221
|
* @function
|
|
222
|
-
* @param {
|
|
222
|
+
* @param {number} timeoutID ID of the timeout to be cleared
|
|
223
223
|
*/
|
|
224
224
|
clearTimeout(timeoutID) {
|
|
225
225
|
utils.function.defer(clearTimer, this, timeoutID);
|
|
@@ -230,7 +230,7 @@ var timer = {
|
|
|
230
230
|
* @name clearInterval
|
|
231
231
|
* @memberOf me.timer
|
|
232
232
|
* @function
|
|
233
|
-
* @param {
|
|
233
|
+
* @param {number} intervalID ID of the interval to be cleared
|
|
234
234
|
*/
|
|
235
235
|
clearInterval(intervalID) {
|
|
236
236
|
utils.function.defer(clearTimer, this, intervalID);
|
|
@@ -241,7 +241,7 @@ var timer = {
|
|
|
241
241
|
* since the game has started or since linux epoch (based on browser support for High Resolution Timer)
|
|
242
242
|
* @name getTime
|
|
243
243
|
* @memberOf me.timer
|
|
244
|
-
* @
|
|
244
|
+
* @returns {number}
|
|
245
245
|
* @function
|
|
246
246
|
*/
|
|
247
247
|
getTime() {
|
|
@@ -252,7 +252,7 @@ var timer = {
|
|
|
252
252
|
* Return elapsed time in milliseconds since the last update
|
|
253
253
|
* @name getDelta
|
|
254
254
|
* @memberOf me.timer
|
|
255
|
-
* @
|
|
255
|
+
* @returns {number}
|
|
256
256
|
* @function
|
|
257
257
|
*/
|
|
258
258
|
getDelta() {
|