melonjs 10.11.0 → 10.12.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/dist/melonjs.js +151 -121
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +197 -111
- package/dist/melonjs.module.js +147 -123
- package/package.json +7 -7
- package/src/entity/entity.js +5 -7
- package/src/geometries/ellipse.js +1 -1
- package/src/geometries/path2d.js +4 -4
- package/src/geometries/poly.js +1 -2
- package/src/geometries/rectangle.js +1 -1
- package/src/physics/body.js +3 -4
- package/src/physics/collision.js +1 -12
- package/src/physics/detector.js +6 -52
- package/src/physics/response.js +48 -0
- package/src/physics/sat.js +1 -1
- package/src/renderable/GUI.js +6 -4
- package/src/renderable/colorlayer.js +9 -7
- package/src/renderable/container.js +12 -10
- package/src/renderable/dragndrop.js +1 -1
- package/src/renderable/imagelayer.js +5 -5
- package/src/renderable/light2d.js +7 -3
- package/src/renderable/renderable.js +6 -6
- package/src/renderable/sprite.js +4 -4
- package/src/renderable/trigger.js +9 -2
- package/src/state/state.js +19 -3
- package/src/system/pooling.js +1 -1
- package/src/text/text.js +6 -3
- package/src/video/texture/atlas.js +2 -0
package/dist/melonjs.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
2
|
+
* melonJS Game Engine - v10.12.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -309,10 +309,10 @@ var store$2 = sharedStore;
|
|
|
309
309
|
(shared$3.exports = function (key, value) {
|
|
310
310
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
311
311
|
})('versions', []).push({
|
|
312
|
-
version: '3.23.
|
|
312
|
+
version: '3.23.1',
|
|
313
313
|
mode: 'global',
|
|
314
314
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
315
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.23.
|
|
315
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.23.1/LICENSE',
|
|
316
316
|
source: 'https://github.com/zloirock/core-js'
|
|
317
317
|
});
|
|
318
318
|
|
|
@@ -1737,7 +1737,7 @@ class ObjectPool {
|
|
|
1737
1737
|
return (typeof className !== "undefined") &&
|
|
1738
1738
|
(typeof obj.onResetEvent === "function") &&
|
|
1739
1739
|
(className in this.objectClass) &&
|
|
1740
|
-
(this.objectClass[className].pool !== "undefined");
|
|
1740
|
+
(typeof this.objectClass[className].pool !== "undefined");
|
|
1741
1741
|
|
|
1742
1742
|
}
|
|
1743
1743
|
|
|
@@ -10291,10 +10291,9 @@ earcut.flatten = function (data) {
|
|
|
10291
10291
|
* (which means that all angles are less than 180 degrees), as described here below : <br>
|
|
10292
10292
|
* <center><img src="images/convex_polygon.png"/></center><br>
|
|
10293
10293
|
*
|
|
10294
|
-
* A polygon's `winding` is clockwise
|
|
10294
|
+
* A polygon's `winding` is clockwise if its vertices (points) are declared turning to the right. The image above shows COUNTERCLOCKWISE winding.
|
|
10295
10295
|
*/
|
|
10296
10296
|
class Polygon {
|
|
10297
|
-
|
|
10298
10297
|
/**
|
|
10299
10298
|
* @param {number} x origin point of the Polygon
|
|
10300
10299
|
* @param {number} y origin point of the Polygon
|
|
@@ -10944,7 +10943,7 @@ class Rect extends Polygon {
|
|
|
10944
10943
|
* @name centerOn
|
|
10945
10944
|
* @memberof Rect
|
|
10946
10945
|
* @param {number} x the x coordinate around which to center this rectangle
|
|
10947
|
-
* @param {number}
|
|
10946
|
+
* @param {number} y the y coordinate around which to center this rectangle
|
|
10948
10947
|
* @returns {Rect} this rectangle
|
|
10949
10948
|
*/
|
|
10950
10949
|
centerOn(x, y) {
|
|
@@ -14456,14 +14455,14 @@ class Renderable extends Rect {
|
|
|
14456
14455
|
}
|
|
14457
14456
|
|
|
14458
14457
|
/**
|
|
14459
|
-
*
|
|
14460
|
-
* automatically called by the game manager {@link game}
|
|
14458
|
+
* draw this renderable (automatically called by melonJS)
|
|
14461
14459
|
* @name draw
|
|
14462
14460
|
* @memberof Renderable
|
|
14463
14461
|
* @protected
|
|
14464
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
14462
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
14463
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
14465
14464
|
*/
|
|
14466
|
-
draw(renderer) { // eslint-disable-line no-unused-vars
|
|
14465
|
+
draw(renderer, viewport) { // eslint-disable-line no-unused-vars
|
|
14467
14466
|
// empty one !
|
|
14468
14467
|
}
|
|
14469
14468
|
|
|
@@ -14496,7 +14495,7 @@ class Renderable extends Rect {
|
|
|
14496
14495
|
* when this renderable body is colliding with another one
|
|
14497
14496
|
* @name onCollision
|
|
14498
14497
|
* @memberof Renderable
|
|
14499
|
-
* @param {
|
|
14498
|
+
* @param {ResponseObject} response the collision response object
|
|
14500
14499
|
* @param {Renderable} other the other renderable touching this one (a reference to response.a or response.b)
|
|
14501
14500
|
* @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
|
|
14502
14501
|
* @example
|
|
@@ -14513,7 +14512,7 @@ class Renderable extends Rect {
|
|
|
14513
14512
|
* return true;
|
|
14514
14513
|
* },
|
|
14515
14514
|
*/
|
|
14516
|
-
onCollision() {
|
|
14515
|
+
onCollision(response, other) { // eslint-disable-line no-unused-vars
|
|
14517
14516
|
return false;
|
|
14518
14517
|
}
|
|
14519
14518
|
|
|
@@ -14733,7 +14732,7 @@ class Ellipse {
|
|
|
14733
14732
|
* @param {Matrix2d} matrix the transformation matrix
|
|
14734
14733
|
* @returns {Polygon} Reference to this object for method chaining
|
|
14735
14734
|
*/
|
|
14736
|
-
transform(
|
|
14735
|
+
transform(matrix) { // eslint-disable-line no-unused-vars
|
|
14737
14736
|
// TODO
|
|
14738
14737
|
return this;
|
|
14739
14738
|
}
|
|
@@ -15301,7 +15300,7 @@ function testPolygonEllipse(a, polyA, b, ellipseB, response) {
|
|
|
15301
15300
|
*/
|
|
15302
15301
|
function testEllipsePolygon(a, ellipseA, b, polyB, response) {
|
|
15303
15302
|
// Test the polygon against the circle.
|
|
15304
|
-
var result =
|
|
15303
|
+
var result = testPolygonEllipse(b, polyB, a, ellipseA, response);
|
|
15305
15304
|
if (result && response) {
|
|
15306
15305
|
// Swap A and B in the response.
|
|
15307
15306
|
var resa = response.a;
|
|
@@ -15324,36 +15323,6 @@ var SAT = /*#__PURE__*/Object.freeze({
|
|
|
15324
15323
|
testEllipsePolygon: testEllipsePolygon
|
|
15325
15324
|
});
|
|
15326
15325
|
|
|
15327
|
-
// a dummy object when using Line for raycasting
|
|
15328
|
-
var dummyObj = {
|
|
15329
|
-
pos : new Vector2d(0, 0),
|
|
15330
|
-
ancestor : {
|
|
15331
|
-
_absPos : new Vector2d(0, 0),
|
|
15332
|
-
getAbsolutePosition : function () {
|
|
15333
|
-
return this._absPos;
|
|
15334
|
-
}
|
|
15335
|
-
}
|
|
15336
|
-
};
|
|
15337
|
-
|
|
15338
|
-
/**
|
|
15339
|
-
* a function used to determine if two objects should collide (based on both respective objects collision mask and type).<br>
|
|
15340
|
-
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
15341
|
-
* @name shouldCollide
|
|
15342
|
-
* @memberof collision
|
|
15343
|
-
* @ignore
|
|
15344
|
-
* @param {Renderable} a a reference to the object A.
|
|
15345
|
-
* @param {Renderable} b a reference to the object B.
|
|
15346
|
-
* @returns {boolean} true if they should collide, false otherwise
|
|
15347
|
-
*/
|
|
15348
|
-
function shouldCollide(a, b) {
|
|
15349
|
-
return (
|
|
15350
|
-
a.isKinematic !== true && b.isKinematic !== true &&
|
|
15351
|
-
typeof a.body === "object" && typeof b.body === "object" &&
|
|
15352
|
-
!(a.body.isStatic === true && b.body.isStatic === true) &&
|
|
15353
|
-
(a.body.collisionMask & b.body.collisionType) !== 0 &&
|
|
15354
|
-
(a.body.collisionType & b.body.collisionMask) !== 0
|
|
15355
|
-
);
|
|
15356
|
-
}
|
|
15357
15326
|
/**
|
|
15358
15327
|
* @classdesc
|
|
15359
15328
|
* An object representing the result of an intersection.
|
|
@@ -15367,7 +15336,6 @@ function shouldCollide(a, b) {
|
|
|
15367
15336
|
* @property {number} indexShapeA The index of the colliding shape for the object a body
|
|
15368
15337
|
* @property {number} indexShapeB The index of the colliding shape for the object b body
|
|
15369
15338
|
* @name ResponseObject
|
|
15370
|
-
* @memberof collision
|
|
15371
15339
|
* @public
|
|
15372
15340
|
*/
|
|
15373
15341
|
class ResponseObject {
|
|
@@ -15389,7 +15357,6 @@ class ResponseObject {
|
|
|
15389
15357
|
* Response object for multiple intersection tests <br>
|
|
15390
15358
|
* (recommended as it will avoid allocating extra memory) <br>
|
|
15391
15359
|
* @name clear
|
|
15392
|
-
* @memberof collision.ResponseObject
|
|
15393
15360
|
* @public
|
|
15394
15361
|
* @returns {object} this object for chaining
|
|
15395
15362
|
*/
|
|
@@ -15403,15 +15370,47 @@ class ResponseObject {
|
|
|
15403
15370
|
}
|
|
15404
15371
|
}
|
|
15405
15372
|
|
|
15406
|
-
//
|
|
15407
|
-
|
|
15373
|
+
// a dummy object when using Line for raycasting
|
|
15374
|
+
let dummyObj = {
|
|
15375
|
+
pos : new Vector2d(0, 0),
|
|
15376
|
+
ancestor : {
|
|
15377
|
+
_absPos : new Vector2d(0, 0),
|
|
15378
|
+
getAbsolutePosition : function () {
|
|
15379
|
+
return this._absPos;
|
|
15380
|
+
}
|
|
15381
|
+
}
|
|
15382
|
+
};
|
|
15383
|
+
|
|
15384
|
+
// the global response object used for collisions
|
|
15385
|
+
let globalResponse = new ResponseObject();
|
|
15386
|
+
|
|
15387
|
+
/**
|
|
15388
|
+
* a function used to determine if two objects should collide (based on both respective objects collision mask and type).<br>
|
|
15389
|
+
* you can redefine this function if you need any specific rules over what should collide with what.
|
|
15390
|
+
* @name shouldCollide
|
|
15391
|
+
* @memberof collision
|
|
15392
|
+
* @ignore
|
|
15393
|
+
* @param {Renderable} a a reference to the object A.
|
|
15394
|
+
* @param {Renderable} b a reference to the object B.
|
|
15395
|
+
* @returns {boolean} true if they should collide, false otherwise
|
|
15396
|
+
*/
|
|
15397
|
+
function shouldCollide(a, b) {
|
|
15398
|
+
return (
|
|
15399
|
+
a.isKinematic !== true && b.isKinematic !== true &&
|
|
15400
|
+
typeof a.body === "object" && typeof b.body === "object" &&
|
|
15401
|
+
!(a.body.isStatic === true && b.body.isStatic === true) &&
|
|
15402
|
+
(a.body.collisionMask & b.body.collisionType) !== 0 &&
|
|
15403
|
+
(a.body.collisionType & b.body.collisionMask) !== 0
|
|
15404
|
+
);
|
|
15405
|
+
}
|
|
15406
|
+
|
|
15408
15407
|
|
|
15409
15408
|
/**
|
|
15410
15409
|
* find all the collisions for the specified object
|
|
15411
15410
|
* @name collisionCheck
|
|
15412
15411
|
* @ignore
|
|
15413
15412
|
* @param {Renderable} objA object to be tested for collision
|
|
15414
|
-
* @param {
|
|
15413
|
+
* @param {ResponseObject} [response] a user defined response object that will be populated if they intersect.
|
|
15415
15414
|
* @returns {boolean} in case of collision, false otherwise
|
|
15416
15415
|
*/
|
|
15417
15416
|
function collisionCheck(objA, response = globalResponse) {
|
|
@@ -15641,17 +15640,6 @@ var collision = {
|
|
|
15641
15640
|
ALL_OBJECT : 0xFFFFFFFF // all objects
|
|
15642
15641
|
},
|
|
15643
15642
|
|
|
15644
|
-
|
|
15645
|
-
/**
|
|
15646
|
-
* a global instance of a response object used for collision detection <br>
|
|
15647
|
-
* this object will be reused amongst collision detection call if not user-defined response is specified
|
|
15648
|
-
* @name response
|
|
15649
|
-
* @memberof collision
|
|
15650
|
-
* @public
|
|
15651
|
-
* @type {collision.ResponseObject}
|
|
15652
|
-
*/
|
|
15653
|
-
response : globalResponse,
|
|
15654
|
-
|
|
15655
15643
|
/**
|
|
15656
15644
|
* Checks for object colliding with the given line
|
|
15657
15645
|
* @name rayCast
|
|
@@ -15684,6 +15672,7 @@ var collision = {
|
|
|
15684
15672
|
/**
|
|
15685
15673
|
* @classdesc
|
|
15686
15674
|
* a Generic Physic Body Object with some physic properties and behavior functionality, to as a member of a Renderable.
|
|
15675
|
+
* @see Renderable.body
|
|
15687
15676
|
*/
|
|
15688
15677
|
class Body {
|
|
15689
15678
|
/**
|
|
@@ -16109,7 +16098,7 @@ class Body {
|
|
|
16109
16098
|
|
|
16110
16099
|
/**
|
|
16111
16100
|
* the built-in function to solve the collision response
|
|
16112
|
-
* @param {object} response the collision response object (see {@link
|
|
16101
|
+
* @param {object} response the collision response object (see {@link ResponseObject})
|
|
16113
16102
|
*/
|
|
16114
16103
|
respondToCollision(response) {
|
|
16115
16104
|
// the overlap vector
|
|
@@ -16243,7 +16232,6 @@ class Body {
|
|
|
16243
16232
|
* cap the body velocity (body.maxVel property) to the specified value<br>
|
|
16244
16233
|
* @param {number} x max velocity on x axis
|
|
16245
16234
|
* @param {number} y max velocity on y axis
|
|
16246
|
-
* @protected
|
|
16247
16235
|
*/
|
|
16248
16236
|
setMaxVelocity(x, y) {
|
|
16249
16237
|
this.maxVel.x = x;
|
|
@@ -16254,7 +16242,6 @@ class Body {
|
|
|
16254
16242
|
* set the body default friction
|
|
16255
16243
|
* @param {number} x horizontal friction
|
|
16256
16244
|
* @param {number} y vertical friction
|
|
16257
|
-
* @protected
|
|
16258
16245
|
*/
|
|
16259
16246
|
setFriction(x = 0, y = 0) {
|
|
16260
16247
|
this.friction.x = x;
|
|
@@ -16362,7 +16349,7 @@ class Body {
|
|
|
16362
16349
|
pool.push(this.friction);
|
|
16363
16350
|
pool.push(this.maxVel);
|
|
16364
16351
|
this.shapes.forEach((shape) => {
|
|
16365
|
-
pool.push(shape);
|
|
16352
|
+
pool.push(shape, false);
|
|
16366
16353
|
});
|
|
16367
16354
|
|
|
16368
16355
|
// set to undefined
|
|
@@ -16476,7 +16463,7 @@ class Container extends Renderable {
|
|
|
16476
16463
|
* @memberof Container#
|
|
16477
16464
|
* @param {number} index added or removed child index
|
|
16478
16465
|
*/
|
|
16479
|
-
this.onChildChange = function (
|
|
16466
|
+
this.onChildChange = function (index) { // eslint-disable-line no-unused-vars
|
|
16480
16467
|
// to be extended
|
|
16481
16468
|
};
|
|
16482
16469
|
|
|
@@ -16560,8 +16547,10 @@ class Container extends Renderable {
|
|
|
16560
16547
|
* Adding a child to the container will automatically remove it from its other container.
|
|
16561
16548
|
* Meaning a child can only have one parent. This is important if you add a renderable
|
|
16562
16549
|
* to a container then add it to the me.game.world container it will move it out of the
|
|
16563
|
-
* orginal container.
|
|
16564
|
-
* will not be in any container.
|
|
16550
|
+
* orginal container. Then when the me.game.world.reset() is called the renderable
|
|
16551
|
+
* will not be in any container. <br>
|
|
16552
|
+
* if the given child implements a onActivateEvent method, that method will be called
|
|
16553
|
+
* once the child is added to this container.
|
|
16565
16554
|
* @name addChild
|
|
16566
16555
|
* @memberof Container
|
|
16567
16556
|
* @param {Renderable} child
|
|
@@ -17003,7 +16992,8 @@ class Container extends Renderable {
|
|
|
17003
16992
|
}
|
|
17004
16993
|
|
|
17005
16994
|
/**
|
|
17006
|
-
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed
|
|
16995
|
+
* Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed. <br>
|
|
16996
|
+
* if the given child implements a onDeactivateEvent() method, that method will be called once the child is removed from this container.
|
|
17007
16997
|
* @name removeChild
|
|
17008
16998
|
* @memberof Container
|
|
17009
16999
|
* @public
|
|
@@ -17305,15 +17295,14 @@ class Container extends Renderable {
|
|
|
17305
17295
|
}
|
|
17306
17296
|
|
|
17307
17297
|
/**
|
|
17308
|
-
|
|
17309
|
-
* automatically called by the game manager {@link game}
|
|
17298
|
+
* draw this renderable (automatically called by melonJS)
|
|
17310
17299
|
* @name draw
|
|
17311
17300
|
* @memberof Container
|
|
17312
17301
|
* @protected
|
|
17313
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
17314
|
-
* @param {
|
|
17302
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
17303
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
17315
17304
|
*/
|
|
17316
|
-
draw(renderer,
|
|
17305
|
+
draw(renderer, viewport) {
|
|
17317
17306
|
var isFloating = false;
|
|
17318
17307
|
var bounds = this.getBounds();
|
|
17319
17308
|
|
|
@@ -17355,7 +17344,7 @@ class Container extends Renderable {
|
|
|
17355
17344
|
obj.preDraw(renderer);
|
|
17356
17345
|
|
|
17357
17346
|
// draw the object
|
|
17358
|
-
obj.draw(renderer,
|
|
17347
|
+
obj.draw(renderer, viewport);
|
|
17359
17348
|
|
|
17360
17349
|
// postdraw (clean-up);
|
|
17361
17350
|
obj.postDraw(renderer);
|
|
@@ -19684,6 +19673,24 @@ var state = {
|
|
|
19684
19673
|
}
|
|
19685
19674
|
},
|
|
19686
19675
|
|
|
19676
|
+
/**
|
|
19677
|
+
* returns the stage associated with the specified state
|
|
19678
|
+
* (or the current one if none is specified)
|
|
19679
|
+
* @name set
|
|
19680
|
+
* @memberof state
|
|
19681
|
+
* @public
|
|
19682
|
+
* @param {number} [state] State ID (see constants)
|
|
19683
|
+
* @returns {Stage}
|
|
19684
|
+
*/
|
|
19685
|
+
get(state = _state) {
|
|
19686
|
+
if (typeof _stages[state] !== "undefined") {
|
|
19687
|
+
return _stages[state].stage;
|
|
19688
|
+
} else {
|
|
19689
|
+
return undefined;
|
|
19690
|
+
}
|
|
19691
|
+
|
|
19692
|
+
},
|
|
19693
|
+
|
|
19687
19694
|
/**
|
|
19688
19695
|
* return a reference to the current stage<br>
|
|
19689
19696
|
* useful to call a object specific method
|
|
@@ -19693,9 +19700,7 @@ var state = {
|
|
|
19693
19700
|
* @returns {Stage}
|
|
19694
19701
|
*/
|
|
19695
19702
|
current() {
|
|
19696
|
-
|
|
19697
|
-
return _stages[_state].stage;
|
|
19698
|
-
}
|
|
19703
|
+
return this.get();
|
|
19699
19704
|
},
|
|
19700
19705
|
|
|
19701
19706
|
/**
|
|
@@ -21094,6 +21099,8 @@ class TextureAtlas {
|
|
|
21094
21099
|
* add uvs mapping for the given region
|
|
21095
21100
|
* @param {object} atlas the atlas dictionnary where the region is define
|
|
21096
21101
|
* @param {object} name region (or frame) name
|
|
21102
|
+
* @param {number} w the width of the region
|
|
21103
|
+
* @param {number} h the height of the region
|
|
21097
21104
|
* @returns {Float32Array} the created region UVs
|
|
21098
21105
|
*/
|
|
21099
21106
|
addUVs(atlas, name, w, h) {
|
|
@@ -21801,14 +21808,14 @@ class Sprite extends Renderable {
|
|
|
21801
21808
|
}
|
|
21802
21809
|
|
|
21803
21810
|
/**
|
|
21804
|
-
*
|
|
21805
|
-
* automatically called by the game manager {@link game}
|
|
21811
|
+
* draw this srite (automatically called by melonJS)
|
|
21806
21812
|
* @name draw
|
|
21807
21813
|
* @memberof Sprite
|
|
21808
21814
|
* @protected
|
|
21809
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
21815
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
21816
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
21810
21817
|
*/
|
|
21811
|
-
draw(renderer) {
|
|
21818
|
+
draw(renderer, viewport) { // eslint-disable-line no-unused-vars
|
|
21812
21819
|
// do nothing if we are flickering
|
|
21813
21820
|
if (this._flicker.isFlickering) {
|
|
21814
21821
|
this._flicker.state = !this._flicker.state;
|
|
@@ -22456,10 +22463,10 @@ class Path2D {
|
|
|
22456
22463
|
* adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
|
|
22457
22464
|
* @name arcTo
|
|
22458
22465
|
* @memberof Path2D
|
|
22459
|
-
* @param {number}
|
|
22460
|
-
* @param {number}
|
|
22461
|
-
* @param {number}
|
|
22462
|
-
* @param {number}
|
|
22466
|
+
* @param {number} x1 the x-axis coordinate of the first control point.
|
|
22467
|
+
* @param {number} y1 the y-axis coordinate of the first control point.
|
|
22468
|
+
* @param {number} x2 the x-axis coordinate of the second control point.
|
|
22469
|
+
* @param {number} y2 the y-axis coordinate of the second control point.
|
|
22463
22470
|
* @param {number} radius the arc's radius. Must be positive.
|
|
22464
22471
|
*/
|
|
22465
22472
|
arcTo(x1, y1, x2, y2, radius) {
|
|
@@ -32793,10 +32800,10 @@ class BasePlugin {
|
|
|
32793
32800
|
* this can be overridden by the plugin
|
|
32794
32801
|
* @public
|
|
32795
32802
|
* @type {string}
|
|
32796
|
-
* @default "10.
|
|
32803
|
+
* @default "10.12.0"
|
|
32797
32804
|
* @name plugin.Base#version
|
|
32798
32805
|
*/
|
|
32799
|
-
this.version = "10.
|
|
32806
|
+
this.version = "10.12.0";
|
|
32800
32807
|
}
|
|
32801
32808
|
}
|
|
32802
32809
|
|
|
@@ -34089,11 +34096,14 @@ const runits = ["ex", "em", "pt", "px"];
|
|
|
34089
34096
|
const toPX = [12, 24, 0.75, 1];
|
|
34090
34097
|
|
|
34091
34098
|
// return a valid 2d context for Text rendering/styling
|
|
34092
|
-
var getContext2d = function (renderer, text) {
|
|
34099
|
+
var getContext2d = function (renderer$1, text) {
|
|
34093
34100
|
if (text.offScreenCanvas === true) {
|
|
34094
34101
|
return text.canvasTexture.context;
|
|
34095
34102
|
} else {
|
|
34096
|
-
|
|
34103
|
+
if (typeof renderer$1 === "undefined") {
|
|
34104
|
+
renderer$1 = renderer;
|
|
34105
|
+
}
|
|
34106
|
+
return renderer$1.getFontContext();
|
|
34097
34107
|
}
|
|
34098
34108
|
};
|
|
34099
34109
|
|
|
@@ -34401,12 +34411,12 @@ class Text extends Renderable {
|
|
|
34401
34411
|
|
|
34402
34412
|
/**
|
|
34403
34413
|
* measure the given text size in pixels
|
|
34404
|
-
* @param {CanvasRenderer|WebGLRenderer}
|
|
34414
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer reference to the active renderer
|
|
34405
34415
|
* @param {string} [text] the text to be measured
|
|
34406
34416
|
* @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
|
|
34407
34417
|
*/
|
|
34408
|
-
measureText(renderer
|
|
34409
|
-
return this.metrics.measureText(text, getContext2d(renderer
|
|
34418
|
+
measureText(renderer, text = this._text) {
|
|
34419
|
+
return this.metrics.measureText(text, getContext2d(renderer, this));
|
|
34410
34420
|
}
|
|
34411
34421
|
|
|
34412
34422
|
|
|
@@ -34418,7 +34428,7 @@ class Text extends Renderable {
|
|
|
34418
34428
|
* @param {number} [y]
|
|
34419
34429
|
* @param {boolean} [stroke=false] draw stroke the the text if true
|
|
34420
34430
|
*/
|
|
34421
|
-
draw(renderer, text, x, y, stroke) {
|
|
34431
|
+
draw(renderer, text, x = this.pos.x, y = this.pos.y, stroke = false) {
|
|
34422
34432
|
// "hacky patch" for backward compatibilty
|
|
34423
34433
|
if (typeof this.ancestor === "undefined") {
|
|
34424
34434
|
|
|
@@ -35134,15 +35144,18 @@ class ColorLayer extends Renderable {
|
|
|
35134
35144
|
}
|
|
35135
35145
|
|
|
35136
35146
|
/**
|
|
35137
|
-
* draw
|
|
35138
|
-
* @
|
|
35147
|
+
* draw this color layer (automatically called by melonJS)
|
|
35148
|
+
* @name draw
|
|
35149
|
+
* @memberof ColorLayer
|
|
35150
|
+
* @protected
|
|
35151
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
35152
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
35139
35153
|
*/
|
|
35140
|
-
draw(renderer,
|
|
35141
|
-
var vpos = viewport.pos;
|
|
35154
|
+
draw(renderer, viewport) {
|
|
35142
35155
|
renderer.save();
|
|
35143
35156
|
renderer.clipRect(
|
|
35144
|
-
|
|
35145
|
-
|
|
35157
|
+
0, 0,
|
|
35158
|
+
viewport.width, viewport.height
|
|
35146
35159
|
);
|
|
35147
35160
|
renderer.clearColor(this.color);
|
|
35148
35161
|
renderer.restore();
|
|
@@ -35318,7 +35331,7 @@ class ImageLayer extends Sprite {
|
|
|
35318
35331
|
* @param {number} h new height
|
|
35319
35332
|
*/
|
|
35320
35333
|
resize(w, h) {
|
|
35321
|
-
super.resize(
|
|
35334
|
+
return super.resize(
|
|
35322
35335
|
this.repeatX ? Infinity : w,
|
|
35323
35336
|
this.repeatY ? Infinity : h
|
|
35324
35337
|
);
|
|
@@ -35397,14 +35410,14 @@ class ImageLayer extends Sprite {
|
|
|
35397
35410
|
}
|
|
35398
35411
|
|
|
35399
35412
|
/**
|
|
35400
|
-
* draw
|
|
35401
|
-
* automatically called by the game manager {@link game}
|
|
35413
|
+
* draw this ImageLayer (automatically called by melonJS)
|
|
35402
35414
|
* @name draw
|
|
35403
35415
|
* @memberof ImageLayer
|
|
35404
35416
|
* @protected
|
|
35405
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
35417
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
35418
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
35406
35419
|
*/
|
|
35407
|
-
draw(renderer) {
|
|
35420
|
+
draw(renderer, viewport) {
|
|
35408
35421
|
var width = this.width,
|
|
35409
35422
|
height = this.height,
|
|
35410
35423
|
bw = viewport.bounds.width,
|
|
@@ -35778,7 +35791,7 @@ class GUI_Object extends Sprite {
|
|
|
35778
35791
|
* @param {Pointer} event the event object
|
|
35779
35792
|
* @returns {boolean} return false if we need to stop propagating the event
|
|
35780
35793
|
*/
|
|
35781
|
-
onClick(
|
|
35794
|
+
onClick(event) { // eslint-disable-line no-unused-vars
|
|
35782
35795
|
return false;
|
|
35783
35796
|
}
|
|
35784
35797
|
|
|
@@ -35799,7 +35812,9 @@ class GUI_Object extends Sprite {
|
|
|
35799
35812
|
* @public
|
|
35800
35813
|
* @param {Pointer} event the event object
|
|
35801
35814
|
*/
|
|
35802
|
-
onOver(
|
|
35815
|
+
onOver(event) { // eslint-disable-line no-unused-vars
|
|
35816
|
+
// to be extended
|
|
35817
|
+
}
|
|
35803
35818
|
|
|
35804
35819
|
/**
|
|
35805
35820
|
* function callback for the pointerLeave event
|
|
@@ -35819,8 +35834,8 @@ class GUI_Object extends Sprite {
|
|
|
35819
35834
|
* @public
|
|
35820
35835
|
* @param {Pointer} event the event object
|
|
35821
35836
|
*/
|
|
35822
|
-
onOut(
|
|
35823
|
-
|
|
35837
|
+
onOut(event) { // eslint-disable-line no-unused-vars
|
|
35838
|
+
// to be extended
|
|
35824
35839
|
}
|
|
35825
35840
|
|
|
35826
35841
|
/**
|
|
@@ -36067,8 +36082,15 @@ class Trigger extends Renderable {
|
|
|
36067
36082
|
}
|
|
36068
36083
|
}
|
|
36069
36084
|
|
|
36070
|
-
/**
|
|
36071
|
-
|
|
36085
|
+
/**
|
|
36086
|
+
* onCollision callback, triggered in case of collision with this trigger
|
|
36087
|
+
* @name onCollision
|
|
36088
|
+
* @memberof Trigger
|
|
36089
|
+
* @param {ResponseObject} response the collision response object
|
|
36090
|
+
* @param {Renderable} other the other renderable touching this one (a reference to response.a or response.b)
|
|
36091
|
+
* @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
|
|
36092
|
+
*/
|
|
36093
|
+
onCollision(response, other) { // eslint-disable-line no-unused-vars
|
|
36072
36094
|
if (this.name === "Trigger") {
|
|
36073
36095
|
this.triggerEvent.apply(this);
|
|
36074
36096
|
}
|
|
@@ -36166,10 +36188,14 @@ class Light2d extends Renderable {
|
|
|
36166
36188
|
}
|
|
36167
36189
|
|
|
36168
36190
|
/**
|
|
36169
|
-
*
|
|
36170
|
-
* @
|
|
36191
|
+
* draw this Light2d (automatically called by melonJS)
|
|
36192
|
+
* @name draw
|
|
36193
|
+
* @memberof Light2d
|
|
36194
|
+
* @protected
|
|
36195
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
36196
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
36171
36197
|
*/
|
|
36172
|
-
draw(renderer) {
|
|
36198
|
+
draw(renderer, viewport) { // eslint-disable-line no-unused-vars
|
|
36173
36199
|
renderer.drawImage(this.texture.canvas, this.getBounds().x, this.getBounds().y);
|
|
36174
36200
|
}
|
|
36175
36201
|
|
|
@@ -36382,7 +36408,7 @@ class DropTarget extends Renderable {
|
|
|
36382
36408
|
* @memberof DropTarget
|
|
36383
36409
|
* @param {Draggable} draggable the draggable object that is dropped
|
|
36384
36410
|
*/
|
|
36385
|
-
drop() {
|
|
36411
|
+
drop(draggable) { // eslint-disable-line no-unused-vars
|
|
36386
36412
|
|
|
36387
36413
|
}
|
|
36388
36414
|
|
|
@@ -37315,23 +37341,21 @@ class Entity extends Renderable {
|
|
|
37315
37341
|
}
|
|
37316
37342
|
|
|
37317
37343
|
/**
|
|
37318
|
-
*
|
|
37319
|
-
* not to be called by the end user<br>
|
|
37320
|
-
* called by the game manager on each game loop
|
|
37344
|
+
* draw this entity (automatically called by melonJS)
|
|
37321
37345
|
* @name draw
|
|
37322
37346
|
* @memberof Entity
|
|
37323
37347
|
* @protected
|
|
37324
|
-
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer
|
|
37325
|
-
* @param {
|
|
37348
|
+
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
37349
|
+
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
37326
37350
|
*/
|
|
37327
|
-
draw(renderer,
|
|
37351
|
+
draw(renderer, viewport) {
|
|
37328
37352
|
var renderable = this.renderable;
|
|
37329
37353
|
if (renderable instanceof Renderable) {
|
|
37330
37354
|
// predraw (apply transforms)
|
|
37331
37355
|
renderable.preDraw(renderer);
|
|
37332
37356
|
|
|
37333
37357
|
// draw the object
|
|
37334
|
-
renderable.draw(renderer,
|
|
37358
|
+
renderable.draw(renderer, viewport);
|
|
37335
37359
|
|
|
37336
37360
|
// postdraw (clean-up);
|
|
37337
37361
|
renderable.postDraw(renderer);
|
|
@@ -37502,7 +37526,7 @@ class DroptargetEntity extends DropTarget {
|
|
|
37502
37526
|
* @name version
|
|
37503
37527
|
* @type {string}
|
|
37504
37528
|
*/
|
|
37505
|
-
const version = "10.
|
|
37529
|
+
const version = "10.12.0";
|
|
37506
37530
|
|
|
37507
37531
|
|
|
37508
37532
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melonjs",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.12.0",
|
|
4
4
|
"description": "melonJS Game Engine",
|
|
5
5
|
"homepage": "http://www.melonjs.org/",
|
|
6
6
|
"keywords": [
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@teppeis/multimaps": "^2.0.0",
|
|
58
|
-
"core-js": "^3.23.
|
|
58
|
+
"core-js": "^3.23.1",
|
|
59
59
|
"earcut": "2.2.3",
|
|
60
60
|
"eventemitter3": "^4.0.7",
|
|
61
61
|
"howler": "2.2.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@melonjs/webdoc-theme": "^1.1.
|
|
64
|
+
"@melonjs/webdoc-theme": "^1.1.1",
|
|
65
65
|
"@rollup/plugin-buble": "^0.21.3",
|
|
66
66
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
67
67
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -69,19 +69,19 @@
|
|
|
69
69
|
"@types/offscreencanvas": "^2019.7.0",
|
|
70
70
|
"@webdoc/cli": "^1.6.6",
|
|
71
71
|
"del-cli": "^4.0.1",
|
|
72
|
-
"eslint": "^8.
|
|
72
|
+
"eslint": "^8.18.0",
|
|
73
73
|
"jasmine-core": "^4.2.0",
|
|
74
|
-
"karma": "^6.
|
|
74
|
+
"karma": "^6.4.0",
|
|
75
75
|
"karma-chrome-launcher": "^3.1.1",
|
|
76
76
|
"karma-coverage": "^2.2.0",
|
|
77
77
|
"karma-html-detailed-reporter": "^2.1.0",
|
|
78
|
-
"karma-jasmine": "^5.0
|
|
78
|
+
"karma-jasmine": "^5.1.0",
|
|
79
79
|
"karma-nyan-reporter": "0.2.5",
|
|
80
80
|
"rollup": "^2.75.6",
|
|
81
81
|
"rollup-plugin-bundle-size": "^1.0.3",
|
|
82
82
|
"rollup-plugin-string": "^3.0.0",
|
|
83
83
|
"terser": "^5.14.1",
|
|
84
|
-
"typescript": "^4.7.
|
|
84
|
+
"typescript": "^4.7.4"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"build": "npm run lint && rollup -c --silent",
|