melonjs 10.4.0 → 10.5.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/dist/melonjs.js +774 -244
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +141 -175
- package/dist/melonjs.module.js +768 -242
- package/package.json +9 -8
- package/src/index.js +5 -12
- package/src/lang/deprecated.js +40 -0
- package/src/level/tiled/TMXTileMap.js +2 -0
- package/src/physics/body.js +2 -1
- package/src/physics/detector.js +4 -3
- package/src/renderable/dragndrop.js +224 -0
- package/src/renderable/renderable.js +2 -3
- package/src/video/texture_cache.js +23 -5
- package/src/video/video.js +1 -1
- package/src/video/webgl/webgl_compositor.js +11 -0
- package/src/video/webgl/webgl_renderer.js +12 -0
- package/src/entity/draggable.js +0 -129
- package/src/entity/droptarget.js +0 -99
package/dist/melonjs.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v10.
|
|
2
|
+
* melonJS Game Engine - v10.5.2
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -13572,7 +13572,7 @@ class Renderable extends Rect {
|
|
|
13572
13572
|
* @param {number} dt time since the last update in milliseconds.
|
|
13573
13573
|
* @returns {boolean} true if the renderable is dirty
|
|
13574
13574
|
*/
|
|
13575
|
-
update(
|
|
13575
|
+
update(dt) { // eslint-disable-line no-unused-vars
|
|
13576
13576
|
return this.isDirty;
|
|
13577
13577
|
}
|
|
13578
13578
|
|
|
@@ -13720,7 +13720,7 @@ class Renderable extends Rect {
|
|
|
13720
13720
|
* @protected
|
|
13721
13721
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
13722
13722
|
*/
|
|
13723
|
-
draw(
|
|
13723
|
+
draw(renderer) { // eslint-disable-line no-unused-vars
|
|
13724
13724
|
// empty one !
|
|
13725
13725
|
}
|
|
13726
13726
|
|
|
@@ -13734,7 +13734,6 @@ class Renderable extends Rect {
|
|
|
13734
13734
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
13735
13735
|
*/
|
|
13736
13736
|
postDraw(renderer) {
|
|
13737
|
-
|
|
13738
13737
|
// remove the previously applied tint
|
|
13739
13738
|
renderer.clearTint();
|
|
13740
13739
|
|
|
@@ -14619,7 +14618,8 @@ var dummyObj = {
|
|
|
14619
14618
|
function shouldCollide(a, b) {
|
|
14620
14619
|
return (
|
|
14621
14620
|
a.isKinematic !== true && b.isKinematic !== true &&
|
|
14622
|
-
a.body && b.body &&
|
|
14621
|
+
typeof a.body === "object" && typeof b.body === "object" &&
|
|
14622
|
+
!(a.body.isStatic === true && b.body.isStatic === true) &&
|
|
14623
14623
|
(a.body.collisionMask & b.body.collisionType) !== 0 &&
|
|
14624
14624
|
(a.body.collisionType & b.body.collisionMask) !== 0
|
|
14625
14625
|
);
|
|
@@ -14732,10 +14732,10 @@ function collisionCheck(objA, response = globalResponse) {
|
|
|
14732
14732
|
response.indexShapeB = indexB;
|
|
14733
14733
|
|
|
14734
14734
|
// execute the onCollision callback
|
|
14735
|
-
if (objA.onCollision && objA.onCollision(response, objB) !== false) {
|
|
14735
|
+
if (objA.onCollision && objA.onCollision(response, objB) !== false && objA.body.isStatic === false) {
|
|
14736
14736
|
objA.body.respondToCollision.call(objA.body, response);
|
|
14737
14737
|
}
|
|
14738
|
-
if (objB.onCollision && objB.onCollision(response, objA) !== false) {
|
|
14738
|
+
if (objB.onCollision && objB.onCollision(response, objA) !== false && objB.body.isStatic === false) {
|
|
14739
14739
|
objB.body.respondToCollision.call(objB.body, response);
|
|
14740
14740
|
}
|
|
14741
14741
|
}
|
|
@@ -15099,7 +15099,8 @@ class Body {
|
|
|
15099
15099
|
|
|
15100
15100
|
|
|
15101
15101
|
/**
|
|
15102
|
-
*
|
|
15102
|
+
* Either this body is a static body or not.
|
|
15103
|
+
* A static body is completely fixed and can never change position or angle.
|
|
15103
15104
|
* @readonly
|
|
15104
15105
|
* @public
|
|
15105
15106
|
* @type {boolean}
|
|
@@ -19388,6 +19389,455 @@ function applyTMXProperties(obj, data) {
|
|
|
19388
19389
|
}
|
|
19389
19390
|
}
|
|
19390
19391
|
|
|
19392
|
+
var src = {};
|
|
19393
|
+
|
|
19394
|
+
var arraymultimap = {};
|
|
19395
|
+
|
|
19396
|
+
var multimap = {};
|
|
19397
|
+
|
|
19398
|
+
var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
19399
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19400
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
19401
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19402
|
+
function step(op) {
|
|
19403
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
19404
|
+
while (_) try {
|
|
19405
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19406
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19407
|
+
switch (op[0]) {
|
|
19408
|
+
case 0: case 1: t = op; break;
|
|
19409
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
19410
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
19411
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
19412
|
+
default:
|
|
19413
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
19414
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19415
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
19416
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
19417
|
+
if (t[2]) _.ops.pop();
|
|
19418
|
+
_.trys.pop(); continue;
|
|
19419
|
+
}
|
|
19420
|
+
op = body.call(thisArg, _);
|
|
19421
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
19422
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
19423
|
+
}
|
|
19424
|
+
};
|
|
19425
|
+
var __values = (commonjsGlobal && commonjsGlobal.__values) || function(o) {
|
|
19426
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
19427
|
+
if (m) return m.call(o);
|
|
19428
|
+
if (o && typeof o.length === "number") return {
|
|
19429
|
+
next: function () {
|
|
19430
|
+
if (o && i >= o.length) o = void 0;
|
|
19431
|
+
return { value: o && o[i++], done: !o };
|
|
19432
|
+
}
|
|
19433
|
+
};
|
|
19434
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
19435
|
+
};
|
|
19436
|
+
var __read = (commonjsGlobal && commonjsGlobal.__read) || function (o, n) {
|
|
19437
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
19438
|
+
if (!m) return o;
|
|
19439
|
+
var i = m.call(o), r, ar = [], e;
|
|
19440
|
+
try {
|
|
19441
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19442
|
+
}
|
|
19443
|
+
catch (error) { e = { error: error }; }
|
|
19444
|
+
finally {
|
|
19445
|
+
try {
|
|
19446
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19447
|
+
}
|
|
19448
|
+
finally { if (e) throw e.error; }
|
|
19449
|
+
}
|
|
19450
|
+
return ar;
|
|
19451
|
+
};
|
|
19452
|
+
Object.defineProperty(multimap, "__esModule", { value: true });
|
|
19453
|
+
multimap.Multimap = void 0;
|
|
19454
|
+
var Multimap = /** @class */ (function () {
|
|
19455
|
+
function Multimap(operator, iterable) {
|
|
19456
|
+
var e_1, _a;
|
|
19457
|
+
this.size_ = 0;
|
|
19458
|
+
this.map = new Map();
|
|
19459
|
+
this.operator = operator;
|
|
19460
|
+
if (iterable) {
|
|
19461
|
+
try {
|
|
19462
|
+
for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
|
|
19463
|
+
var _b = __read(iterable_1_1.value, 2), key = _b[0], value = _b[1];
|
|
19464
|
+
this.put(key, value);
|
|
19465
|
+
}
|
|
19466
|
+
}
|
|
19467
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
19468
|
+
finally {
|
|
19469
|
+
try {
|
|
19470
|
+
if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) _a.call(iterable_1);
|
|
19471
|
+
}
|
|
19472
|
+
finally { if (e_1) throw e_1.error; }
|
|
19473
|
+
}
|
|
19474
|
+
}
|
|
19475
|
+
return this;
|
|
19476
|
+
}
|
|
19477
|
+
Object.defineProperty(Multimap.prototype, "size", {
|
|
19478
|
+
get: function () {
|
|
19479
|
+
return this.size_;
|
|
19480
|
+
},
|
|
19481
|
+
enumerable: false,
|
|
19482
|
+
configurable: true
|
|
19483
|
+
});
|
|
19484
|
+
Multimap.prototype.get = function (key) {
|
|
19485
|
+
var values = this.map.get(key);
|
|
19486
|
+
if (values) {
|
|
19487
|
+
return this.operator.clone(values);
|
|
19488
|
+
}
|
|
19489
|
+
else {
|
|
19490
|
+
return this.operator.create();
|
|
19491
|
+
}
|
|
19492
|
+
};
|
|
19493
|
+
Multimap.prototype.put = function (key, value) {
|
|
19494
|
+
var values = this.map.get(key);
|
|
19495
|
+
if (!values) {
|
|
19496
|
+
values = this.operator.create();
|
|
19497
|
+
}
|
|
19498
|
+
if (!this.operator.add(value, values)) {
|
|
19499
|
+
return false;
|
|
19500
|
+
}
|
|
19501
|
+
this.map.set(key, values);
|
|
19502
|
+
this.size_++;
|
|
19503
|
+
return true;
|
|
19504
|
+
};
|
|
19505
|
+
Multimap.prototype.putAll = function (arg1, arg2) {
|
|
19506
|
+
var e_2, _a, e_3, _b;
|
|
19507
|
+
var pushed = 0;
|
|
19508
|
+
if (arg2) {
|
|
19509
|
+
var key = arg1;
|
|
19510
|
+
var values = arg2;
|
|
19511
|
+
try {
|
|
19512
|
+
for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
|
|
19513
|
+
var value = values_1_1.value;
|
|
19514
|
+
this.put(key, value);
|
|
19515
|
+
pushed++;
|
|
19516
|
+
}
|
|
19517
|
+
}
|
|
19518
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
19519
|
+
finally {
|
|
19520
|
+
try {
|
|
19521
|
+
if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1);
|
|
19522
|
+
}
|
|
19523
|
+
finally { if (e_2) throw e_2.error; }
|
|
19524
|
+
}
|
|
19525
|
+
}
|
|
19526
|
+
else if (arg1 instanceof Multimap) {
|
|
19527
|
+
try {
|
|
19528
|
+
for (var _c = __values(arg1.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
19529
|
+
var _e = __read(_d.value, 2), key = _e[0], value = _e[1];
|
|
19530
|
+
this.put(key, value);
|
|
19531
|
+
pushed++;
|
|
19532
|
+
}
|
|
19533
|
+
}
|
|
19534
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
19535
|
+
finally {
|
|
19536
|
+
try {
|
|
19537
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
19538
|
+
}
|
|
19539
|
+
finally { if (e_3) throw e_3.error; }
|
|
19540
|
+
}
|
|
19541
|
+
}
|
|
19542
|
+
else {
|
|
19543
|
+
throw new TypeError("unexpected arguments");
|
|
19544
|
+
}
|
|
19545
|
+
return pushed > 0;
|
|
19546
|
+
};
|
|
19547
|
+
Multimap.prototype.has = function (key) {
|
|
19548
|
+
return this.map.has(key);
|
|
19549
|
+
};
|
|
19550
|
+
Multimap.prototype.hasEntry = function (key, value) {
|
|
19551
|
+
return this.operator.has(value, this.get(key));
|
|
19552
|
+
};
|
|
19553
|
+
Multimap.prototype.delete = function (key) {
|
|
19554
|
+
this.size_ -= this.operator.size(this.get(key));
|
|
19555
|
+
return this.map.delete(key);
|
|
19556
|
+
};
|
|
19557
|
+
Multimap.prototype.deleteEntry = function (key, value) {
|
|
19558
|
+
var current = this.get(key);
|
|
19559
|
+
if (!this.operator.delete(value, current)) {
|
|
19560
|
+
return false;
|
|
19561
|
+
}
|
|
19562
|
+
this.map.set(key, current);
|
|
19563
|
+
this.size_--;
|
|
19564
|
+
return true;
|
|
19565
|
+
};
|
|
19566
|
+
Multimap.prototype.clear = function () {
|
|
19567
|
+
this.map.clear();
|
|
19568
|
+
this.size_ = 0;
|
|
19569
|
+
};
|
|
19570
|
+
Multimap.prototype.keys = function () {
|
|
19571
|
+
return this.map.keys();
|
|
19572
|
+
};
|
|
19573
|
+
Multimap.prototype.entries = function () {
|
|
19574
|
+
var self = this;
|
|
19575
|
+
function gen() {
|
|
19576
|
+
var _a, _b, _c, key, values, values_2, values_2_1, value, e_4_1, e_5_1;
|
|
19577
|
+
var e_5, _d, e_4, _e;
|
|
19578
|
+
return __generator(this, function (_f) {
|
|
19579
|
+
switch (_f.label) {
|
|
19580
|
+
case 0:
|
|
19581
|
+
_f.trys.push([0, 11, 12, 13]);
|
|
19582
|
+
_a = __values(self.map.entries()), _b = _a.next();
|
|
19583
|
+
_f.label = 1;
|
|
19584
|
+
case 1:
|
|
19585
|
+
if (!!_b.done) return [3 /*break*/, 10];
|
|
19586
|
+
_c = __read(_b.value, 2), key = _c[0], values = _c[1];
|
|
19587
|
+
_f.label = 2;
|
|
19588
|
+
case 2:
|
|
19589
|
+
_f.trys.push([2, 7, 8, 9]);
|
|
19590
|
+
values_2 = (e_4 = void 0, __values(values)), values_2_1 = values_2.next();
|
|
19591
|
+
_f.label = 3;
|
|
19592
|
+
case 3:
|
|
19593
|
+
if (!!values_2_1.done) return [3 /*break*/, 6];
|
|
19594
|
+
value = values_2_1.value;
|
|
19595
|
+
return [4 /*yield*/, [key, value]];
|
|
19596
|
+
case 4:
|
|
19597
|
+
_f.sent();
|
|
19598
|
+
_f.label = 5;
|
|
19599
|
+
case 5:
|
|
19600
|
+
values_2_1 = values_2.next();
|
|
19601
|
+
return [3 /*break*/, 3];
|
|
19602
|
+
case 6: return [3 /*break*/, 9];
|
|
19603
|
+
case 7:
|
|
19604
|
+
e_4_1 = _f.sent();
|
|
19605
|
+
e_4 = { error: e_4_1 };
|
|
19606
|
+
return [3 /*break*/, 9];
|
|
19607
|
+
case 8:
|
|
19608
|
+
try {
|
|
19609
|
+
if (values_2_1 && !values_2_1.done && (_e = values_2.return)) _e.call(values_2);
|
|
19610
|
+
}
|
|
19611
|
+
finally { if (e_4) throw e_4.error; }
|
|
19612
|
+
return [7 /*endfinally*/];
|
|
19613
|
+
case 9:
|
|
19614
|
+
_b = _a.next();
|
|
19615
|
+
return [3 /*break*/, 1];
|
|
19616
|
+
case 10: return [3 /*break*/, 13];
|
|
19617
|
+
case 11:
|
|
19618
|
+
e_5_1 = _f.sent();
|
|
19619
|
+
e_5 = { error: e_5_1 };
|
|
19620
|
+
return [3 /*break*/, 13];
|
|
19621
|
+
case 12:
|
|
19622
|
+
try {
|
|
19623
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
19624
|
+
}
|
|
19625
|
+
finally { if (e_5) throw e_5.error; }
|
|
19626
|
+
return [7 /*endfinally*/];
|
|
19627
|
+
case 13: return [2 /*return*/];
|
|
19628
|
+
}
|
|
19629
|
+
});
|
|
19630
|
+
}
|
|
19631
|
+
return gen();
|
|
19632
|
+
};
|
|
19633
|
+
Multimap.prototype.values = function () {
|
|
19634
|
+
var self = this;
|
|
19635
|
+
function gen() {
|
|
19636
|
+
var _a, _b, _c, value, e_6_1;
|
|
19637
|
+
var e_6, _d;
|
|
19638
|
+
return __generator(this, function (_e) {
|
|
19639
|
+
switch (_e.label) {
|
|
19640
|
+
case 0:
|
|
19641
|
+
_e.trys.push([0, 5, 6, 7]);
|
|
19642
|
+
_a = __values(self.entries()), _b = _a.next();
|
|
19643
|
+
_e.label = 1;
|
|
19644
|
+
case 1:
|
|
19645
|
+
if (!!_b.done) return [3 /*break*/, 4];
|
|
19646
|
+
_c = __read(_b.value, 2), value = _c[1];
|
|
19647
|
+
return [4 /*yield*/, value];
|
|
19648
|
+
case 2:
|
|
19649
|
+
_e.sent();
|
|
19650
|
+
_e.label = 3;
|
|
19651
|
+
case 3:
|
|
19652
|
+
_b = _a.next();
|
|
19653
|
+
return [3 /*break*/, 1];
|
|
19654
|
+
case 4: return [3 /*break*/, 7];
|
|
19655
|
+
case 5:
|
|
19656
|
+
e_6_1 = _e.sent();
|
|
19657
|
+
e_6 = { error: e_6_1 };
|
|
19658
|
+
return [3 /*break*/, 7];
|
|
19659
|
+
case 6:
|
|
19660
|
+
try {
|
|
19661
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
19662
|
+
}
|
|
19663
|
+
finally { if (e_6) throw e_6.error; }
|
|
19664
|
+
return [7 /*endfinally*/];
|
|
19665
|
+
case 7: return [2 /*return*/];
|
|
19666
|
+
}
|
|
19667
|
+
});
|
|
19668
|
+
}
|
|
19669
|
+
return gen();
|
|
19670
|
+
};
|
|
19671
|
+
Multimap.prototype.forEach = function (callback, thisArg) {
|
|
19672
|
+
var e_7, _a;
|
|
19673
|
+
try {
|
|
19674
|
+
for (var _b = __values(this.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19675
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
19676
|
+
callback.call(thisArg === undefined ? this : thisArg, value, key, this);
|
|
19677
|
+
}
|
|
19678
|
+
}
|
|
19679
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
19680
|
+
finally {
|
|
19681
|
+
try {
|
|
19682
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
19683
|
+
}
|
|
19684
|
+
finally { if (e_7) throw e_7.error; }
|
|
19685
|
+
}
|
|
19686
|
+
};
|
|
19687
|
+
Multimap.prototype[Symbol.iterator] = function () {
|
|
19688
|
+
return this.entries();
|
|
19689
|
+
};
|
|
19690
|
+
Multimap.prototype.asMap = function () {
|
|
19691
|
+
var e_8, _a;
|
|
19692
|
+
var ret = new Map();
|
|
19693
|
+
try {
|
|
19694
|
+
for (var _b = __values(this.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19695
|
+
var key = _c.value;
|
|
19696
|
+
ret.set(key, this.operator.clone(this.get(key)));
|
|
19697
|
+
}
|
|
19698
|
+
}
|
|
19699
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
19700
|
+
finally {
|
|
19701
|
+
try {
|
|
19702
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
19703
|
+
}
|
|
19704
|
+
finally { if (e_8) throw e_8.error; }
|
|
19705
|
+
}
|
|
19706
|
+
return ret;
|
|
19707
|
+
};
|
|
19708
|
+
return Multimap;
|
|
19709
|
+
}());
|
|
19710
|
+
multimap.Multimap = Multimap;
|
|
19711
|
+
|
|
19712
|
+
var __extends$1 = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
19713
|
+
var extendStatics = function (d, b) {
|
|
19714
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19715
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
19716
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
19717
|
+
return extendStatics(d, b);
|
|
19718
|
+
};
|
|
19719
|
+
return function (d, b) {
|
|
19720
|
+
extendStatics(d, b);
|
|
19721
|
+
function __() { this.constructor = d; }
|
|
19722
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19723
|
+
};
|
|
19724
|
+
})();
|
|
19725
|
+
Object.defineProperty(arraymultimap, "__esModule", { value: true });
|
|
19726
|
+
arraymultimap.ArrayMultimap = void 0;
|
|
19727
|
+
var multimap_1$1 = multimap;
|
|
19728
|
+
var ArrayMultimap = /** @class */ (function (_super) {
|
|
19729
|
+
__extends$1(ArrayMultimap, _super);
|
|
19730
|
+
function ArrayMultimap(iterable) {
|
|
19731
|
+
return _super.call(this, new ArrayOperator(), iterable) || this;
|
|
19732
|
+
}
|
|
19733
|
+
Object.defineProperty(ArrayMultimap.prototype, Symbol.toStringTag, {
|
|
19734
|
+
get: function () {
|
|
19735
|
+
return "ArrayMultimap";
|
|
19736
|
+
},
|
|
19737
|
+
enumerable: false,
|
|
19738
|
+
configurable: true
|
|
19739
|
+
});
|
|
19740
|
+
return ArrayMultimap;
|
|
19741
|
+
}(multimap_1$1.Multimap));
|
|
19742
|
+
arraymultimap.ArrayMultimap = ArrayMultimap;
|
|
19743
|
+
var ArrayOperator = /** @class */ (function () {
|
|
19744
|
+
function ArrayOperator() {
|
|
19745
|
+
}
|
|
19746
|
+
ArrayOperator.prototype.create = function () {
|
|
19747
|
+
return [];
|
|
19748
|
+
};
|
|
19749
|
+
ArrayOperator.prototype.clone = function (collection) {
|
|
19750
|
+
return collection.slice();
|
|
19751
|
+
};
|
|
19752
|
+
ArrayOperator.prototype.add = function (value, collection) {
|
|
19753
|
+
collection.push(value);
|
|
19754
|
+
return true;
|
|
19755
|
+
};
|
|
19756
|
+
ArrayOperator.prototype.size = function (collection) {
|
|
19757
|
+
return collection.length;
|
|
19758
|
+
};
|
|
19759
|
+
ArrayOperator.prototype.delete = function (value, collection) {
|
|
19760
|
+
var index = collection.indexOf(value);
|
|
19761
|
+
if (index > -1) {
|
|
19762
|
+
collection.splice(index, 1);
|
|
19763
|
+
return true;
|
|
19764
|
+
}
|
|
19765
|
+
return false;
|
|
19766
|
+
};
|
|
19767
|
+
ArrayOperator.prototype.has = function (value, collection) {
|
|
19768
|
+
return collection.includes(value);
|
|
19769
|
+
};
|
|
19770
|
+
return ArrayOperator;
|
|
19771
|
+
}());
|
|
19772
|
+
|
|
19773
|
+
var setmultimap = {};
|
|
19774
|
+
|
|
19775
|
+
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
19776
|
+
var extendStatics = function (d, b) {
|
|
19777
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19778
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
19779
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
19780
|
+
return extendStatics(d, b);
|
|
19781
|
+
};
|
|
19782
|
+
return function (d, b) {
|
|
19783
|
+
extendStatics(d, b);
|
|
19784
|
+
function __() { this.constructor = d; }
|
|
19785
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19786
|
+
};
|
|
19787
|
+
})();
|
|
19788
|
+
Object.defineProperty(setmultimap, "__esModule", { value: true });
|
|
19789
|
+
setmultimap.SetMultimap = void 0;
|
|
19790
|
+
var multimap_1 = multimap;
|
|
19791
|
+
var SetMultimap = /** @class */ (function (_super) {
|
|
19792
|
+
__extends(SetMultimap, _super);
|
|
19793
|
+
function SetMultimap(iterable) {
|
|
19794
|
+
return _super.call(this, new SetOperator(), iterable) || this;
|
|
19795
|
+
}
|
|
19796
|
+
Object.defineProperty(SetMultimap.prototype, Symbol.toStringTag, {
|
|
19797
|
+
get: function () {
|
|
19798
|
+
return "SetMultimap";
|
|
19799
|
+
},
|
|
19800
|
+
enumerable: false,
|
|
19801
|
+
configurable: true
|
|
19802
|
+
});
|
|
19803
|
+
return SetMultimap;
|
|
19804
|
+
}(multimap_1.Multimap));
|
|
19805
|
+
setmultimap.SetMultimap = SetMultimap;
|
|
19806
|
+
var SetOperator = /** @class */ (function () {
|
|
19807
|
+
function SetOperator() {
|
|
19808
|
+
}
|
|
19809
|
+
SetOperator.prototype.create = function () {
|
|
19810
|
+
return new Set();
|
|
19811
|
+
};
|
|
19812
|
+
SetOperator.prototype.clone = function (collection) {
|
|
19813
|
+
return new Set(collection);
|
|
19814
|
+
};
|
|
19815
|
+
SetOperator.prototype.add = function (value, collection) {
|
|
19816
|
+
var prev = collection.size;
|
|
19817
|
+
collection.add(value);
|
|
19818
|
+
return prev !== collection.size;
|
|
19819
|
+
};
|
|
19820
|
+
SetOperator.prototype.size = function (collection) {
|
|
19821
|
+
return collection.size;
|
|
19822
|
+
};
|
|
19823
|
+
SetOperator.prototype.delete = function (value, collection) {
|
|
19824
|
+
return collection.delete(value);
|
|
19825
|
+
};
|
|
19826
|
+
SetOperator.prototype.has = function (value, collection) {
|
|
19827
|
+
return collection.has(value);
|
|
19828
|
+
};
|
|
19829
|
+
return SetOperator;
|
|
19830
|
+
}());
|
|
19831
|
+
|
|
19832
|
+
(function (exports) {
|
|
19833
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19834
|
+
exports.SetMultimap = exports.ArrayMultimap = void 0;
|
|
19835
|
+
var arraymultimap_1 = arraymultimap;
|
|
19836
|
+
Object.defineProperty(exports, "ArrayMultimap", { enumerable: true, get: function () { return arraymultimap_1.ArrayMultimap; } });
|
|
19837
|
+
var setmultimap_1 = setmultimap;
|
|
19838
|
+
Object.defineProperty(exports, "SetMultimap", { enumerable: true, get: function () { return setmultimap_1.SetMultimap; } });
|
|
19839
|
+
}(src));
|
|
19840
|
+
|
|
19391
19841
|
/**
|
|
19392
19842
|
* a basic texture cache object
|
|
19393
19843
|
* @ignore
|
|
@@ -19398,7 +19848,8 @@ class TextureCache {
|
|
|
19398
19848
|
* @ignore
|
|
19399
19849
|
*/
|
|
19400
19850
|
constructor(max_size) {
|
|
19401
|
-
|
|
19851
|
+
// cache uses an array to allow for duplicated key
|
|
19852
|
+
this.cache = new src.ArrayMultimap();
|
|
19402
19853
|
this.tinted = new Map();
|
|
19403
19854
|
this.units = new Map();
|
|
19404
19855
|
this.max_size = max_size || Infinity;
|
|
@@ -19432,13 +19883,29 @@ class TextureCache {
|
|
|
19432
19883
|
* @ignore
|
|
19433
19884
|
*/
|
|
19434
19885
|
get(image, atlas) {
|
|
19435
|
-
|
|
19886
|
+
var entry;
|
|
19887
|
+
|
|
19888
|
+
if (typeof atlas === "undefined") {
|
|
19889
|
+
entry = this.cache.get(image)[0];
|
|
19890
|
+
} else {
|
|
19891
|
+
// manage cases where a specific atlas is specified
|
|
19892
|
+
this.cache.forEach((value, key) => {
|
|
19893
|
+
var _atlas = value.getAtlas();
|
|
19894
|
+
if (key === image && _atlas[0].width === atlas.framewidth && _atlas[0].height === atlas.frameheight) {
|
|
19895
|
+
entry = value;
|
|
19896
|
+
}
|
|
19897
|
+
});
|
|
19898
|
+
}
|
|
19899
|
+
|
|
19900
|
+
if (typeof entry === "undefined") {
|
|
19436
19901
|
if (!atlas) {
|
|
19437
19902
|
atlas = createAtlas(image.width, image.height, image.src ? getBasename(image.src) : undefined);
|
|
19438
19903
|
}
|
|
19439
|
-
|
|
19904
|
+
entry = new TextureAtlas(atlas, image, false);
|
|
19905
|
+
this.set(image, entry);
|
|
19440
19906
|
}
|
|
19441
|
-
|
|
19907
|
+
|
|
19908
|
+
return entry;
|
|
19442
19909
|
}
|
|
19443
19910
|
|
|
19444
19911
|
/**
|
|
@@ -19483,7 +19950,7 @@ class TextureCache {
|
|
|
19483
19950
|
"(" + width + "x" + height + ")"
|
|
19484
19951
|
);
|
|
19485
19952
|
}
|
|
19486
|
-
this.cache.
|
|
19953
|
+
return this.cache.put(image, texture);
|
|
19487
19954
|
}
|
|
19488
19955
|
|
|
19489
19956
|
/**
|
|
@@ -25381,6 +25848,8 @@ class TMXTileMap {
|
|
|
25381
25848
|
if (isCollisionGroup && !settings.name && obj.body) {
|
|
25382
25849
|
// configure the body accordingly
|
|
25383
25850
|
obj.body.collisionType = collision.types.WORLD_SHAPE;
|
|
25851
|
+
// mark collision shapes as static
|
|
25852
|
+
obj.body.isStatic = true;
|
|
25384
25853
|
}
|
|
25385
25854
|
|
|
25386
25855
|
//apply group opacity value to the child objects if group are merged
|
|
@@ -29129,6 +29598,17 @@ class WebGLCompositor {
|
|
|
29129
29598
|
return this.currentTextureUnit;
|
|
29130
29599
|
}
|
|
29131
29600
|
|
|
29601
|
+
/**
|
|
29602
|
+
* set/change the current projection matrix
|
|
29603
|
+
* @name setProjection
|
|
29604
|
+
* @memberof WebGLCompositor
|
|
29605
|
+
* @function
|
|
29606
|
+
* @param {Matrix3d} matrix
|
|
29607
|
+
*/
|
|
29608
|
+
setProjection(matrix) {
|
|
29609
|
+
this.activeShader.setUniform("uProjectionMatrix", matrix);
|
|
29610
|
+
}
|
|
29611
|
+
|
|
29132
29612
|
/**
|
|
29133
29613
|
* Select the shader to use for compositing
|
|
29134
29614
|
* @name useShader
|
|
@@ -29608,6 +30088,18 @@ class WebGLRenderer extends Renderer {
|
|
|
29608
30088
|
this.currentCompositor.flush();
|
|
29609
30089
|
}
|
|
29610
30090
|
|
|
30091
|
+
/**
|
|
30092
|
+
* set/change the current projection matrix (WebGL only)
|
|
30093
|
+
* @name setProjection
|
|
30094
|
+
* @memberof WebGLRenderer.prototype
|
|
30095
|
+
* @function
|
|
30096
|
+
* @param {Matrix3d} matrix
|
|
30097
|
+
*/
|
|
30098
|
+
setProjection(matrix) {
|
|
30099
|
+
super.setProjection(matrix);
|
|
30100
|
+
this.currentCompositor.setProjection(matrix);
|
|
30101
|
+
}
|
|
30102
|
+
|
|
29611
30103
|
/**
|
|
29612
30104
|
* Clears the gl context with the given color.
|
|
29613
30105
|
* @name clearColor
|
|
@@ -30708,7 +31200,7 @@ function init(width, height, options) {
|
|
|
30708
31200
|
|
|
30709
31201
|
// default scaled size value
|
|
30710
31202
|
settings.zoomX = width * scaleRatio.x;
|
|
30711
|
-
settings.zoomY =
|
|
31203
|
+
settings.zoomY = height * scaleRatio.y;
|
|
30712
31204
|
|
|
30713
31205
|
//add a channel for the onresize/onorientationchange event
|
|
30714
31206
|
window.addEventListener(
|
|
@@ -31374,10 +31866,10 @@ class BasePlugin {
|
|
|
31374
31866
|
* this can be overridden by the plugin
|
|
31375
31867
|
* @public
|
|
31376
31868
|
* @type {string}
|
|
31377
|
-
* @default "10.
|
|
31869
|
+
* @default "10.5.2"
|
|
31378
31870
|
* @name plugin.Base#version
|
|
31379
31871
|
*/
|
|
31380
|
-
this.version = "10.
|
|
31872
|
+
this.version = "10.5.2";
|
|
31381
31873
|
}
|
|
31382
31874
|
}
|
|
31383
31875
|
|
|
@@ -34517,6 +35009,225 @@ class Trigger extends Renderable {
|
|
|
34517
35009
|
|
|
34518
35010
|
}
|
|
34519
35011
|
|
|
35012
|
+
/**
|
|
35013
|
+
* @classdesc
|
|
35014
|
+
* A Draggable base object
|
|
35015
|
+
* @see DropTarget
|
|
35016
|
+
* @augments Renderable
|
|
35017
|
+
*/
|
|
35018
|
+
class Draggable extends Renderable {
|
|
35019
|
+
/**
|
|
35020
|
+
* @param {number} x the x coordinates of the draggable object
|
|
35021
|
+
* @param {number} y the y coordinates of the draggable object
|
|
35022
|
+
* @param {number} width draggable object width
|
|
35023
|
+
* @param {number} height draggable object height
|
|
35024
|
+
*/
|
|
35025
|
+
constructor(x, y, width, height) {
|
|
35026
|
+
super(x, y, width, height);
|
|
35027
|
+
this.isKinematic = false;
|
|
35028
|
+
this.dragging = false;
|
|
35029
|
+
this.dragId = null;
|
|
35030
|
+
this.grabOffset = new Vector2d(0, 0);
|
|
35031
|
+
this.initEvents();
|
|
35032
|
+
}
|
|
35033
|
+
|
|
35034
|
+
/**
|
|
35035
|
+
* Initializes the events the modules needs to listen to
|
|
35036
|
+
* It translates the pointer events to me.events
|
|
35037
|
+
* in order to make them pass through the system and to make
|
|
35038
|
+
* this module testable. Then we subscribe this module to the
|
|
35039
|
+
* transformed events.
|
|
35040
|
+
* @name initEvents
|
|
35041
|
+
* @memberof Draggable
|
|
35042
|
+
* @function
|
|
35043
|
+
* @private
|
|
35044
|
+
*/
|
|
35045
|
+
initEvents() {
|
|
35046
|
+
registerPointerEvent("pointerdown", this, (e) => { emit(DRAGSTART, e, this); });
|
|
35047
|
+
registerPointerEvent("pointerup", this, (e) => { emit(DRAGEND, e, this); });
|
|
35048
|
+
registerPointerEvent("pointercancel", this, (e) => { emit(DRAGEND, e, this); });
|
|
35049
|
+
on(POINTERMOVE, this.dragMove.bind(this));
|
|
35050
|
+
on(DRAGSTART, (e, draggable) => {
|
|
35051
|
+
if (draggable === this) {
|
|
35052
|
+
this.dragStart(e);
|
|
35053
|
+
}
|
|
35054
|
+
});
|
|
35055
|
+
on(DRAGEND, (e, draggable) => {
|
|
35056
|
+
if (draggable === this) {
|
|
35057
|
+
this.dragEnd(e);
|
|
35058
|
+
}
|
|
35059
|
+
});
|
|
35060
|
+
}
|
|
35061
|
+
|
|
35062
|
+
/**
|
|
35063
|
+
* Gets called when the user starts dragging the entity
|
|
35064
|
+
* @name dragStart
|
|
35065
|
+
* @memberof Draggable
|
|
35066
|
+
* @function
|
|
35067
|
+
* @param {object} e the pointer event
|
|
35068
|
+
* @returns {boolean} false if the object is being dragged
|
|
35069
|
+
*/
|
|
35070
|
+
dragStart(e) {
|
|
35071
|
+
if (this.dragging === false) {
|
|
35072
|
+
this.dragging = true;
|
|
35073
|
+
this.grabOffset.set(e.gameX, e.gameY);
|
|
35074
|
+
this.grabOffset.sub(this.pos);
|
|
35075
|
+
return false;
|
|
35076
|
+
}
|
|
35077
|
+
}
|
|
35078
|
+
|
|
35079
|
+
/**
|
|
35080
|
+
* Gets called when the user drags this entity around
|
|
35081
|
+
* @name dragMove
|
|
35082
|
+
* @memberof Draggable
|
|
35083
|
+
* @function
|
|
35084
|
+
* @param {object} e the pointer event
|
|
35085
|
+
*/
|
|
35086
|
+
dragMove(e) {
|
|
35087
|
+
if (this.dragging === true) {
|
|
35088
|
+
this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
|
|
35089
|
+
this.pos.sub(this.grabOffset);
|
|
35090
|
+
}
|
|
35091
|
+
}
|
|
35092
|
+
|
|
35093
|
+
/**
|
|
35094
|
+
* Gets called when the user stops dragging the entity
|
|
35095
|
+
* @name dragEnd
|
|
35096
|
+
* @memberof Draggable
|
|
35097
|
+
* @function
|
|
35098
|
+
* @returns {boolean} false if the object stopped being dragged
|
|
35099
|
+
*/
|
|
35100
|
+
dragEnd() {
|
|
35101
|
+
if (this.dragging === true) {
|
|
35102
|
+
this.dragging = false;
|
|
35103
|
+
return false;
|
|
35104
|
+
}
|
|
35105
|
+
}
|
|
35106
|
+
|
|
35107
|
+
/**
|
|
35108
|
+
* Destructor
|
|
35109
|
+
* @name destroy
|
|
35110
|
+
* @memberof Draggable
|
|
35111
|
+
* @function
|
|
35112
|
+
* @ignore
|
|
35113
|
+
*/
|
|
35114
|
+
destroy() {
|
|
35115
|
+
off(POINTERMOVE, this.dragMove);
|
|
35116
|
+
off(DRAGSTART, this.dragStart);
|
|
35117
|
+
off(DRAGEND, this.dragEnd);
|
|
35118
|
+
releasePointerEvent("pointerdown", this);
|
|
35119
|
+
releasePointerEvent("pointerup", this);
|
|
35120
|
+
releasePointerEvent("pointercancel", this);
|
|
35121
|
+
super.destroy();
|
|
35122
|
+
}
|
|
35123
|
+
}
|
|
35124
|
+
/**
|
|
35125
|
+
* @classdesc
|
|
35126
|
+
* a base drop target object
|
|
35127
|
+
* @see Draggable
|
|
35128
|
+
* @augments Renderable
|
|
35129
|
+
*/
|
|
35130
|
+
class DropTarget extends Renderable {
|
|
35131
|
+
/**
|
|
35132
|
+
* @param {number} x the x coordinates of the drop target
|
|
35133
|
+
* @param {number} y the y coordinates of the drop target
|
|
35134
|
+
* @param {number} width drop target width
|
|
35135
|
+
* @param {number} height drop target height
|
|
35136
|
+
*/
|
|
35137
|
+
constructor(x, y, width, height) {
|
|
35138
|
+
super(x, y, width, height);
|
|
35139
|
+
|
|
35140
|
+
this.isKinematic = false;
|
|
35141
|
+
|
|
35142
|
+
/**
|
|
35143
|
+
* constant for the overlaps method
|
|
35144
|
+
* @public
|
|
35145
|
+
* @constant
|
|
35146
|
+
* @type {string}
|
|
35147
|
+
* @name CHECKMETHOD_OVERLAP
|
|
35148
|
+
* @memberof DropTarget
|
|
35149
|
+
*/
|
|
35150
|
+
this.CHECKMETHOD_OVERLAP = "overlaps";
|
|
35151
|
+
|
|
35152
|
+
/**
|
|
35153
|
+
* constant for the contains method
|
|
35154
|
+
* @public
|
|
35155
|
+
* @constant
|
|
35156
|
+
* @type {string}
|
|
35157
|
+
* @name CHECKMETHOD_CONTAINS
|
|
35158
|
+
* @memberof DropTarget
|
|
35159
|
+
*/
|
|
35160
|
+
this.CHECKMETHOD_CONTAINS = "contains";
|
|
35161
|
+
|
|
35162
|
+
/**
|
|
35163
|
+
* the checkmethod we want to use
|
|
35164
|
+
* @public
|
|
35165
|
+
* @constant
|
|
35166
|
+
* @type {string}
|
|
35167
|
+
* @name checkMethod
|
|
35168
|
+
* @default "overlaps"
|
|
35169
|
+
* @memberof DropTarget
|
|
35170
|
+
*/
|
|
35171
|
+
this.checkMethod = this.CHECKMETHOD_OVERLAP;
|
|
35172
|
+
|
|
35173
|
+
on(DRAGEND, this.checkOnMe, this);
|
|
35174
|
+
|
|
35175
|
+
}
|
|
35176
|
+
|
|
35177
|
+
/**
|
|
35178
|
+
* Sets the collision method which is going to be used to check a valid drop
|
|
35179
|
+
* @name setCheckMethod
|
|
35180
|
+
* @memberof DropTarget
|
|
35181
|
+
* @function
|
|
35182
|
+
* @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
|
|
35183
|
+
*/
|
|
35184
|
+
setCheckMethod(checkMethod) {
|
|
35185
|
+
// We can improve this check,
|
|
35186
|
+
// because now you can use every method in theory
|
|
35187
|
+
if (typeof(this.getBounds()[this.checkMethod]) === "function") {
|
|
35188
|
+
this.checkMethod = checkMethod;
|
|
35189
|
+
}
|
|
35190
|
+
}
|
|
35191
|
+
|
|
35192
|
+
/**
|
|
35193
|
+
* Checks if a dropped entity is dropped on the current entity
|
|
35194
|
+
* @name checkOnMe
|
|
35195
|
+
* @memberof DropTarget
|
|
35196
|
+
* @function
|
|
35197
|
+
* @param {object} e the triggering event
|
|
35198
|
+
* @param {Draggable} draggable the draggable object that is dropped
|
|
35199
|
+
*/
|
|
35200
|
+
checkOnMe(e, draggable) {
|
|
35201
|
+
if (draggable && this.getBounds()[this.checkMethod](draggable.getBounds())) {
|
|
35202
|
+
// call the drop method on the current entity
|
|
35203
|
+
this.drop(draggable);
|
|
35204
|
+
}
|
|
35205
|
+
}
|
|
35206
|
+
|
|
35207
|
+
/**
|
|
35208
|
+
* Gets called when a draggable entity is dropped on the current entity
|
|
35209
|
+
* @name drop
|
|
35210
|
+
* @memberof DropTarget
|
|
35211
|
+
* @function
|
|
35212
|
+
* @param {Draggable} draggable the draggable object that is dropped
|
|
35213
|
+
*/
|
|
35214
|
+
drop() {
|
|
35215
|
+
|
|
35216
|
+
}
|
|
35217
|
+
|
|
35218
|
+
/**
|
|
35219
|
+
* Destructor
|
|
35220
|
+
* @name destroy
|
|
35221
|
+
* @memberof DropTarget
|
|
35222
|
+
* @function
|
|
35223
|
+
* @ignore
|
|
35224
|
+
*/
|
|
35225
|
+
destroy() {
|
|
35226
|
+
off(DRAGEND, this.checkOnMe);
|
|
35227
|
+
super.destroy();
|
|
35228
|
+
}
|
|
35229
|
+
}
|
|
35230
|
+
|
|
34520
35231
|
/**
|
|
34521
35232
|
* @classdesc
|
|
34522
35233
|
* Particle Container Object.
|
|
@@ -35571,226 +36282,6 @@ class Entity extends Renderable {
|
|
|
35571
36282
|
|
|
35572
36283
|
}
|
|
35573
36284
|
|
|
35574
|
-
/**
|
|
35575
|
-
* @classdesc
|
|
35576
|
-
* Used to make a game entity draggable
|
|
35577
|
-
* @augments Entity
|
|
35578
|
-
*/
|
|
35579
|
-
class DraggableEntity extends Entity {
|
|
35580
|
-
/**
|
|
35581
|
-
* @param {number} x the x coordinates of the entity object
|
|
35582
|
-
* @param {number} y the y coordinates of the entity object
|
|
35583
|
-
* @param {object} settings Entity properties (see {@link Entity})
|
|
35584
|
-
*/
|
|
35585
|
-
constructor(x, y, settings) {
|
|
35586
|
-
super(x, y, settings);
|
|
35587
|
-
this.dragging = false;
|
|
35588
|
-
this.dragId = null;
|
|
35589
|
-
this.grabOffset = new Vector2d(0, 0);
|
|
35590
|
-
this.onPointerEvent = registerPointerEvent;
|
|
35591
|
-
this.removePointerEvent = releasePointerEvent;
|
|
35592
|
-
this.initEvents();
|
|
35593
|
-
}
|
|
35594
|
-
|
|
35595
|
-
/**
|
|
35596
|
-
* Initializes the events the modules needs to listen to
|
|
35597
|
-
* It translates the pointer events to me.events
|
|
35598
|
-
* in order to make them pass through the system and to make
|
|
35599
|
-
* this module testable. Then we subscribe this module to the
|
|
35600
|
-
* transformed events.
|
|
35601
|
-
* @name initEvents
|
|
35602
|
-
* @memberof DraggableEntity
|
|
35603
|
-
* @function
|
|
35604
|
-
*/
|
|
35605
|
-
initEvents() {
|
|
35606
|
-
/**
|
|
35607
|
-
* @ignore
|
|
35608
|
-
*/
|
|
35609
|
-
this.mouseDown = function (e) {
|
|
35610
|
-
this.translatePointerEvent(e, DRAGSTART);
|
|
35611
|
-
};
|
|
35612
|
-
/**
|
|
35613
|
-
* @ignore
|
|
35614
|
-
*/
|
|
35615
|
-
this.mouseUp = function (e) {
|
|
35616
|
-
this.translatePointerEvent(e, DRAGEND);
|
|
35617
|
-
};
|
|
35618
|
-
this.onPointerEvent("pointerdown", this, this.mouseDown.bind(this));
|
|
35619
|
-
this.onPointerEvent("pointerup", this, this.mouseUp.bind(this));
|
|
35620
|
-
this.onPointerEvent("pointercancel", this, this.mouseUp.bind(this));
|
|
35621
|
-
on(POINTERMOVE, this.dragMove, this);
|
|
35622
|
-
on(DRAGSTART, this.dragStart, this);
|
|
35623
|
-
on(DRAGEND, this.dragEnd, this);
|
|
35624
|
-
}
|
|
35625
|
-
|
|
35626
|
-
/**
|
|
35627
|
-
* Translates a pointer event to a me.event
|
|
35628
|
-
* @name translatePointerEvent
|
|
35629
|
-
* @memberof DraggableEntity
|
|
35630
|
-
* @function
|
|
35631
|
-
* @param {object} e the pointer event you want to translate
|
|
35632
|
-
* @param {string} translation the me.event you want to translate the event to
|
|
35633
|
-
*/
|
|
35634
|
-
translatePointerEvent(e, translation) {
|
|
35635
|
-
emit(translation, e);
|
|
35636
|
-
}
|
|
35637
|
-
|
|
35638
|
-
/**
|
|
35639
|
-
* Gets called when the user starts dragging the entity
|
|
35640
|
-
* @name dragStart
|
|
35641
|
-
* @memberof DraggableEntity
|
|
35642
|
-
* @function
|
|
35643
|
-
* @param {object} e the pointer event
|
|
35644
|
-
* @returns {boolean} false if the object is being dragged
|
|
35645
|
-
*/
|
|
35646
|
-
dragStart(e) {
|
|
35647
|
-
if (this.dragging === false) {
|
|
35648
|
-
this.dragging = true;
|
|
35649
|
-
this.grabOffset.set(e.gameX, e.gameY);
|
|
35650
|
-
this.grabOffset.sub(this.pos);
|
|
35651
|
-
return false;
|
|
35652
|
-
}
|
|
35653
|
-
}
|
|
35654
|
-
|
|
35655
|
-
/**
|
|
35656
|
-
* Gets called when the user drags this entity around
|
|
35657
|
-
* @name dragMove
|
|
35658
|
-
* @memberof DraggableEntity
|
|
35659
|
-
* @function
|
|
35660
|
-
* @param {object} e the pointer event
|
|
35661
|
-
*/
|
|
35662
|
-
dragMove(e) {
|
|
35663
|
-
if (this.dragging === true) {
|
|
35664
|
-
this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
|
|
35665
|
-
this.pos.sub(this.grabOffset);
|
|
35666
|
-
}
|
|
35667
|
-
}
|
|
35668
|
-
|
|
35669
|
-
/**
|
|
35670
|
-
* Gets called when the user stops dragging the entity
|
|
35671
|
-
* @name dragEnd
|
|
35672
|
-
* @memberof DraggableEntity
|
|
35673
|
-
* @function
|
|
35674
|
-
* @returns {boolean} false if the object stopped being dragged
|
|
35675
|
-
*/
|
|
35676
|
-
dragEnd() {
|
|
35677
|
-
if (this.dragging === true) {
|
|
35678
|
-
this.dragging = false;
|
|
35679
|
-
return false;
|
|
35680
|
-
}
|
|
35681
|
-
}
|
|
35682
|
-
|
|
35683
|
-
/**
|
|
35684
|
-
* Destructor
|
|
35685
|
-
* @name destroy
|
|
35686
|
-
* @memberof DraggableEntity
|
|
35687
|
-
* @function
|
|
35688
|
-
*/
|
|
35689
|
-
destroy() {
|
|
35690
|
-
off(POINTERMOVE, this.dragMove);
|
|
35691
|
-
off(DRAGSTART, this.dragStart);
|
|
35692
|
-
off(DRAGEND, this.dragEnd);
|
|
35693
|
-
this.removePointerEvent("pointerdown", this);
|
|
35694
|
-
this.removePointerEvent("pointerup", this);
|
|
35695
|
-
}
|
|
35696
|
-
}
|
|
35697
|
-
|
|
35698
|
-
/**
|
|
35699
|
-
* @classdesc
|
|
35700
|
-
* Used to make a game entity a droptarget
|
|
35701
|
-
* @augments Entity
|
|
35702
|
-
*/
|
|
35703
|
-
class DroptargetEntity extends Entity {
|
|
35704
|
-
/**
|
|
35705
|
-
* @param {number} x the x coordinates of the entity object
|
|
35706
|
-
* @param {number} y the y coordinates of the entity object
|
|
35707
|
-
* @param {object} settings Entity properties (see {@link Entity})
|
|
35708
|
-
*/
|
|
35709
|
-
constructor(x, y, settings) {
|
|
35710
|
-
super(x, y, settings);
|
|
35711
|
-
/**
|
|
35712
|
-
* constant for the overlaps method
|
|
35713
|
-
* @public
|
|
35714
|
-
* @constant
|
|
35715
|
-
* @type {string}
|
|
35716
|
-
* @name CHECKMETHOD_OVERLAP
|
|
35717
|
-
* @memberof DroptargetEntity
|
|
35718
|
-
*/
|
|
35719
|
-
this.CHECKMETHOD_OVERLAP = "overlaps";
|
|
35720
|
-
/**
|
|
35721
|
-
* constant for the contains method
|
|
35722
|
-
* @public
|
|
35723
|
-
* @constant
|
|
35724
|
-
* @type {string}
|
|
35725
|
-
* @name CHECKMETHOD_CONTAINS
|
|
35726
|
-
* @memberof DroptargetEntity
|
|
35727
|
-
*/
|
|
35728
|
-
this.CHECKMETHOD_CONTAINS = "contains";
|
|
35729
|
-
/**
|
|
35730
|
-
* the checkmethod we want to use
|
|
35731
|
-
* @public
|
|
35732
|
-
* @constant
|
|
35733
|
-
* @type {string}
|
|
35734
|
-
* @name checkMethod
|
|
35735
|
-
* @memberof DroptargetEntity
|
|
35736
|
-
*/
|
|
35737
|
-
this.checkMethod = null;
|
|
35738
|
-
on(DRAGEND, this.checkOnMe, this);
|
|
35739
|
-
this.checkMethod = this[this.CHECKMETHOD_OVERLAP];
|
|
35740
|
-
}
|
|
35741
|
-
|
|
35742
|
-
/**
|
|
35743
|
-
* Sets the collision method which is going to be used to check a valid drop
|
|
35744
|
-
* @name setCheckMethod
|
|
35745
|
-
* @memberof DroptargetEntity
|
|
35746
|
-
* @function
|
|
35747
|
-
* @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
|
|
35748
|
-
*/
|
|
35749
|
-
setCheckMethod(checkMethod) {
|
|
35750
|
-
// We can improve this check,
|
|
35751
|
-
// because now you can use every method in theory
|
|
35752
|
-
if (typeof(this[checkMethod]) !== "undefined") {
|
|
35753
|
-
this.checkMethod = this[checkMethod];
|
|
35754
|
-
}
|
|
35755
|
-
}
|
|
35756
|
-
|
|
35757
|
-
/**
|
|
35758
|
-
* Checks if a dropped entity is dropped on the current entity
|
|
35759
|
-
* @name checkOnMe
|
|
35760
|
-
* @memberof DroptargetEntity
|
|
35761
|
-
* @function
|
|
35762
|
-
* @param {object} e the triggering event
|
|
35763
|
-
* @param {object} draggableEntity the draggable entity that is dropped
|
|
35764
|
-
*/
|
|
35765
|
-
checkOnMe(e, draggableEntity) {
|
|
35766
|
-
if (draggableEntity && this.checkMethod(draggableEntity.getBounds())) {
|
|
35767
|
-
// call the drop method on the current entity
|
|
35768
|
-
this.drop(draggableEntity);
|
|
35769
|
-
}
|
|
35770
|
-
}
|
|
35771
|
-
|
|
35772
|
-
/**
|
|
35773
|
-
* Gets called when a draggable entity is dropped on the current entity
|
|
35774
|
-
* @name drop
|
|
35775
|
-
* @memberof DroptargetEntity
|
|
35776
|
-
* @function
|
|
35777
|
-
* @param {object} draggableEntity the draggable entity that is dropped
|
|
35778
|
-
*/
|
|
35779
|
-
drop() {
|
|
35780
|
-
|
|
35781
|
-
}
|
|
35782
|
-
|
|
35783
|
-
/**
|
|
35784
|
-
* Destructor
|
|
35785
|
-
* @name destroy
|
|
35786
|
-
* @memberof DroptargetEntity
|
|
35787
|
-
* @function
|
|
35788
|
-
*/
|
|
35789
|
-
destroy() {
|
|
35790
|
-
off(DRAGEND, this.checkOnMe);
|
|
35791
|
-
}
|
|
35792
|
-
}
|
|
35793
|
-
|
|
35794
36285
|
/**
|
|
35795
36286
|
* placeholder for all deprecated classes and corresponding alias for backward compatibility
|
|
35796
36287
|
*/
|
|
@@ -35874,13 +36365,48 @@ Object.defineProperty(Renderer.prototype, "Texture", {
|
|
|
35874
36365
|
}
|
|
35875
36366
|
});
|
|
35876
36367
|
|
|
35877
|
-
|
|
35878
|
-
|
|
35879
|
-
|
|
35880
|
-
|
|
36368
|
+
|
|
36369
|
+
/**
|
|
36370
|
+
* @classdesc
|
|
36371
|
+
* Used to make a game entity draggable
|
|
36372
|
+
* @augments Entity
|
|
36373
|
+
* @deprecated since 10.5.0
|
|
36374
|
+
* @see Draggable
|
|
36375
|
+
*/
|
|
36376
|
+
class DraggableEntity extends Draggable {
|
|
36377
|
+
/**
|
|
36378
|
+
* @param {number} x the x coordinates of the draggable object
|
|
36379
|
+
* @param {number} y the y coordinates of the draggable object
|
|
36380
|
+
* @param {object} settings Entity properties (see {@link Entity})
|
|
36381
|
+
*/
|
|
36382
|
+
constructor(x, y, settings) {
|
|
36383
|
+
warning("DraggableEntity", "Draggable", "10.5.0");
|
|
36384
|
+
super(x, y, settings.width, settings.height);
|
|
36385
|
+
}
|
|
36386
|
+
}
|
|
36387
|
+
|
|
36388
|
+
/**
|
|
36389
|
+
* @classdesc
|
|
36390
|
+
* Used to make a game entity a droptarget
|
|
36391
|
+
* @augments Entity
|
|
36392
|
+
* @deprecated since 10.5.0
|
|
36393
|
+
* @see DropTarget
|
|
36394
|
+
*/
|
|
36395
|
+
class DroptargetEntity extends DropTarget {
|
|
36396
|
+
/**
|
|
36397
|
+
* @param {number} x the x coordinates of the draggable object
|
|
36398
|
+
* @param {number} y the y coordinates of the draggable object
|
|
36399
|
+
* @param {object} settings Entity properties (see {@link Entity})
|
|
36400
|
+
*/
|
|
36401
|
+
constructor(x, y, settings) {
|
|
36402
|
+
warning("DroptargetEntity", "DropTarget", "10.5.0");
|
|
36403
|
+
super(x, y, settings.width, settings.height);
|
|
36404
|
+
}
|
|
36405
|
+
}
|
|
35881
36406
|
|
|
35882
36407
|
// ES5 polyfills
|
|
35883
36408
|
|
|
36409
|
+
|
|
35884
36410
|
/**
|
|
35885
36411
|
* current melonJS version
|
|
35886
36412
|
* @static
|
|
@@ -35888,7 +36414,7 @@ var deprecated = /*#__PURE__*/Object.freeze({
|
|
|
35888
36414
|
* @name version
|
|
35889
36415
|
* @type {string}
|
|
35890
36416
|
*/
|
|
35891
|
-
const version = "10.
|
|
36417
|
+
const version = "10.5.2";
|
|
35892
36418
|
|
|
35893
36419
|
|
|
35894
36420
|
/**
|
|
@@ -35995,4 +36521,4 @@ device$1.onReady(function () {
|
|
|
35995
36521
|
}
|
|
35996
36522
|
});
|
|
35997
36523
|
|
|
35998
|
-
export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, DraggableEntity, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision,
|
|
36524
|
+
export { BitmapText, BitmapTextData, Body, Bounds$1 as Bounds, Camera2d, CanvasRenderer, Collectable, Color, ColorLayer, Container, Draggable, DraggableEntity, DropTarget, DroptargetEntity, Ellipse, Entity, GLShader, GUI_Object, ImageLayer, Line, math as Math, Matrix2d, Matrix3d, NineSliceSprite, ObservableVector2d, ObservableVector3d, Particle, ParticleEmitter, ParticleEmitterSettings, Pointer, Polygon, QuadTree, Rect, Renderable, Renderer, Sprite, Stage, TMXHexagonalRenderer, TMXIsometricRenderer, TMXLayer, TMXOrthogonalRenderer, TMXRenderer, TMXStaggeredRenderer, TMXTileMap, TMXTileset, TMXTilesetGroup, Text, TextureAtlas, Tile, Trigger, Tween, Vector2d, Vector3d, WebGLCompositor, WebGLRenderer, World, audio, boot, collision, device$1 as device, event, game, initialized, input, level, loader, plugin, plugins, pool, save, skipAutoInit, state, timer$1 as timer, utils, version, video, warning };
|