melonjs 10.7.1 → 10.10.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.
Files changed (74) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +29 -23
  3. package/dist/melonjs.js +2220 -1070
  4. package/dist/melonjs.min.js +4 -4
  5. package/dist/melonjs.module.d.ts +1395 -485
  6. package/dist/melonjs.module.js +2244 -1131
  7. package/package.json +17 -14
  8. package/src/camera/camera2d.js +1 -1
  9. package/src/entity/entity.js +6 -7
  10. package/src/game.js +2 -2
  11. package/src/geometries/ellipse.js +20 -21
  12. package/src/geometries/line.js +7 -7
  13. package/src/geometries/path2d.js +319 -0
  14. package/src/geometries/poly.js +27 -27
  15. package/src/geometries/rectangle.js +19 -19
  16. package/src/geometries/roundrect.js +164 -0
  17. package/src/index.js +12 -2
  18. package/src/input/gamepad.js +2 -2
  19. package/src/input/pointerevent.js +1 -1
  20. package/src/lang/deprecated.js +8 -6
  21. package/src/level/tiled/TMXLayer.js +1 -1
  22. package/src/level/tiled/TMXObject.js +9 -12
  23. package/src/level/tiled/TMXTileMap.js +23 -4
  24. package/src/level/tiled/TMXUtils.js +1 -1
  25. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  26. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  27. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  28. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  29. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  30. package/src/loader/loader.js +4 -4
  31. package/src/loader/loadingscreen.js +17 -6
  32. package/src/math/color.js +6 -5
  33. package/src/math/matrix2.js +1 -1
  34. package/src/math/matrix3.js +1 -1
  35. package/src/math/observable_vector2.js +1 -1
  36. package/src/math/observable_vector3.js +1 -1
  37. package/src/math/vector2.js +1 -1
  38. package/src/math/vector3.js +1 -1
  39. package/src/particles/emitter.js +34 -26
  40. package/src/particles/particle.js +3 -2
  41. package/src/physics/body.js +67 -51
  42. package/src/physics/bounds.js +8 -9
  43. package/src/physics/world.js +1 -1
  44. package/src/polyfill/index.js +1 -0
  45. package/src/polyfill/roundrect.js +235 -0
  46. package/src/renderable/GUI.js +5 -5
  47. package/src/renderable/collectable.js +9 -2
  48. package/src/renderable/colorlayer.js +1 -1
  49. package/src/renderable/container.js +27 -27
  50. package/src/renderable/imagelayer.js +3 -3
  51. package/src/renderable/light2d.js +115 -0
  52. package/src/renderable/renderable.js +23 -22
  53. package/src/renderable/sprite.js +15 -16
  54. package/src/renderable/trigger.js +10 -4
  55. package/src/state/stage.js +73 -3
  56. package/src/state/state.js +1 -1
  57. package/src/system/device.js +10 -8
  58. package/src/system/pooling.js +156 -149
  59. package/src/text/bitmaptext.js +1 -1
  60. package/src/text/text.js +14 -18
  61. package/src/utils/utils.js +2 -2
  62. package/src/video/canvas/canvas_renderer.js +144 -81
  63. package/src/video/renderer.js +64 -37
  64. package/src/video/{texture.js → texture/atlas.js} +8 -8
  65. package/src/video/{texture_cache.js → texture/cache.js} +4 -4
  66. package/src/video/texture/canvas_texture.js +87 -0
  67. package/src/video/webgl/glshader.js +29 -193
  68. package/src/video/webgl/utils/attributes.js +16 -0
  69. package/src/video/webgl/utils/precision.js +11 -0
  70. package/src/video/webgl/utils/program.js +58 -0
  71. package/src/video/webgl/utils/string.js +16 -0
  72. package/src/video/webgl/utils/uniforms.js +87 -0
  73. package/src/video/webgl/webgl_compositor.js +1 -14
  74. package/src/video/webgl/webgl_renderer.js +191 -231
@@ -1,6 +1,6 @@
1
1
  import earcut from "earcut";
2
2
  import Vector2d from "./../math/vector2.js";
3
- import * as pool from "./../system/pooling.js";
3
+ import pool from "./../system/pooling.js";
4
4
 
5
5
  /**
6
6
  * @classdesc
@@ -25,16 +25,16 @@ class Polygon {
25
25
  * @public
26
26
  * @type {Vector2d}
27
27
  * @name pos
28
- * @memberof Polygon#
28
+ * @memberof Polygon
29
29
  */
30
- this.pos = new Vector2d();
30
+ this.pos = pool.pull("Vector2d");
31
31
 
32
32
  /**
33
33
  * The bounding rectangle for this shape
34
34
  * @ignore
35
35
  * @type {Bounds}
36
36
  * @name _bounds
37
- * @memberof Polygon#
37
+ * @memberof Polygon
38
38
  */
39
39
  this._bounds;
40
40
 
@@ -44,7 +44,7 @@ class Polygon {
44
44
  * @public
45
45
  * @type {Vector2d[]}
46
46
  * @name points
47
- * @memberof Polygon#
47
+ * @memberof Polygon
48
48
  */
49
49
  this.points = [];
50
50
 
@@ -83,7 +83,7 @@ class Polygon {
83
83
  /**
84
84
  * set new value to the Polygon
85
85
  * @name setShape
86
- * @memberof Polygon.prototype
86
+ * @memberof Polygon
87
87
  * @function
88
88
  * @param {number} x position of the Polygon
89
89
  * @param {number} y position of the Polygon
@@ -99,7 +99,7 @@ class Polygon {
99
99
  /**
100
100
  * set the vertices defining this Polygon
101
101
  * @name setVertices
102
- * @memberof Polygon.prototype
102
+ * @memberof Polygon
103
103
  * @function
104
104
  * @param {Vector2d[]} vertices array of vector or vertice defining the Polygon
105
105
  * @returns {Polygon} this instance for objecf chaining
@@ -117,13 +117,13 @@ class Polygon {
117
117
  if (typeof vertices[0] === "object") {
118
118
  // array of {x,y} object
119
119
  vertices.forEach((vertice) => {
120
- this.points.push(new Vector2d(vertice.x, vertice.y));
120
+ this.points.push(pool.pull("Vector2d", vertice.x, vertice.y));
121
121
  });
122
122
 
123
123
  } else {
124
124
  // it's a flat array
125
125
  for (var p = 0; p < vertices.length; p += 2) {
126
- this.points.push(new Vector2d(vertices[p], vertices[p + 1]));
126
+ this.points.push(pool.pull("Vector2d", vertices[p], vertices[p + 1]));
127
127
  }
128
128
  }
129
129
  } else {
@@ -139,7 +139,7 @@ class Polygon {
139
139
  /**
140
140
  * apply the given transformation matrix to this Polygon
141
141
  * @name transform
142
- * @memberof Polygon.prototype
142
+ * @memberof Polygon
143
143
  * @function
144
144
  * @param {Matrix2d} m the transformation matrix
145
145
  * @returns {Polygon} Reference to this object for method chaining
@@ -158,7 +158,7 @@ class Polygon {
158
158
  /**
159
159
  * apply an isometric projection to this shape
160
160
  * @name toIso
161
- * @memberof Polygon.prototype
161
+ * @memberof Polygon
162
162
  * @function
163
163
  * @returns {Polygon} Reference to this object for method chaining
164
164
  */
@@ -169,7 +169,7 @@ class Polygon {
169
169
  /**
170
170
  * apply a 2d projection to this shape
171
171
  * @name to2d
172
- * @memberof Polygon.prototype
172
+ * @memberof Polygon
173
173
  * @function
174
174
  * @returns {Polygon} Reference to this object for method chaining
175
175
  */
@@ -180,7 +180,7 @@ class Polygon {
180
180
  /**
181
181
  * Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
182
182
  * @name rotate
183
- * @memberof Polygon.prototype
183
+ * @memberof Polygon
184
184
  * @function
185
185
  * @param {number} angle The angle to rotate (in radians)
186
186
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -202,7 +202,7 @@ class Polygon {
202
202
  /**
203
203
  * Scale this Polygon by the given scalar.
204
204
  * @name scale
205
- * @memberof Polygon.prototype
205
+ * @memberof Polygon
206
206
  * @function
207
207
  * @param {number} x
208
208
  * @param {number} [y=x]
@@ -224,7 +224,7 @@ class Polygon {
224
224
  /**
225
225
  * Scale this Polygon by the given vector
226
226
  * @name scaleV
227
- * @memberof Polygon.prototype
227
+ * @memberof Polygon
228
228
  * @function
229
229
  * @param {Vector2d} v
230
230
  * @returns {Polygon} Reference to this object for method chaining
@@ -237,7 +237,7 @@ class Polygon {
237
237
  * Computes the calculated collision polygon.
238
238
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
239
239
  * @name recalc
240
- * @memberof Polygon.prototype
240
+ * @memberof Polygon
241
241
  * @function
242
242
  * @returns {Polygon} Reference to this object for method chaining
243
243
  */
@@ -258,12 +258,12 @@ class Polygon {
258
258
  // Calculate the edges/normals
259
259
  for (i = 0; i < len; i++) {
260
260
  if (edges[i] === undefined) {
261
- edges[i] = new Vector2d();
261
+ edges[i] = pool.pull("Vector2d");
262
262
  }
263
263
  edges[i].copy(points[(i + 1) % len]).sub(points[i]);
264
264
 
265
265
  if (normals[i] === undefined) {
266
- normals[i] = new Vector2d();
266
+ normals[i] = pool.pull("Vector2d");
267
267
  }
268
268
  normals[i].copy(edges[i]).perp().normalize();
269
269
  }
@@ -281,7 +281,7 @@ class Polygon {
281
281
  /**
282
282
  * returns a list of indices for all triangles defined in this polygon
283
283
  * @name getIndices
284
- * @memberof Polygon.prototype
284
+ * @memberof Polygon
285
285
  * @function
286
286
  * @returns {Array} an array of vertex indices for all triangles forming this polygon.
287
287
  */
@@ -295,7 +295,7 @@ class Polygon {
295
295
  /**
296
296
  * Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
297
297
  * @name isConvex
298
- * @memberof Polygon.prototype
298
+ * @memberof Polygon
299
299
  * @function
300
300
  * @returns {boolean} true if the vertices are convex, false if not, null if not computable
301
301
  */
@@ -342,7 +342,7 @@ class Polygon {
342
342
  /**
343
343
  * translate the Polygon by the specified offset
344
344
  * @name translate
345
- * @memberof Polygon.prototype
345
+ * @memberof Polygon
346
346
  * @function
347
347
  * @param {number} x x offset
348
348
  * @param {number} y y offset
@@ -351,7 +351,7 @@ class Polygon {
351
351
  /**
352
352
  * translate the Polygon by the specified vector
353
353
  * @name translate
354
- * @memberof Polygon.prototype
354
+ * @memberof Polygon
355
355
  * @function
356
356
  * @param {Vector2d} v vector offset
357
357
  * @returns {Polygon} Reference to this object for method chaining
@@ -412,7 +412,7 @@ class Polygon {
412
412
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
413
413
  * bounding rect, as the function can be highly consuming with complex shapes)
414
414
  * @name contains
415
- * @memberof Polygon.prototype
415
+ * @memberof Polygon
416
416
  * @function
417
417
  * @param {Vector2d} point
418
418
  * @returns {boolean} true if contains
@@ -423,7 +423,7 @@ class Polygon {
423
423
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
424
424
  * bounding rect, as the function can be highly consuming with complex shapes)
425
425
  * @name contains
426
- * @memberof Polygon.prototype
426
+ * @memberof Polygon
427
427
  * @function
428
428
  * @param {number} x x coordinate
429
429
  * @param {number} y y coordinate
@@ -461,7 +461,7 @@ class Polygon {
461
461
  /**
462
462
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
463
463
  * @name getBounds
464
- * @memberof Polygon.prototype
464
+ * @memberof Polygon
465
465
  * @function
466
466
  * @returns {Bounds} this shape bounding box Rectangle object
467
467
  */
@@ -476,7 +476,7 @@ class Polygon {
476
476
  * update the bounding box for this shape.
477
477
  * @ignore
478
478
  * @name updateBounds
479
- * @memberof Polygon.prototype
479
+ * @memberof Polygon
480
480
  * @function
481
481
  * @returns {Bounds} this shape bounding box Rectangle object
482
482
  */
@@ -492,7 +492,7 @@ class Polygon {
492
492
  /**
493
493
  * clone this Polygon
494
494
  * @name clone
495
- * @memberof Polygon.prototype
495
+ * @memberof Polygon
496
496
  * @function
497
497
  * @returns {Polygon} new Polygon
498
498
  */
@@ -1,4 +1,4 @@
1
- import Vector2d from "./../math/vector2.js";
1
+ import pool from "./../system/pooling.js";
2
2
  import Polygon from "./poly.js";
3
3
 
4
4
  /**
@@ -16,10 +16,10 @@ class Rect extends Polygon {
16
16
  constructor(x, y, w, h) {
17
17
  // parent constructor
18
18
  super(x, y, [
19
- new Vector2d(0, 0), // 0, 0
20
- new Vector2d(w, 0), // 1, 0
21
- new Vector2d(w, h), // 1, 1
22
- new Vector2d(0, h) // 0, 1
19
+ pool.pull("Vector2d", 0, 0), // 0, 0
20
+ pool.pull("Vector2d", w, 0), // 1, 0
21
+ pool.pull("Vector2d", w, h), // 1, 1
22
+ pool.pull("Vector2d", 0, h) // 0, 1
23
23
  ]);
24
24
  this.shapeType = "Rectangle";
25
25
  }
@@ -32,7 +32,7 @@ class Rect extends Polygon {
32
32
  /**
33
33
  * set new value to the rectangle shape
34
34
  * @name setShape
35
- * @memberof Rect.prototype
35
+ * @memberof Rect
36
36
  * @function
37
37
  * @param {number} x position of the Rectangle
38
38
  * @param {number} y position of the Rectangle
@@ -175,7 +175,7 @@ class Rect extends Polygon {
175
175
  /**
176
176
  * center the rectangle position around the given coordinates
177
177
  * @name centerOn
178
- * @memberof Rect.prototype
178
+ * @memberof Rect
179
179
  * @function
180
180
  * @param {number} x the x coordinate around which to center this rectangle
181
181
  * @param {number} x the y coordinate around which to center this rectangle
@@ -190,7 +190,7 @@ class Rect extends Polygon {
190
190
  /**
191
191
  * resize the rectangle
192
192
  * @name resize
193
- * @memberof Rect.prototype
193
+ * @memberof Rect
194
194
  * @function
195
195
  * @param {number} w new width of the rectangle
196
196
  * @param {number} h new height of the rectangle
@@ -205,7 +205,7 @@ class Rect extends Polygon {
205
205
  /**
206
206
  * scale the rectangle
207
207
  * @name scale
208
- * @memberof Rect.prototype
208
+ * @memberof Rect
209
209
  * @function
210
210
  * @param {number} x a number representing the abscissa of the scaling vector.
211
211
  * @param {number} [y=x] a number representing the ordinate of the scaling vector.
@@ -220,7 +220,7 @@ class Rect extends Polygon {
220
220
  /**
221
221
  * clone this rectangle
222
222
  * @name clone
223
- * @memberof Rect.prototype
223
+ * @memberof Rect
224
224
  * @function
225
225
  * @returns {Rect} new rectangle
226
226
  */
@@ -231,7 +231,7 @@ class Rect extends Polygon {
231
231
  /**
232
232
  * copy the position and size of the given rectangle into this one
233
233
  * @name copy
234
- * @memberof Rect.prototype
234
+ * @memberof Rect
235
235
  * @function
236
236
  * @param {Rect} rect Source rectangle
237
237
  * @returns {Rect} new rectangle
@@ -243,7 +243,7 @@ class Rect extends Polygon {
243
243
  /**
244
244
  * merge this rectangle with another one
245
245
  * @name union
246
- * @memberof Rect.prototype
246
+ * @memberof Rect
247
247
  * @function
248
248
  * @param {Rect} rect other rectangle to union with
249
249
  * @returns {Rect} the union(ed) rectangle
@@ -265,7 +265,7 @@ class Rect extends Polygon {
265
265
  /**
266
266
  * check if this rectangle is intersecting with the specified one
267
267
  * @name overlaps
268
- * @memberof Rect.prototype
268
+ * @memberof Rect
269
269
  * @function
270
270
  * @param {Rect} rect
271
271
  * @returns {boolean} true if overlaps
@@ -282,7 +282,7 @@ class Rect extends Polygon {
282
282
  /**
283
283
  * Returns true if the rectangle contains the given rectangle
284
284
  * @name contains
285
- * @memberof Rect.prototype
285
+ * @memberof Rect
286
286
  * @function
287
287
  * @param {Rect} rect
288
288
  * @returns {boolean} true if contains
@@ -291,7 +291,7 @@ class Rect extends Polygon {
291
291
  /**
292
292
  * Returns true if the rectangle contains the given point
293
293
  * @name contains
294
- * @memberof Rect.prototype
294
+ * @memberof Rect
295
295
  * @function
296
296
  * @param {number} x x coordinate
297
297
  * @param {number} y y coordinate
@@ -337,7 +337,7 @@ class Rect extends Polygon {
337
337
  /**
338
338
  * check if this rectangle is identical to the specified one
339
339
  * @name equals
340
- * @memberof Rect.prototype
340
+ * @memberof Rect
341
341
  * @function
342
342
  * @param {Rect} rect
343
343
  * @returns {boolean} true if equals
@@ -354,7 +354,7 @@ class Rect extends Polygon {
354
354
  /**
355
355
  * determines whether all coordinates of this rectangle are finite numbers.
356
356
  * @name isFinite
357
- * @memberof Rect.prototype
357
+ * @memberof Rect
358
358
  * @function
359
359
  * @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
360
360
  */
@@ -365,12 +365,12 @@ class Rect extends Polygon {
365
365
  /**
366
366
  * Returns a polygon whose edges are the same as this box.
367
367
  * @name toPolygon
368
- * @memberof Rect.prototype
368
+ * @memberof Rect
369
369
  * @function
370
370
  * @returns {Polygon} a new Polygon that represents this rectangle.
371
371
  */
372
372
  toPolygon() {
373
- return new Polygon(
373
+ return pool.pull("Polygon",
374
374
  this.pos.x, this.pos.y, this.points
375
375
  );
376
376
  }
@@ -0,0 +1,164 @@
1
+ import Rect from "./rectangle.js";
2
+
3
+ // https://developer.chrome.com/blog/canvas2d/#round-rect
4
+
5
+ /**
6
+ * @classdesc
7
+ * a rectangle object with rounded corners
8
+ * @augments Rect
9
+ */
10
+ class RoundRect extends Rect {
11
+ /**
12
+ * @param {number} x position of the rounded rectangle
13
+ * @param {number} y position of the rounded rectangle
14
+ * @param {number} width the rectangle width
15
+ * @param {number} height the rectangle height
16
+ * @param {number} [radius=20] the radius of the rounded corner
17
+ */
18
+ constructor(x, y, width, height, radius = 20) {
19
+ // parent constructor
20
+ super(x, y, width, height);
21
+
22
+ // set the corner radius
23
+ this.radius = radius;
24
+ }
25
+
26
+ /** @ignore */
27
+ onResetEvent(x, y, w, h, radius) {
28
+ super.setShape(x, y, w, h);
29
+ this.radius = radius;
30
+ }
31
+
32
+
33
+ /**
34
+ * the radius of the rounded corner
35
+ * @public
36
+ * @type {number}
37
+ * @default 20
38
+ * @name radius
39
+ * @memberof RoundRect
40
+ */
41
+ get radius() {
42
+ return this._radius;
43
+ }
44
+ set radius(value) {
45
+ // verify the rectangle is at least as wide and tall as the rounded corners.
46
+ if (this.width < 2 * value) {
47
+ value = this.width / 2;
48
+ }
49
+ if (this.height < 2 * value) {
50
+ value = this.height / 2;
51
+ }
52
+ this._radius = value;
53
+ }
54
+
55
+ /**
56
+ * copy the position, size and radius of the given rounded rectangle into this one
57
+ * @name copy
58
+ * @memberof RoundRect
59
+ * @function
60
+ * @param {RoundRect} rrect source rounded rectangle
61
+ * @returns {RoundRect} new rectangle
62
+ */
63
+ copy(rrect) {
64
+ super.setShape(rrect.pos.x, rrect.pos.y, rrect.width, rrect.height);
65
+ this.radius = rrect.radius;
66
+ return this;
67
+ }
68
+
69
+ /**
70
+ * Returns true if the rounded rectangle contains the given point
71
+ * @name contains
72
+ * @memberof RoundRect
73
+ * @function
74
+ * @param {number} x x coordinate
75
+ * @param {number} y y coordinate
76
+ * @returns {boolean} true if contains
77
+ */
78
+
79
+ /**
80
+ * Returns true if the rounded rectangle contains the given point
81
+ * @name contains
82
+ * @memberof RoundRect
83
+ * @function
84
+ * @param {Vector2d} point
85
+ * @returns {boolean} true if contains
86
+ */
87
+ contains() {
88
+ var arg0 = arguments[0];
89
+ var _x, _y;
90
+ if (arguments.length === 2) {
91
+ // x, y
92
+ _x = arg0;
93
+ _y = arguments[1];
94
+ } else {
95
+ if (arg0 instanceof Rect) {
96
+ // good enough
97
+ return super.contains(arg0);
98
+ } else {
99
+ // vector
100
+ _x = arg0.x;
101
+ _y = arg0.y;
102
+ }
103
+ }
104
+
105
+ // check whether point is outside the bounding box
106
+ if (_x < this.left || _x >= this.right || _y < this.top || _y >= this.bottom) {
107
+ return false; // outside bounding box
108
+ }
109
+
110
+ // check whether point is within the bounding box minus radius
111
+ if ((_x >= this.left + this.radius && _x <= this.right - this.radius) || (_y >= this.top + this.radius && _y <= this.bottom - this.radius)) {
112
+ return true;
113
+ }
114
+
115
+ // check whether point is in one of the rounded corner areas
116
+ var tx, ty;
117
+ var radiusX = Math.max(0, Math.min(this.radius, this.width / 2));
118
+ var radiusY = Math.max(0, Math.min(this.radius, this.height / 2));
119
+
120
+ if (_x < this.left + radiusX && _y < this.top + radiusY) {
121
+ tx = _x - this.left - radiusX;
122
+ ty = _y - this.top - radiusY;
123
+ } else if (_x > this.right - radiusX && _y < this.top + radiusY) {
124
+ tx = _x - this.right + radiusX;
125
+ ty = _y - this.top - radiusY;
126
+ } else if (_x > this.right - radiusX && _y > this.bottom - radiusY) {
127
+ tx = _x - this.right + radiusX;
128
+ ty = _y - this.bottom + radiusY;
129
+ } else if (_x < this.left + radiusX && _y > this.bottom - radiusY) {
130
+ tx = _x - this.left - radiusX;
131
+ ty = _y - this.bottom + radiusY;
132
+ } else {
133
+ return false; // inside and not within the rounded corner area
134
+ }
135
+
136
+ // Pythagorean theorem.
137
+ return ((tx * tx) + (ty * ty) <= (radiusX * radiusY));
138
+ }
139
+
140
+ /**
141
+ * check if this RoundRect is identical to the specified one
142
+ * @name equals
143
+ * @memberof RoundRect
144
+ * @function
145
+ * @param {RoundRect} rrect
146
+ * @returns {boolean} true if equals
147
+ */
148
+ equals(rrect) {
149
+ return super.equals(rrect) && this.radius === rrect.radius;
150
+ }
151
+
152
+ /**
153
+ * clone this RoundRect
154
+ * @name clone
155
+ * @memberof RoundRect
156
+ * @function
157
+ * @returns {RoundRect} new RoundRect
158
+ */
159
+ clone() {
160
+ return new RoundRect(this.pos.x, this.pos.y, this.width, this.height, radius);
161
+ }
162
+ };
163
+
164
+ export default RoundRect;
package/src/index.js CHANGED
@@ -15,7 +15,7 @@ import { plugin, plugins } from "./plugin/plugin.js";
15
15
  import * as video from "./video/video.js";
16
16
  import save from "./system/save.js";
17
17
  import timer from "./system/timer.js";
18
- import * as pool from "./system/pooling.js";
18
+ import pool from "./system/pooling.js";
19
19
  import state from "./state/state.js";
20
20
  import level from "./level/level.js";
21
21
 
@@ -31,6 +31,7 @@ import Polygon from "./geometries/poly.js";
31
31
  import Line from "./geometries/line.js";
32
32
  import Ellipse from "./geometries/ellipse.js";
33
33
  import Rect from "./geometries/rectangle.js";
34
+ import RoundRect from "./geometries/roundrect.js";
34
35
  import QuadTree from "./physics/quadtree.js";
35
36
  import Body from "./physics/body.js";
36
37
  import Bounds from "./physics/bounds.js";
@@ -40,7 +41,8 @@ import WebGLCompositor from "./video/webgl/webgl_compositor.js";
40
41
  import Renderer from "./video/renderer.js";
41
42
  import WebGLRenderer from "./video/webgl/webgl_renderer.js";
42
43
  import CanvasRenderer from "./video/canvas/canvas_renderer.js";
43
- import { TextureAtlas } from "./video/texture.js";
44
+ import CanvasTexture from "./video/texture/canvas_texture.js";
45
+ import { TextureAtlas } from "./video/texture/atlas.js";
44
46
  import Renderable from "./renderable/renderable.js";
45
47
  import Text from "./text/text.js";
46
48
  import BitmapText from "./text/bitmaptext.js";
@@ -52,6 +54,7 @@ import NineSliceSprite from "./renderable/nineslicesprite.js";
52
54
  import GUI_Object from "./renderable/GUI.js";
53
55
  import Collectable from "./renderable/collectable.js";
54
56
  import Trigger from "./renderable/trigger.js";
57
+ import Light2d from "./renderable/light2d.js";
55
58
  import { Draggable, DropTarget } from "./renderable/dragndrop.js";
56
59
  import TMXRenderer from "./level/tiled/renderer/TMXRenderer.js";
57
60
  import TMXOrthogonalRenderer from "./level/tiled/renderer/TMXOrthogonalRenderer.js";
@@ -117,6 +120,7 @@ export {
117
120
  Line,
118
121
  Ellipse,
119
122
  Rect,
123
+ RoundRect,
120
124
  Tween,
121
125
  QuadTree,
122
126
  GLShader,
@@ -138,6 +142,7 @@ export {
138
142
  GUI_Object,
139
143
  Collectable,
140
144
  Trigger,
145
+ Light2d,
141
146
  Draggable,
142
147
  DropTarget,
143
148
  TMXRenderer,
@@ -200,6 +205,7 @@ export function boot() {
200
205
  pool.register("me.Entity", Entity);
201
206
  pool.register("me.Collectable", Collectable);
202
207
  pool.register("me.Trigger", Trigger);
208
+ pool.register("me.Light2d", Light2d);
203
209
  pool.register("me.Tween", Tween, true);
204
210
  pool.register("me.Color", Color, true);
205
211
  pool.register("me.Particle", Particle, true);
@@ -218,6 +224,7 @@ export function boot() {
218
224
  pool.register("me.Matrix2d", Matrix2d, true);
219
225
  pool.register("me.Matrix3d", Matrix3d, true);
220
226
  pool.register("me.Rect", Rect, true);
227
+ pool.register("me.RoundRect", RoundRect, true);
221
228
  pool.register("me.Polygon", Polygon, true);
222
229
  pool.register("me.Line", Line, true);
223
230
  pool.register("me.Ellipse", Ellipse, true);
@@ -227,6 +234,7 @@ export function boot() {
227
234
  pool.register("Entity", Entity);
228
235
  pool.register("Collectable", Collectable);
229
236
  pool.register("Trigger", Trigger);
237
+ pool.register("Light2d", Light2d);
230
238
  pool.register("Tween", Tween, true);
231
239
  pool.register("Color", Color, true);
232
240
  pool.register("Particle", Particle, true);
@@ -245,10 +253,12 @@ export function boot() {
245
253
  pool.register("Matrix2d", Matrix2d, true);
246
254
  pool.register("Matrix3d", Matrix3d, true);
247
255
  pool.register("Rect", Rect, true);
256
+ pool.register("RoundRect", RoundRect, true);
248
257
  pool.register("Polygon", Polygon, true);
249
258
  pool.register("Line", Line, true);
250
259
  pool.register("Ellipse", Ellipse, true);
251
260
  pool.register("Bounds", Bounds, true);
261
+ pool.register("CanvasTexture", CanvasTexture, true);
252
262
 
253
263
  // publish Boot notification
254
264
  event.emit(event.BOOT);
@@ -57,8 +57,8 @@ var leadingZeroRE = /^0+/;
57
57
  function addMapping(id, mapping) {
58
58
  var expanded_id = id.replace(vendorProductRE, function (_, a, b) {
59
59
  return (
60
- "000".substr(a.length - 1) + a + "-" +
61
- "000".substr(b.length - 1) + b + "-"
60
+ "000".slice(a.length - 1) + a + "-" +
61
+ "000".slice(b.length - 1) + b + "-"
62
62
  );
63
63
  });
64
64
  var sparse_id = id.replace(vendorProductRE, function (_, a, b) {
@@ -5,7 +5,7 @@ import { throttle } from "./../utils/function.js";
5
5
  import { remove } from "./../utils/array.js";
6
6
  import * as event from "./../system/event.js";
7
7
  import timer from "./../system/timer.js";
8
- import * as pool from "./../system/pooling.js";
8
+ import pool from "./../system/pooling.js";
9
9
  import device from "./../system/device.js";
10
10
  import Pointer from "./pointer.js";
11
11
  import Rect from "./../geometries/rectangle.js";
@@ -1,6 +1,6 @@
1
1
  import device from "./../system/device.js";
2
2
  import { requestPointerLock, exitPointerLock } from "./../input/input.js";
3
- import { TextureAtlas } from "./../video/texture.js";
3
+ import { TextureAtlas } from "./../video/texture/atlas.js";
4
4
  import Renderer from "./../video/renderer.js";
5
5
  import { Draggable, DropTarget } from "./../renderable/dragndrop.js";
6
6
 
@@ -47,9 +47,10 @@ export function warning(deprecated, replacement, version) {
47
47
 
48
48
  /**
49
49
  * @public
50
- * @type {Function}
51
50
  * @name turnOnPointerLock
52
- * @memberof device
51
+ * @function
52
+ * @returns {boolean} return true if the request was successfully submitted
53
+ * @memberof device#
53
54
  * @deprecated since 10.3.0
54
55
  * @see input.requestPointerLock
55
56
  */
@@ -60,9 +61,10 @@ device.turnOnPointerLock = function () {
60
61
 
61
62
  /**
62
63
  * @public
63
- * @type {Function}
64
64
  * @name turnOffPointerLock
65
- * @memberof device
65
+ * @function
66
+ * @returns {boolean} return true if the request was successfully submitted
67
+ * @memberof device#
66
68
  * @deprecated since 10.3.0
67
69
  * @see input.exitPointerLock
68
70
  */
@@ -74,7 +76,7 @@ device.turnOffPointerLock = function () {
74
76
  /**
75
77
  * @public
76
78
  * @name Texture
77
- * @memberof Renderer
79
+ * @memberof Renderer#
78
80
  * @deprecated since 10.4.0
79
81
  * @see TextureAtlas
80
82
  */
@@ -1,5 +1,5 @@
1
1
  import { createCanvas } from "./../../video/video.js";
2
- import * as pool from "./../../system/pooling.js";
2
+ import pool from "./../../system/pooling.js";
3
3
  import * as TMXUtils from "./TMXUtils.js";
4
4
  import Tile from "./TMXTile.js";
5
5
  import Renderable from "./../../renderable/renderable.js";