melonjs 10.4.0 → 10.5.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v10.4.0
2
+ * melonJS Game Engine - v10.5.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
@@ -14707,7 +14707,8 @@
14707
14707
  function shouldCollide(a, b) {
14708
14708
  return (
14709
14709
  a.isKinematic !== true && b.isKinematic !== true &&
14710
- a.body && b.body &&
14710
+ typeof a.body === "object" && typeof b.body === "object" &&
14711
+ !(a.body.isStatic === true && b.body.isStatic === true) &&
14711
14712
  (a.body.collisionMask & b.body.collisionType) !== 0 &&
14712
14713
  (a.body.collisionType & b.body.collisionMask) !== 0
14713
14714
  );
@@ -14820,10 +14821,10 @@
14820
14821
  response.indexShapeB = indexB;
14821
14822
 
14822
14823
  // execute the onCollision callback
14823
- if (objA.onCollision && objA.onCollision(response, objB) !== false) {
14824
+ if (objA.onCollision && objA.onCollision(response, objB) !== false && objA.body.isStatic === false) {
14824
14825
  objA.body.respondToCollision.call(objA.body, response);
14825
14826
  }
14826
- if (objB.onCollision && objB.onCollision(response, objA) !== false) {
14827
+ if (objB.onCollision && objB.onCollision(response, objA) !== false && objB.body.isStatic === false) {
14827
14828
  objB.body.respondToCollision.call(objB.body, response);
14828
14829
  }
14829
14830
  }
@@ -15183,7 +15184,8 @@
15183
15184
 
15184
15185
 
15185
15186
  /**
15186
- * either this body is a static body or not
15187
+ * Either this body is a static body or not.
15188
+ * A static body is completely fixed and can never change position or angle.
15187
15189
  * @readonly
15188
15190
  * @public
15189
15191
  * @type {boolean}
@@ -19523,12 +19525,462 @@
19523
19525
  }
19524
19526
  }
19525
19527
 
19528
+ var src = {};
19529
+
19530
+ var arraymultimap = {};
19531
+
19532
+ var multimap = {};
19533
+
19534
+ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
19535
+ var _ = { label: 0, sent: function() { if (t[0] & 1) { throw t[1]; } return t[1]; }, trys: [], ops: [] }, f, y, t, g;
19536
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
19537
+ function verb(n) { return function (v) { return step([n, v]); }; }
19538
+ function step(op) {
19539
+ if (f) { throw new TypeError("Generator is already executing."); }
19540
+ while (_) { try {
19541
+ 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; }
19542
+ if (y = 0, t) { op = [op[0] & 2, t.value]; }
19543
+ switch (op[0]) {
19544
+ case 0: case 1: t = op; break;
19545
+ case 4: _.label++; return { value: op[1], done: false };
19546
+ case 5: _.label++; y = op[1]; op = [0]; continue;
19547
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
19548
+ default:
19549
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
19550
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
19551
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
19552
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
19553
+ if (t[2]) { _.ops.pop(); }
19554
+ _.trys.pop(); continue;
19555
+ }
19556
+ op = body.call(thisArg, _);
19557
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } }
19558
+ if (op[0] & 5) { throw op[1]; } return { value: op[0] ? op[1] : void 0, done: true };
19559
+ }
19560
+ };
19561
+ var __values = (commonjsGlobal && commonjsGlobal.__values) || function(o) {
19562
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
19563
+ if (m) { return m.call(o); }
19564
+ if (o && typeof o.length === "number") { return {
19565
+ next: function () {
19566
+ if (o && i >= o.length) { o = void 0; }
19567
+ return { value: o && o[i++], done: !o };
19568
+ }
19569
+ }; }
19570
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
19571
+ };
19572
+ var __read = (commonjsGlobal && commonjsGlobal.__read) || function (o, n) {
19573
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
19574
+ if (!m) { return o; }
19575
+ var i = m.call(o), r, ar = [], e;
19576
+ try {
19577
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) { ar.push(r.value); }
19578
+ }
19579
+ catch (error) { e = { error: error }; }
19580
+ finally {
19581
+ try {
19582
+ if (r && !r.done && (m = i["return"])) { m.call(i); }
19583
+ }
19584
+ finally { if (e) { throw e.error; } }
19585
+ }
19586
+ return ar;
19587
+ };
19588
+ Object.defineProperty(multimap, "__esModule", { value: true });
19589
+ multimap.Multimap = void 0;
19590
+ var Multimap = /** @class */ (function () {
19591
+ function Multimap(operator, iterable) {
19592
+ var e_1, _a;
19593
+ this.size_ = 0;
19594
+ this.map = new Map();
19595
+ this.operator = operator;
19596
+ if (iterable) {
19597
+ try {
19598
+ for (var iterable_1 = __values(iterable), iterable_1_1 = iterable_1.next(); !iterable_1_1.done; iterable_1_1 = iterable_1.next()) {
19599
+ var _b = __read(iterable_1_1.value, 2), key = _b[0], value = _b[1];
19600
+ this.put(key, value);
19601
+ }
19602
+ }
19603
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
19604
+ finally {
19605
+ try {
19606
+ if (iterable_1_1 && !iterable_1_1.done && (_a = iterable_1.return)) { _a.call(iterable_1); }
19607
+ }
19608
+ finally { if (e_1) { throw e_1.error; } }
19609
+ }
19610
+ }
19611
+ return this;
19612
+ }
19613
+ Object.defineProperty(Multimap.prototype, "size", {
19614
+ get: function () {
19615
+ return this.size_;
19616
+ },
19617
+ enumerable: false,
19618
+ configurable: true
19619
+ });
19620
+ Multimap.prototype.get = function (key) {
19621
+ var values = this.map.get(key);
19622
+ if (values) {
19623
+ return this.operator.clone(values);
19624
+ }
19625
+ else {
19626
+ return this.operator.create();
19627
+ }
19628
+ };
19629
+ Multimap.prototype.put = function (key, value) {
19630
+ var values = this.map.get(key);
19631
+ if (!values) {
19632
+ values = this.operator.create();
19633
+ }
19634
+ if (!this.operator.add(value, values)) {
19635
+ return false;
19636
+ }
19637
+ this.map.set(key, values);
19638
+ this.size_++;
19639
+ return true;
19640
+ };
19641
+ Multimap.prototype.putAll = function (arg1, arg2) {
19642
+ var e_2, _a, e_3, _b;
19643
+ var pushed = 0;
19644
+ if (arg2) {
19645
+ var key = arg1;
19646
+ var values = arg2;
19647
+ try {
19648
+ for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) {
19649
+ var value = values_1_1.value;
19650
+ this.put(key, value);
19651
+ pushed++;
19652
+ }
19653
+ }
19654
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
19655
+ finally {
19656
+ try {
19657
+ if (values_1_1 && !values_1_1.done && (_a = values_1.return)) { _a.call(values_1); }
19658
+ }
19659
+ finally { if (e_2) { throw e_2.error; } }
19660
+ }
19661
+ }
19662
+ else if (arg1 instanceof Multimap) {
19663
+ try {
19664
+ for (var _c = __values(arg1.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
19665
+ var _e = __read(_d.value, 2), key = _e[0], value = _e[1];
19666
+ this.put(key, value);
19667
+ pushed++;
19668
+ }
19669
+ }
19670
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
19671
+ finally {
19672
+ try {
19673
+ if (_d && !_d.done && (_b = _c.return)) { _b.call(_c); }
19674
+ }
19675
+ finally { if (e_3) { throw e_3.error; } }
19676
+ }
19677
+ }
19678
+ else {
19679
+ throw new TypeError("unexpected arguments");
19680
+ }
19681
+ return pushed > 0;
19682
+ };
19683
+ Multimap.prototype.has = function (key) {
19684
+ return this.map.has(key);
19685
+ };
19686
+ Multimap.prototype.hasEntry = function (key, value) {
19687
+ return this.operator.has(value, this.get(key));
19688
+ };
19689
+ Multimap.prototype.delete = function (key) {
19690
+ this.size_ -= this.operator.size(this.get(key));
19691
+ return this.map.delete(key);
19692
+ };
19693
+ Multimap.prototype.deleteEntry = function (key, value) {
19694
+ var current = this.get(key);
19695
+ if (!this.operator.delete(value, current)) {
19696
+ return false;
19697
+ }
19698
+ this.map.set(key, current);
19699
+ this.size_--;
19700
+ return true;
19701
+ };
19702
+ Multimap.prototype.clear = function () {
19703
+ this.map.clear();
19704
+ this.size_ = 0;
19705
+ };
19706
+ Multimap.prototype.keys = function () {
19707
+ return this.map.keys();
19708
+ };
19709
+ Multimap.prototype.entries = function () {
19710
+ var self = this;
19711
+ function gen() {
19712
+ var _a, _b, _c, key, values, values_2, values_2_1, value, e_4_1, e_5_1;
19713
+ var e_5, _d, e_4, _e;
19714
+ return __generator(this, function (_f) {
19715
+ switch (_f.label) {
19716
+ case 0:
19717
+ _f.trys.push([0, 11, 12, 13]);
19718
+ _a = __values(self.map.entries()), _b = _a.next();
19719
+ _f.label = 1;
19720
+ case 1:
19721
+ if (!!_b.done) { return [3 /*break*/, 10]; }
19722
+ _c = __read(_b.value, 2), key = _c[0], values = _c[1];
19723
+ _f.label = 2;
19724
+ case 2:
19725
+ _f.trys.push([2, 7, 8, 9]);
19726
+ values_2 = (e_4 = void 0, __values(values)), values_2_1 = values_2.next();
19727
+ _f.label = 3;
19728
+ case 3:
19729
+ if (!!values_2_1.done) { return [3 /*break*/, 6]; }
19730
+ value = values_2_1.value;
19731
+ return [4 /*yield*/, [key, value]];
19732
+ case 4:
19733
+ _f.sent();
19734
+ _f.label = 5;
19735
+ case 5:
19736
+ values_2_1 = values_2.next();
19737
+ return [3 /*break*/, 3];
19738
+ case 6: return [3 /*break*/, 9];
19739
+ case 7:
19740
+ e_4_1 = _f.sent();
19741
+ e_4 = { error: e_4_1 };
19742
+ return [3 /*break*/, 9];
19743
+ case 8:
19744
+ try {
19745
+ if (values_2_1 && !values_2_1.done && (_e = values_2.return)) { _e.call(values_2); }
19746
+ }
19747
+ finally { if (e_4) { throw e_4.error; } }
19748
+ return [7 /*endfinally*/];
19749
+ case 9:
19750
+ _b = _a.next();
19751
+ return [3 /*break*/, 1];
19752
+ case 10: return [3 /*break*/, 13];
19753
+ case 11:
19754
+ e_5_1 = _f.sent();
19755
+ e_5 = { error: e_5_1 };
19756
+ return [3 /*break*/, 13];
19757
+ case 12:
19758
+ try {
19759
+ if (_b && !_b.done && (_d = _a.return)) { _d.call(_a); }
19760
+ }
19761
+ finally { if (e_5) { throw e_5.error; } }
19762
+ return [7 /*endfinally*/];
19763
+ case 13: return [2 /*return*/];
19764
+ }
19765
+ });
19766
+ }
19767
+ return gen();
19768
+ };
19769
+ Multimap.prototype.values = function () {
19770
+ var self = this;
19771
+ function gen() {
19772
+ var _a, _b, _c, value, e_6_1;
19773
+ var e_6, _d;
19774
+ return __generator(this, function (_e) {
19775
+ switch (_e.label) {
19776
+ case 0:
19777
+ _e.trys.push([0, 5, 6, 7]);
19778
+ _a = __values(self.entries()), _b = _a.next();
19779
+ _e.label = 1;
19780
+ case 1:
19781
+ if (!!_b.done) { return [3 /*break*/, 4]; }
19782
+ _c = __read(_b.value, 2), value = _c[1];
19783
+ return [4 /*yield*/, value];
19784
+ case 2:
19785
+ _e.sent();
19786
+ _e.label = 3;
19787
+ case 3:
19788
+ _b = _a.next();
19789
+ return [3 /*break*/, 1];
19790
+ case 4: return [3 /*break*/, 7];
19791
+ case 5:
19792
+ e_6_1 = _e.sent();
19793
+ e_6 = { error: e_6_1 };
19794
+ return [3 /*break*/, 7];
19795
+ case 6:
19796
+ try {
19797
+ if (_b && !_b.done && (_d = _a.return)) { _d.call(_a); }
19798
+ }
19799
+ finally { if (e_6) { throw e_6.error; } }
19800
+ return [7 /*endfinally*/];
19801
+ case 7: return [2 /*return*/];
19802
+ }
19803
+ });
19804
+ }
19805
+ return gen();
19806
+ };
19807
+ Multimap.prototype.forEach = function (callback, thisArg) {
19808
+ var e_7, _a;
19809
+ try {
19810
+ for (var _b = __values(this.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
19811
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
19812
+ callback.call(thisArg === undefined ? this : thisArg, value, key, this);
19813
+ }
19814
+ }
19815
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
19816
+ finally {
19817
+ try {
19818
+ if (_c && !_c.done && (_a = _b.return)) { _a.call(_b); }
19819
+ }
19820
+ finally { if (e_7) { throw e_7.error; } }
19821
+ }
19822
+ };
19823
+ Multimap.prototype[Symbol.iterator] = function () {
19824
+ return this.entries();
19825
+ };
19826
+ Multimap.prototype.asMap = function () {
19827
+ var e_8, _a;
19828
+ var ret = new Map();
19829
+ try {
19830
+ for (var _b = __values(this.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
19831
+ var key = _c.value;
19832
+ ret.set(key, this.operator.clone(this.get(key)));
19833
+ }
19834
+ }
19835
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
19836
+ finally {
19837
+ try {
19838
+ if (_c && !_c.done && (_a = _b.return)) { _a.call(_b); }
19839
+ }
19840
+ finally { if (e_8) { throw e_8.error; } }
19841
+ }
19842
+ return ret;
19843
+ };
19844
+ return Multimap;
19845
+ }());
19846
+ multimap.Multimap = Multimap;
19847
+
19848
+ var __extends$1 = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
19849
+ var extendStatics = function (d, b) {
19850
+ extendStatics = Object.setPrototypeOf ||
19851
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19852
+ function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } };
19853
+ return extendStatics(d, b);
19854
+ };
19855
+ return function (d, b) {
19856
+ extendStatics(d, b);
19857
+ function __() { this.constructor = d; }
19858
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19859
+ };
19860
+ })();
19861
+ Object.defineProperty(arraymultimap, "__esModule", { value: true });
19862
+ arraymultimap.ArrayMultimap = void 0;
19863
+ var multimap_1$1 = multimap;
19864
+ var ArrayMultimap = /** @class */ (function (_super) {
19865
+ __extends$1(ArrayMultimap, _super);
19866
+ function ArrayMultimap(iterable) {
19867
+ return _super.call(this, new ArrayOperator(), iterable) || this;
19868
+ }
19869
+ Object.defineProperty(ArrayMultimap.prototype, Symbol.toStringTag, {
19870
+ get: function () {
19871
+ return "ArrayMultimap";
19872
+ },
19873
+ enumerable: false,
19874
+ configurable: true
19875
+ });
19876
+ return ArrayMultimap;
19877
+ }(multimap_1$1.Multimap));
19878
+ arraymultimap.ArrayMultimap = ArrayMultimap;
19879
+ var ArrayOperator = /** @class */ (function () {
19880
+ function ArrayOperator() {
19881
+ }
19882
+ ArrayOperator.prototype.create = function () {
19883
+ return [];
19884
+ };
19885
+ ArrayOperator.prototype.clone = function (collection) {
19886
+ return collection.slice();
19887
+ };
19888
+ ArrayOperator.prototype.add = function (value, collection) {
19889
+ collection.push(value);
19890
+ return true;
19891
+ };
19892
+ ArrayOperator.prototype.size = function (collection) {
19893
+ return collection.length;
19894
+ };
19895
+ ArrayOperator.prototype.delete = function (value, collection) {
19896
+ var index = collection.indexOf(value);
19897
+ if (index > -1) {
19898
+ collection.splice(index, 1);
19899
+ return true;
19900
+ }
19901
+ return false;
19902
+ };
19903
+ ArrayOperator.prototype.has = function (value, collection) {
19904
+ return collection.includes(value);
19905
+ };
19906
+ return ArrayOperator;
19907
+ }());
19908
+
19909
+ var setmultimap = {};
19910
+
19911
+ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
19912
+ var extendStatics = function (d, b) {
19913
+ extendStatics = Object.setPrototypeOf ||
19914
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19915
+ function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } };
19916
+ return extendStatics(d, b);
19917
+ };
19918
+ return function (d, b) {
19919
+ extendStatics(d, b);
19920
+ function __() { this.constructor = d; }
19921
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19922
+ };
19923
+ })();
19924
+ Object.defineProperty(setmultimap, "__esModule", { value: true });
19925
+ setmultimap.SetMultimap = void 0;
19926
+ var multimap_1 = multimap;
19927
+ var SetMultimap = /** @class */ (function (_super) {
19928
+ __extends(SetMultimap, _super);
19929
+ function SetMultimap(iterable) {
19930
+ return _super.call(this, new SetOperator(), iterable) || this;
19931
+ }
19932
+ Object.defineProperty(SetMultimap.prototype, Symbol.toStringTag, {
19933
+ get: function () {
19934
+ return "SetMultimap";
19935
+ },
19936
+ enumerable: false,
19937
+ configurable: true
19938
+ });
19939
+ return SetMultimap;
19940
+ }(multimap_1.Multimap));
19941
+ setmultimap.SetMultimap = SetMultimap;
19942
+ var SetOperator = /** @class */ (function () {
19943
+ function SetOperator() {
19944
+ }
19945
+ SetOperator.prototype.create = function () {
19946
+ return new Set();
19947
+ };
19948
+ SetOperator.prototype.clone = function (collection) {
19949
+ return new Set(collection);
19950
+ };
19951
+ SetOperator.prototype.add = function (value, collection) {
19952
+ var prev = collection.size;
19953
+ collection.add(value);
19954
+ return prev !== collection.size;
19955
+ };
19956
+ SetOperator.prototype.size = function (collection) {
19957
+ return collection.size;
19958
+ };
19959
+ SetOperator.prototype.delete = function (value, collection) {
19960
+ return collection.delete(value);
19961
+ };
19962
+ SetOperator.prototype.has = function (value, collection) {
19963
+ return collection.has(value);
19964
+ };
19965
+ return SetOperator;
19966
+ }());
19967
+
19968
+ (function (exports) {
19969
+ Object.defineProperty(exports, "__esModule", { value: true });
19970
+ exports.SetMultimap = exports.ArrayMultimap = void 0;
19971
+ var arraymultimap_1 = arraymultimap;
19972
+ Object.defineProperty(exports, "ArrayMultimap", { enumerable: true, get: function () { return arraymultimap_1.ArrayMultimap; } });
19973
+ var setmultimap_1 = setmultimap;
19974
+ Object.defineProperty(exports, "SetMultimap", { enumerable: true, get: function () { return setmultimap_1.SetMultimap; } });
19975
+ }(src));
19976
+
19526
19977
  /**
19527
19978
  * a basic texture cache object
19528
19979
  * @ignore
19529
19980
  */
19530
19981
  var TextureCache = function TextureCache(max_size) {
19531
- this.cache = new Map();
19982
+ // cache uses an array to allow for duplicated key
19983
+ this.cache = new src.ArrayMultimap();
19532
19984
  this.tinted = new Map();
19533
19985
  this.units = new Map();
19534
19986
  this.max_size = max_size || Infinity;
@@ -19562,13 +20014,29 @@
19562
20014
  * @ignore
19563
20015
  */
19564
20016
  TextureCache.prototype.get = function get (image, atlas) {
19565
- if (!this.cache.has(image)) {
20017
+ var entry;
20018
+
20019
+ if (typeof atlas === "undefined") {
20020
+ entry = this.cache.get(image)[0];
20021
+ } else {
20022
+ // manage cases where a specific atlas is specified
20023
+ this.cache.forEach(function (value, key) {
20024
+ var _atlas = value.getAtlas();
20025
+ if (key === image && _atlas[0].width === atlas.framewidth && _atlas[0].height === atlas.frameheight) {
20026
+ entry = value;
20027
+ }
20028
+ });
20029
+ }
20030
+
20031
+ if (typeof entry === "undefined") {
19566
20032
  if (!atlas) {
19567
20033
  atlas = createAtlas(image.width, image.height, image.src ? getBasename(image.src) : undefined);
19568
20034
  }
19569
- this.set(image, new TextureAtlas(atlas, image, false));
20035
+ entry = new TextureAtlas(atlas, image, false);
20036
+ this.set(image, entry);
19570
20037
  }
19571
- return this.cache.get(image);
20038
+
20039
+ return entry;
19572
20040
  };
19573
20041
 
19574
20042
  /**
@@ -19613,7 +20081,7 @@
19613
20081
  "(" + width + "x" + height + ")"
19614
20082
  );
19615
20083
  }
19616
- this.cache.set(image, texture);
20084
+ return this.cache.put(image, texture);
19617
20085
  };
19618
20086
 
19619
20087
  /**
@@ -25425,6 +25893,8 @@
25425
25893
  if (isCollisionGroup && !settings.name && obj.body) {
25426
25894
  // configure the body accordingly
25427
25895
  obj.body.collisionType = collision.types.WORLD_SHAPE;
25896
+ // mark collision shapes as static
25897
+ obj.body.isStatic = true;
25428
25898
  }
25429
25899
 
25430
25900
  //apply group opacity value to the child objects if group are merged
@@ -31430,10 +31900,10 @@
31430
31900
  * this can be overridden by the plugin
31431
31901
  * @public
31432
31902
  * @type {string}
31433
- * @default "10.4.0"
31903
+ * @default "10.5.0"
31434
31904
  * @name plugin.Base#version
31435
31905
  */
31436
- this.version = "10.4.0";
31906
+ this.version = "10.5.0";
31437
31907
  };
31438
31908
 
31439
31909
  /**
@@ -34459,6 +34929,227 @@
34459
34929
  return Trigger;
34460
34930
  }(Renderable));
34461
34931
 
34932
+ /**
34933
+ * @classdesc
34934
+ * A Draggable base object
34935
+ * @see DropTarget
34936
+ * @augments Renderable
34937
+ */
34938
+ var Draggable = /*@__PURE__*/(function (Renderable) {
34939
+ function Draggable(x, y, width, height) {
34940
+ Renderable.call(this, x, y, width, height);
34941
+ this.isKinematic = false;
34942
+ this.dragging = false;
34943
+ this.dragId = null;
34944
+ this.grabOffset = new Vector2d(0, 0);
34945
+ this.initEvents();
34946
+ }
34947
+
34948
+ if ( Renderable ) Draggable.__proto__ = Renderable;
34949
+ Draggable.prototype = Object.create( Renderable && Renderable.prototype );
34950
+ Draggable.prototype.constructor = Draggable;
34951
+
34952
+ /**
34953
+ * Initializes the events the modules needs to listen to
34954
+ * It translates the pointer events to me.events
34955
+ * in order to make them pass through the system and to make
34956
+ * this module testable. Then we subscribe this module to the
34957
+ * transformed events.
34958
+ * @name initEvents
34959
+ * @memberof Draggable
34960
+ * @function
34961
+ * @private
34962
+ */
34963
+ Draggable.prototype.initEvents = function initEvents () {
34964
+ var this$1$1 = this;
34965
+
34966
+ registerPointerEvent("pointerdown", this, function (e) { emit(DRAGSTART, e, this$1$1); });
34967
+ registerPointerEvent("pointerup", this, function (e) { emit(DRAGEND, e, this$1$1); });
34968
+ registerPointerEvent("pointercancel", this, function (e) { emit(DRAGEND, e, this$1$1); });
34969
+ on(POINTERMOVE, this.dragMove.bind(this));
34970
+ on(DRAGSTART, function (e, draggable) {
34971
+ if (draggable === this$1$1) {
34972
+ this$1$1.dragStart(e);
34973
+ }
34974
+ });
34975
+ on(DRAGEND, function (e, draggable) {
34976
+ if (draggable === this$1$1) {
34977
+ this$1$1.dragEnd(e);
34978
+ }
34979
+ });
34980
+ };
34981
+
34982
+ /**
34983
+ * Gets called when the user starts dragging the entity
34984
+ * @name dragStart
34985
+ * @memberof Draggable
34986
+ * @function
34987
+ * @param {object} e the pointer event
34988
+ * @returns {boolean} false if the object is being dragged
34989
+ */
34990
+ Draggable.prototype.dragStart = function dragStart (e) {
34991
+ if (this.dragging === false) {
34992
+ this.dragging = true;
34993
+ this.grabOffset.set(e.gameX, e.gameY);
34994
+ this.grabOffset.sub(this.pos);
34995
+ return false;
34996
+ }
34997
+ };
34998
+
34999
+ /**
35000
+ * Gets called when the user drags this entity around
35001
+ * @name dragMove
35002
+ * @memberof Draggable
35003
+ * @function
35004
+ * @param {object} e the pointer event
35005
+ */
35006
+ Draggable.prototype.dragMove = function dragMove (e) {
35007
+ if (this.dragging === true) {
35008
+ this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
35009
+ this.pos.sub(this.grabOffset);
35010
+ }
35011
+ };
35012
+
35013
+ /**
35014
+ * Gets called when the user stops dragging the entity
35015
+ * @name dragEnd
35016
+ * @memberof Draggable
35017
+ * @function
35018
+ * @returns {boolean} false if the object stopped being dragged
35019
+ */
35020
+ Draggable.prototype.dragEnd = function dragEnd () {
35021
+ if (this.dragging === true) {
35022
+ this.dragging = false;
35023
+ return false;
35024
+ }
35025
+ };
35026
+
35027
+ /**
35028
+ * Destructor
35029
+ * @name destroy
35030
+ * @memberof Draggable
35031
+ * @function
35032
+ * @private
35033
+ */
35034
+ Draggable.prototype.destroy = function destroy () {
35035
+ off(POINTERMOVE, this.dragMove);
35036
+ off(DRAGSTART, this.dragStart);
35037
+ off(DRAGEND, this.dragEnd);
35038
+ releasePointerEvent("pointerdown", this);
35039
+ releasePointerEvent("pointerup", this);
35040
+ releasePointerEvent("pointercancel", this);
35041
+ Renderable.prototype.destroy.call(this);
35042
+ };
35043
+
35044
+ return Draggable;
35045
+ }(Renderable));
35046
+ /**
35047
+ * @classdesc
35048
+ * a base drop target object
35049
+ * @see Draggable
35050
+ * @augments Renderable
35051
+ */
35052
+ var DropTarget = /*@__PURE__*/(function (Renderable) {
35053
+ function DropTarget(x, y, width, height) {
35054
+ Renderable.call(this, x, y, width, height);
35055
+
35056
+ this.isKinematic = false;
35057
+
35058
+ /**
35059
+ * constant for the overlaps method
35060
+ * @public
35061
+ * @constant
35062
+ * @type {string}
35063
+ * @name CHECKMETHOD_OVERLAP
35064
+ * @memberof DropTarget
35065
+ */
35066
+ this.CHECKMETHOD_OVERLAP = "overlaps";
35067
+
35068
+ /**
35069
+ * constant for the contains method
35070
+ * @public
35071
+ * @constant
35072
+ * @type {string}
35073
+ * @name CHECKMETHOD_CONTAINS
35074
+ * @memberof DropTarget
35075
+ */
35076
+ this.CHECKMETHOD_CONTAINS = "contains";
35077
+
35078
+ /**
35079
+ * the checkmethod we want to use
35080
+ * @public
35081
+ * @constant
35082
+ * @type {string}
35083
+ * @name checkMethod
35084
+ * @default "overlaps"
35085
+ * @memberof DropTarget
35086
+ */
35087
+ this.checkMethod = this.CHECKMETHOD_OVERLAP;
35088
+
35089
+ on(DRAGEND, this.checkOnMe, this);
35090
+
35091
+ }
35092
+
35093
+ if ( Renderable ) DropTarget.__proto__ = Renderable;
35094
+ DropTarget.prototype = Object.create( Renderable && Renderable.prototype );
35095
+ DropTarget.prototype.constructor = DropTarget;
35096
+
35097
+ /**
35098
+ * Sets the collision method which is going to be used to check a valid drop
35099
+ * @name setCheckMethod
35100
+ * @memberof DropTarget
35101
+ * @function
35102
+ * @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
35103
+ */
35104
+ DropTarget.prototype.setCheckMethod = function setCheckMethod (checkMethod) {
35105
+ // We can improve this check,
35106
+ // because now you can use every method in theory
35107
+ if (typeof(this.getBounds()[this.checkMethod]) === "function") {
35108
+ this.checkMethod = checkMethod;
35109
+ }
35110
+ };
35111
+
35112
+ /**
35113
+ * Checks if a dropped entity is dropped on the current entity
35114
+ * @name checkOnMe
35115
+ * @memberof DropTarget
35116
+ * @function
35117
+ * @param {object} e the triggering event
35118
+ * @param {Draggable} draggable the draggable object that is dropped
35119
+ */
35120
+ DropTarget.prototype.checkOnMe = function checkOnMe (e, draggable) {
35121
+ if (draggable && this.getBounds()[this.checkMethod](draggable.getBounds())) {
35122
+ // call the drop method on the current entity
35123
+ this.drop(draggable);
35124
+ }
35125
+ };
35126
+
35127
+ /**
35128
+ * Gets called when a draggable entity is dropped on the current entity
35129
+ * @name drop
35130
+ * @memberof DropTarget
35131
+ * @function
35132
+ * @param {Draggable} draggable the draggable object that is dropped
35133
+ */
35134
+ DropTarget.prototype.drop = function drop () {
35135
+
35136
+ };
35137
+
35138
+ /**
35139
+ * Destructor
35140
+ * @name destroy
35141
+ * @memberof DropTarget
35142
+ * @function
35143
+ * @private
35144
+ */
35145
+ DropTarget.prototype.destroy = function destroy () {
35146
+ off(DRAGEND, this.checkOnMe);
35147
+ Renderable.prototype.destroy.call(this);
35148
+ };
35149
+
35150
+ return DropTarget;
35151
+ }(Renderable));
35152
+
34462
35153
  /**
34463
35154
  * @classdesc
34464
35155
  * Particle Container Object.
@@ -35517,228 +36208,6 @@
35517
36208
  return Entity;
35518
36209
  }(Renderable));
35519
36210
 
35520
- /**
35521
- * @classdesc
35522
- * Used to make a game entity draggable
35523
- * @augments Entity
35524
- */
35525
- var DraggableEntity = /*@__PURE__*/(function (Entity) {
35526
- function DraggableEntity(x, y, settings) {
35527
- Entity.call(this, x, y, settings);
35528
- this.dragging = false;
35529
- this.dragId = null;
35530
- this.grabOffset = new Vector2d(0, 0);
35531
- this.onPointerEvent = registerPointerEvent;
35532
- this.removePointerEvent = releasePointerEvent;
35533
- this.initEvents();
35534
- }
35535
-
35536
- if ( Entity ) DraggableEntity.__proto__ = Entity;
35537
- DraggableEntity.prototype = Object.create( Entity && Entity.prototype );
35538
- DraggableEntity.prototype.constructor = DraggableEntity;
35539
-
35540
- /**
35541
- * Initializes the events the modules needs to listen to
35542
- * It translates the pointer events to me.events
35543
- * in order to make them pass through the system and to make
35544
- * this module testable. Then we subscribe this module to the
35545
- * transformed events.
35546
- * @name initEvents
35547
- * @memberof DraggableEntity
35548
- * @function
35549
- */
35550
- DraggableEntity.prototype.initEvents = function initEvents () {
35551
- /**
35552
- * @ignore
35553
- */
35554
- this.mouseDown = function (e) {
35555
- this.translatePointerEvent(e, DRAGSTART);
35556
- };
35557
- /**
35558
- * @ignore
35559
- */
35560
- this.mouseUp = function (e) {
35561
- this.translatePointerEvent(e, DRAGEND);
35562
- };
35563
- this.onPointerEvent("pointerdown", this, this.mouseDown.bind(this));
35564
- this.onPointerEvent("pointerup", this, this.mouseUp.bind(this));
35565
- this.onPointerEvent("pointercancel", this, this.mouseUp.bind(this));
35566
- on(POINTERMOVE, this.dragMove, this);
35567
- on(DRAGSTART, this.dragStart, this);
35568
- on(DRAGEND, this.dragEnd, this);
35569
- };
35570
-
35571
- /**
35572
- * Translates a pointer event to a me.event
35573
- * @name translatePointerEvent
35574
- * @memberof DraggableEntity
35575
- * @function
35576
- * @param {object} e the pointer event you want to translate
35577
- * @param {string} translation the me.event you want to translate the event to
35578
- */
35579
- DraggableEntity.prototype.translatePointerEvent = function translatePointerEvent (e, translation) {
35580
- emit(translation, e);
35581
- };
35582
-
35583
- /**
35584
- * Gets called when the user starts dragging the entity
35585
- * @name dragStart
35586
- * @memberof DraggableEntity
35587
- * @function
35588
- * @param {object} e the pointer event
35589
- * @returns {boolean} false if the object is being dragged
35590
- */
35591
- DraggableEntity.prototype.dragStart = function dragStart (e) {
35592
- if (this.dragging === false) {
35593
- this.dragging = true;
35594
- this.grabOffset.set(e.gameX, e.gameY);
35595
- this.grabOffset.sub(this.pos);
35596
- return false;
35597
- }
35598
- };
35599
-
35600
- /**
35601
- * Gets called when the user drags this entity around
35602
- * @name dragMove
35603
- * @memberof DraggableEntity
35604
- * @function
35605
- * @param {object} e the pointer event
35606
- */
35607
- DraggableEntity.prototype.dragMove = function dragMove (e) {
35608
- if (this.dragging === true) {
35609
- this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
35610
- this.pos.sub(this.grabOffset);
35611
- }
35612
- };
35613
-
35614
- /**
35615
- * Gets called when the user stops dragging the entity
35616
- * @name dragEnd
35617
- * @memberof DraggableEntity
35618
- * @function
35619
- * @returns {boolean} false if the object stopped being dragged
35620
- */
35621
- DraggableEntity.prototype.dragEnd = function dragEnd () {
35622
- if (this.dragging === true) {
35623
- this.dragging = false;
35624
- return false;
35625
- }
35626
- };
35627
-
35628
- /**
35629
- * Destructor
35630
- * @name destroy
35631
- * @memberof DraggableEntity
35632
- * @function
35633
- */
35634
- DraggableEntity.prototype.destroy = function destroy () {
35635
- off(POINTERMOVE, this.dragMove);
35636
- off(DRAGSTART, this.dragStart);
35637
- off(DRAGEND, this.dragEnd);
35638
- this.removePointerEvent("pointerdown", this);
35639
- this.removePointerEvent("pointerup", this);
35640
- };
35641
-
35642
- return DraggableEntity;
35643
- }(Entity));
35644
-
35645
- /**
35646
- * @classdesc
35647
- * Used to make a game entity a droptarget
35648
- * @augments Entity
35649
- */
35650
- var DroptargetEntity = /*@__PURE__*/(function (Entity) {
35651
- function DroptargetEntity(x, y, settings) {
35652
- Entity.call(this, x, y, settings);
35653
- /**
35654
- * constant for the overlaps method
35655
- * @public
35656
- * @constant
35657
- * @type {string}
35658
- * @name CHECKMETHOD_OVERLAP
35659
- * @memberof DroptargetEntity
35660
- */
35661
- this.CHECKMETHOD_OVERLAP = "overlaps";
35662
- /**
35663
- * constant for the contains method
35664
- * @public
35665
- * @constant
35666
- * @type {string}
35667
- * @name CHECKMETHOD_CONTAINS
35668
- * @memberof DroptargetEntity
35669
- */
35670
- this.CHECKMETHOD_CONTAINS = "contains";
35671
- /**
35672
- * the checkmethod we want to use
35673
- * @public
35674
- * @constant
35675
- * @type {string}
35676
- * @name checkMethod
35677
- * @memberof DroptargetEntity
35678
- */
35679
- this.checkMethod = null;
35680
- on(DRAGEND, this.checkOnMe, this);
35681
- this.checkMethod = this[this.CHECKMETHOD_OVERLAP];
35682
- }
35683
-
35684
- if ( Entity ) DroptargetEntity.__proto__ = Entity;
35685
- DroptargetEntity.prototype = Object.create( Entity && Entity.prototype );
35686
- DroptargetEntity.prototype.constructor = DroptargetEntity;
35687
-
35688
- /**
35689
- * Sets the collision method which is going to be used to check a valid drop
35690
- * @name setCheckMethod
35691
- * @memberof DroptargetEntity
35692
- * @function
35693
- * @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
35694
- */
35695
- DroptargetEntity.prototype.setCheckMethod = function setCheckMethod (checkMethod) {
35696
- // We can improve this check,
35697
- // because now you can use every method in theory
35698
- if (typeof(this[checkMethod]) !== "undefined") {
35699
- this.checkMethod = this[checkMethod];
35700
- }
35701
- };
35702
-
35703
- /**
35704
- * Checks if a dropped entity is dropped on the current entity
35705
- * @name checkOnMe
35706
- * @memberof DroptargetEntity
35707
- * @function
35708
- * @param {object} e the triggering event
35709
- * @param {object} draggableEntity the draggable entity that is dropped
35710
- */
35711
- DroptargetEntity.prototype.checkOnMe = function checkOnMe (e, draggableEntity) {
35712
- if (draggableEntity && this.checkMethod(draggableEntity.getBounds())) {
35713
- // call the drop method on the current entity
35714
- this.drop(draggableEntity);
35715
- }
35716
- };
35717
-
35718
- /**
35719
- * Gets called when a draggable entity is dropped on the current entity
35720
- * @name drop
35721
- * @memberof DroptargetEntity
35722
- * @function
35723
- * @param {object} draggableEntity the draggable entity that is dropped
35724
- */
35725
- DroptargetEntity.prototype.drop = function drop () {
35726
-
35727
- };
35728
-
35729
- /**
35730
- * Destructor
35731
- * @name destroy
35732
- * @memberof DroptargetEntity
35733
- * @function
35734
- */
35735
- DroptargetEntity.prototype.destroy = function destroy () {
35736
- off(DRAGEND, this.checkOnMe);
35737
- };
35738
-
35739
- return DroptargetEntity;
35740
- }(Entity));
35741
-
35742
36211
  /**
35743
36212
  * placeholder for all deprecated classes and corresponding alias for backward compatibility
35744
36213
  */
@@ -35822,13 +36291,50 @@
35822
36291
  }
35823
36292
  });
35824
36293
 
35825
- var deprecated = /*#__PURE__*/Object.freeze({
35826
- __proto__: null,
35827
- warning: warning
35828
- });
36294
+
36295
+ /**
36296
+ * @classdesc
36297
+ * Used to make a game entity draggable
36298
+ * @augments Entity
36299
+ * @deprecated since 10.5.0
36300
+ * @see Draggable
36301
+ */
36302
+ var DraggableEntity = /*@__PURE__*/(function (Draggable) {
36303
+ function DraggableEntity(x, y, settings) {
36304
+ warning("DraggableEntity", "Draggable", "10.5.0");
36305
+ Draggable.call(this, x, y, settings.width, settings.height);
36306
+ }
36307
+
36308
+ if ( Draggable ) DraggableEntity.__proto__ = Draggable;
36309
+ DraggableEntity.prototype = Object.create( Draggable && Draggable.prototype );
36310
+ DraggableEntity.prototype.constructor = DraggableEntity;
36311
+
36312
+ return DraggableEntity;
36313
+ }(Draggable));
36314
+
36315
+ /**
36316
+ * @classdesc
36317
+ * Used to make a game entity a droptarget
36318
+ * @augments Entity
36319
+ * @deprecated since 10.5.0
36320
+ * @see DropTarget
36321
+ */
36322
+ var DroptargetEntity = /*@__PURE__*/(function (DropTarget) {
36323
+ function DroptargetEntity(x, y, settings) {
36324
+ warning("DroptargetEntity", "DropTarget", "10.5.0");
36325
+ DropTarget.call(this, x, y, settings.width, settings.height);
36326
+ }
36327
+
36328
+ if ( DropTarget ) DroptargetEntity.__proto__ = DropTarget;
36329
+ DroptargetEntity.prototype = Object.create( DropTarget && DropTarget.prototype );
36330
+ DroptargetEntity.prototype.constructor = DroptargetEntity;
36331
+
36332
+ return DroptargetEntity;
36333
+ }(DropTarget));
35829
36334
 
35830
36335
  // ES5 polyfills
35831
36336
 
36337
+
35832
36338
  /**
35833
36339
  * current melonJS version
35834
36340
  * @static
@@ -35836,7 +36342,7 @@
35836
36342
  * @name version
35837
36343
  * @type {string}
35838
36344
  */
35839
- var version = "10.4.0";
36345
+ var version = "10.5.0";
35840
36346
 
35841
36347
 
35842
36348
  /**
@@ -35953,7 +36459,9 @@
35953
36459
  exports.Color = Color;
35954
36460
  exports.ColorLayer = ColorLayer;
35955
36461
  exports.Container = Container;
36462
+ exports.Draggable = Draggable;
35956
36463
  exports.DraggableEntity = DraggableEntity;
36464
+ exports.DropTarget = DropTarget;
35957
36465
  exports.DroptargetEntity = DroptargetEntity;
35958
36466
  exports.Ellipse = Ellipse;
35959
36467
  exports.Entity = Entity;
@@ -36000,7 +36508,6 @@
36000
36508
  exports.audio = audio;
36001
36509
  exports.boot = boot;
36002
36510
  exports.collision = collision;
36003
- exports.deprecated = deprecated;
36004
36511
  exports.device = device$1;
36005
36512
  exports.event = event;
36006
36513
  exports.game = game;
@@ -36017,6 +36524,7 @@
36017
36524
  exports.utils = utils;
36018
36525
  exports.version = version;
36019
36526
  exports.video = video;
36527
+ exports.warning = warning;
36020
36528
 
36021
36529
  Object.defineProperty(exports, '__esModule', { value: true });
36022
36530