melonjs 10.2.0 → 10.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 +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/math/matrix2.js
CHANGED
|
@@ -7,10 +7,9 @@ import Matrix3d from "./matrix3.js";
|
|
|
7
7
|
* the identity matrix and parameters position : <br>
|
|
8
8
|
* <img src="images/identity-matrix_2x.png"/>
|
|
9
9
|
* @class Matrix2d
|
|
10
|
-
* @
|
|
11
|
-
* @constructor
|
|
10
|
+
* @memberof me
|
|
12
11
|
* @param {me.Matrix2d} [mat2d] An instance of me.Matrix2d to copy from
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix2d.setTransform}
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
15
|
class Matrix2d {
|
|
@@ -45,11 +44,11 @@ class Matrix2d {
|
|
|
45
44
|
/**
|
|
46
45
|
* tx component of the matrix
|
|
47
46
|
* @public
|
|
48
|
-
* @type {
|
|
47
|
+
* @type {number}
|
|
49
48
|
* @readonly
|
|
50
49
|
* @see me.Matrix2d.translate
|
|
51
50
|
* @name tx
|
|
52
|
-
* @
|
|
51
|
+
* @memberof me.Matrix2d
|
|
53
52
|
*/
|
|
54
53
|
get tx() {
|
|
55
54
|
return this.val[6];
|
|
@@ -58,11 +57,11 @@ class Matrix2d {
|
|
|
58
57
|
/**
|
|
59
58
|
* ty component of the matrix
|
|
60
59
|
* @public
|
|
61
|
-
* @type {
|
|
60
|
+
* @type {number}
|
|
62
61
|
* @readonly
|
|
63
62
|
* @see me.Matrix2d.translate
|
|
64
63
|
* @name ty
|
|
65
|
-
* @
|
|
64
|
+
* @memberof me.Matrix2d
|
|
66
65
|
*/
|
|
67
66
|
get ty() {
|
|
68
67
|
return this.val[7];
|
|
@@ -73,9 +72,9 @@ class Matrix2d {
|
|
|
73
72
|
* the identity matrix and parameters position : <br>
|
|
74
73
|
* <img src="images/identity-matrix_2x.png"/>
|
|
75
74
|
* @name identity
|
|
76
|
-
* @
|
|
75
|
+
* @memberof me.Matrix2d
|
|
77
76
|
* @function
|
|
78
|
-
* @
|
|
77
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
79
78
|
*/
|
|
80
79
|
identity() {
|
|
81
80
|
this.setTransform(
|
|
@@ -89,18 +88,18 @@ class Matrix2d {
|
|
|
89
88
|
/**
|
|
90
89
|
* set the matrix to the specified value
|
|
91
90
|
* @name setTransform
|
|
92
|
-
* @
|
|
91
|
+
* @memberof me.Matrix2d
|
|
93
92
|
* @function
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {
|
|
96
|
-
* @param {
|
|
97
|
-
* @param {
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {
|
|
100
|
-
* @param {
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
103
|
-
* @
|
|
93
|
+
* @param {number} a
|
|
94
|
+
* @param {number} b
|
|
95
|
+
* @param {number} c
|
|
96
|
+
* @param {number} d
|
|
97
|
+
* @param {number} e
|
|
98
|
+
* @param {number} f
|
|
99
|
+
* @param {number} [g=0]
|
|
100
|
+
* @param {number} [h=0]
|
|
101
|
+
* @param {number} [i=1]
|
|
102
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
104
103
|
*/
|
|
105
104
|
setTransform() {
|
|
106
105
|
var a = this.val;
|
|
@@ -133,23 +132,23 @@ class Matrix2d {
|
|
|
133
132
|
/**
|
|
134
133
|
* Copies over the values from another me.Matrix2d.
|
|
135
134
|
* @name copy
|
|
136
|
-
* @
|
|
135
|
+
* @memberof me.Matrix2d
|
|
137
136
|
* @function
|
|
138
137
|
* @param {me.Matrix2d} m the matrix object to copy from
|
|
139
|
-
* @
|
|
138
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
140
139
|
*/
|
|
141
|
-
copy(
|
|
142
|
-
this.val.set(
|
|
140
|
+
copy(m) {
|
|
141
|
+
this.val.set(m.val);
|
|
143
142
|
return this;
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
/**
|
|
147
146
|
* Copies over the upper-left 3x3 values from the given me.Matrix3d
|
|
148
147
|
* @name fromMat3d
|
|
149
|
-
* @
|
|
148
|
+
* @memberof me.Matrix2d
|
|
150
149
|
* @function
|
|
151
150
|
* @param {me.Matrix3d} m the matrix object to copy from
|
|
152
|
-
* @
|
|
151
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
153
152
|
*/
|
|
154
153
|
fromMat3d(m) {
|
|
155
154
|
var b = m.val;
|
|
@@ -171,10 +170,10 @@ class Matrix2d {
|
|
|
171
170
|
/**
|
|
172
171
|
* multiply both matrix
|
|
173
172
|
* @name multiply
|
|
174
|
-
* @
|
|
173
|
+
* @memberof me.Matrix2d
|
|
175
174
|
* @function
|
|
176
175
|
* @param {me.Matrix2d} m the other matrix
|
|
177
|
-
* @
|
|
176
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
178
177
|
*/
|
|
179
178
|
multiply(m) {
|
|
180
179
|
var b = m.val;
|
|
@@ -203,9 +202,9 @@ class Matrix2d {
|
|
|
203
202
|
/**
|
|
204
203
|
* Transpose the value of this matrix.
|
|
205
204
|
* @name transpose
|
|
206
|
-
* @
|
|
205
|
+
* @memberof me.Matrix2d
|
|
207
206
|
* @function
|
|
208
|
-
* @
|
|
207
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
209
208
|
*/
|
|
210
209
|
transpose() {
|
|
211
210
|
var a = this.val,
|
|
@@ -226,9 +225,9 @@ class Matrix2d {
|
|
|
226
225
|
/**
|
|
227
226
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
228
227
|
* @name invert
|
|
229
|
-
* @
|
|
228
|
+
* @memberof me.Matrix2d
|
|
230
229
|
* @function
|
|
231
|
-
* @
|
|
230
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
232
231
|
*/
|
|
233
232
|
invert() {
|
|
234
233
|
var val = this.val;
|
|
@@ -261,10 +260,10 @@ class Matrix2d {
|
|
|
261
260
|
/**
|
|
262
261
|
* apply the current transform to the given 2d vector
|
|
263
262
|
* @name apply
|
|
264
|
-
* @
|
|
263
|
+
* @memberof me.Matrix2d
|
|
265
264
|
* @function
|
|
266
|
-
* @param {me.Vector2d}
|
|
267
|
-
* @
|
|
265
|
+
* @param {me.Vector2d} v the vector object to be transformed
|
|
266
|
+
* @returns {me.Vector2d} result vector object.
|
|
268
267
|
*/
|
|
269
268
|
apply(v) {
|
|
270
269
|
var a = this.val,
|
|
@@ -280,10 +279,10 @@ class Matrix2d {
|
|
|
280
279
|
/**
|
|
281
280
|
* apply the inverted current transform to the given 2d vector
|
|
282
281
|
* @name applyInverse
|
|
283
|
-
* @
|
|
282
|
+
* @memberof me.Matrix2d
|
|
284
283
|
* @function
|
|
285
|
-
* @param {me.Vector2d}
|
|
286
|
-
* @
|
|
284
|
+
* @param {me.Vector2d} v the vector object to be transformed
|
|
285
|
+
* @returns {me.Vector2d} result vector object.
|
|
287
286
|
*/
|
|
288
287
|
applyInverse(v) {
|
|
289
288
|
var a = this.val,
|
|
@@ -301,11 +300,11 @@ class Matrix2d {
|
|
|
301
300
|
/**
|
|
302
301
|
* scale the matrix
|
|
303
302
|
* @name scale
|
|
304
|
-
* @
|
|
303
|
+
* @memberof me.Matrix2d
|
|
305
304
|
* @function
|
|
306
|
-
* @param {
|
|
307
|
-
* @param {
|
|
308
|
-
* @
|
|
305
|
+
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
306
|
+
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
307
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
309
308
|
*/
|
|
310
309
|
scale(x, y) {
|
|
311
310
|
var a = this.val,
|
|
@@ -323,10 +322,10 @@ class Matrix2d {
|
|
|
323
322
|
/**
|
|
324
323
|
* adds a 2D scaling transformation.
|
|
325
324
|
* @name scaleV
|
|
326
|
-
* @
|
|
325
|
+
* @memberof me.Matrix2d
|
|
327
326
|
* @function
|
|
328
|
-
* @param {me.Vector2d}
|
|
329
|
-
* @
|
|
327
|
+
* @param {me.Vector2d} v scaling vector
|
|
328
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
330
329
|
*/
|
|
331
330
|
scaleV(v) {
|
|
332
331
|
return this.scale(v.x, v.y);
|
|
@@ -335,10 +334,10 @@ class Matrix2d {
|
|
|
335
334
|
/**
|
|
336
335
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
337
336
|
* @name scaleX
|
|
338
|
-
* @
|
|
337
|
+
* @memberof me.Matrix2d
|
|
339
338
|
* @function
|
|
340
|
-
* @param {
|
|
341
|
-
* @
|
|
339
|
+
* @param {number} x x scaling vector
|
|
340
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
342
341
|
*/
|
|
343
342
|
scaleX(x) {
|
|
344
343
|
return this.scale(x, 1);
|
|
@@ -347,10 +346,10 @@ class Matrix2d {
|
|
|
347
346
|
/**
|
|
348
347
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
349
348
|
* @name scaleY
|
|
350
|
-
* @
|
|
349
|
+
* @memberof me.Matrix2d
|
|
351
350
|
* @function
|
|
352
|
-
* @param {
|
|
353
|
-
* @
|
|
351
|
+
* @param {number} y y scaling vector
|
|
352
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
354
353
|
*/
|
|
355
354
|
scaleY(y) {
|
|
356
355
|
return this.scale(1, y);
|
|
@@ -359,10 +358,10 @@ class Matrix2d {
|
|
|
359
358
|
/**
|
|
360
359
|
* rotate the matrix (counter-clockwise) by the specified angle (in radians).
|
|
361
360
|
* @name rotate
|
|
362
|
-
* @
|
|
361
|
+
* @memberof me.Matrix2d
|
|
363
362
|
* @function
|
|
364
|
-
* @param {
|
|
365
|
-
* @
|
|
363
|
+
* @param {number} angle Rotation angle in radians.
|
|
364
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
366
365
|
*/
|
|
367
366
|
rotate(angle) {
|
|
368
367
|
if (angle !== 0) {
|
|
@@ -390,19 +389,19 @@ class Matrix2d {
|
|
|
390
389
|
/**
|
|
391
390
|
* translate the matrix position on the horizontal and vertical axis
|
|
392
391
|
* @name translate
|
|
393
|
-
* @
|
|
392
|
+
* @memberof me.Matrix2d
|
|
394
393
|
* @function
|
|
395
|
-
* @param {
|
|
396
|
-
* @param {
|
|
397
|
-
* @
|
|
394
|
+
* @param {number} x the x coordindates to translate the matrix by
|
|
395
|
+
* @param {number} y the y coordindates to translate the matrix by
|
|
396
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
398
397
|
*/
|
|
399
398
|
/**
|
|
400
399
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
401
400
|
* @name translateV
|
|
402
|
-
* @
|
|
401
|
+
* @memberof me.Matrix2d
|
|
403
402
|
* @function
|
|
404
403
|
* @param {me.Vector2d} v the vector to translate the matrix by
|
|
405
|
-
* @
|
|
404
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
406
405
|
*/
|
|
407
406
|
translate() {
|
|
408
407
|
var a = this.val;
|
|
@@ -427,10 +426,10 @@ class Matrix2d {
|
|
|
427
426
|
/**
|
|
428
427
|
* returns true if the matrix is an identity matrix.
|
|
429
428
|
* @name isIdentity
|
|
430
|
-
* @
|
|
429
|
+
* @memberof me.Matrix2d
|
|
431
430
|
* @function
|
|
432
|
-
* @
|
|
433
|
-
|
|
431
|
+
* @returns {boolean}
|
|
432
|
+
*/
|
|
434
433
|
isIdentity() {
|
|
435
434
|
var a = this.val;
|
|
436
435
|
|
|
@@ -450,10 +449,10 @@ class Matrix2d {
|
|
|
450
449
|
/**
|
|
451
450
|
* return true if the two matrices are identical
|
|
452
451
|
* @name equals
|
|
453
|
-
* @
|
|
452
|
+
* @memberof me.Matrix2d
|
|
454
453
|
* @function
|
|
455
454
|
* @param {me.Matrix2d} m the other matrix
|
|
456
|
-
* @
|
|
455
|
+
* @returns {boolean} true if both are equals
|
|
457
456
|
*/
|
|
458
457
|
equals(m) {
|
|
459
458
|
var b = m.val;
|
|
@@ -475,9 +474,9 @@ class Matrix2d {
|
|
|
475
474
|
/**
|
|
476
475
|
* Clone the Matrix
|
|
477
476
|
* @name clone
|
|
478
|
-
* @
|
|
477
|
+
* @memberof me.Matrix2d
|
|
479
478
|
* @function
|
|
480
|
-
* @
|
|
479
|
+
* @returns {me.Matrix2d}
|
|
481
480
|
*/
|
|
482
481
|
clone() {
|
|
483
482
|
return pool.pull("Matrix2d", this);
|
|
@@ -486,9 +485,9 @@ class Matrix2d {
|
|
|
486
485
|
/**
|
|
487
486
|
* return an array representation of this Matrix
|
|
488
487
|
* @name toArray
|
|
489
|
-
* @
|
|
488
|
+
* @memberof me.Matrix2d
|
|
490
489
|
* @function
|
|
491
|
-
* @
|
|
490
|
+
* @returns {Float32Array}
|
|
492
491
|
*/
|
|
493
492
|
toArray() {
|
|
494
493
|
return this.val;
|
|
@@ -497,9 +496,9 @@ class Matrix2d {
|
|
|
497
496
|
/**
|
|
498
497
|
* convert the object to a string representation
|
|
499
498
|
* @name toString
|
|
500
|
-
* @
|
|
499
|
+
* @memberof me.Matrix2d
|
|
501
500
|
* @function
|
|
502
|
-
* @
|
|
501
|
+
* @returns {string}
|
|
503
502
|
*/
|
|
504
503
|
toString() {
|
|
505
504
|
var a = this.val;
|