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
@@ -233,9 +233,45 @@ export class Body {
233
233
  * body.collisionType = me.collision.types.PLAYER_OBJECT;
234
234
  */
235
235
  public collisionType: number;
236
- vel: Vector2d;
237
- force: Vector2d;
238
- friction: Vector2d;
236
+ /**
237
+ * body velocity
238
+ * @public
239
+ * @type {Vector2d}
240
+ * @default <0,0>
241
+ */
242
+ public vel: Vector2d;
243
+ /**
244
+ * body force or acceleration (automatically) applied to the body.
245
+ * when defining a force, user should also define a max velocity
246
+ * @public
247
+ * @type {Vector2d}
248
+ * @default <0,0>
249
+ * @see Body.setMaxVelocity
250
+ * @example
251
+ * // define a default maximum acceleration, initial force and friction
252
+ * this.body.force.set(0, 0);
253
+ * this.body.friction.set(0.4, 0);
254
+ * this.body.setMaxVelocity(3, 15);
255
+ *
256
+ * // apply a postive or negative force when pressing left of right key
257
+ * update(dt) {
258
+ * if (me.input.isKeyPressed("left")) {
259
+ * this.body.force.x = -this.body.maxVel.x;
260
+ * } else if (me.input.isKeyPressed("right")) {
261
+ * this.body.force.x = this.body.maxVel.x;
262
+ * } else {
263
+ * this.body.force.x = 0;
264
+ * }
265
+ * }
266
+ */
267
+ public force: Vector2d;
268
+ /**
269
+ * body friction
270
+ * @public
271
+ * @type {Vector2d}
272
+ * @default <0,0>
273
+ */
274
+ public friction: Vector2d;
239
275
  /**
240
276
  * the body bouciness level when colliding with other solid bodies :
241
277
  * a value of 0 will not bounce, a value of 1 will fully rebound.
@@ -251,7 +287,13 @@ export class Body {
251
287
  * @default 1
252
288
  */
253
289
  public mass: number;
254
- maxVel: Vector2d;
290
+ /**
291
+ * max velocity (to limit body velocity)
292
+ * @public
293
+ * @type {Vector2d}
294
+ * @default <490,490>
295
+ */
296
+ public maxVel: Vector2d;
255
297
  /**
256
298
  * Either this body is a static body or not.
257
299
  * A static body is completely fixed and can never change position or angle.
@@ -484,6 +526,7 @@ declare class Bounds$1 {
484
526
  * @param {Vector2d[]} [vertices] an array of me.Vector2d points
485
527
  */
486
528
  constructor(vertices?: Vector2d[]);
529
+ _center: Vector2d;
487
530
  /**
488
531
  * @ignore
489
532
  */
@@ -496,7 +539,6 @@ declare class Bounds$1 {
496
539
  x: number;
497
540
  y: number;
498
541
  };
499
- _center: Vector2d;
500
542
  /**
501
543
  * reset the bound
502
544
  * @name clear
@@ -864,7 +906,7 @@ export class Camera2d extends Renderable {
864
906
  * @param {number} h deadzone height
865
907
  */
866
908
  setDeadzone(w: number, h: number): void;
867
- deadzone: Rect;
909
+ deadzone: Rect$1;
868
910
  /**
869
911
  * resize the camera
870
912
  * @name resize
@@ -1074,7 +1116,7 @@ export class CanvasRenderer extends Renderer {
1074
1116
  /**
1075
1117
  * Reset the canvas transform to identity
1076
1118
  * @name resetTransform
1077
- * @memberof CanvasRenderer.prototype
1119
+ * @memberof CanvasRenderer
1078
1120
  * @function
1079
1121
  */
1080
1122
  resetTransform(): void;
@@ -1091,7 +1133,7 @@ export class CanvasRenderer extends Renderer {
1091
1133
  * <img src="images/screen-blendmode.png" width="510"/> <br>
1092
1134
  * @name setBlendMode
1093
1135
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
1094
- * @memberof CanvasRenderer.prototype
1136
+ * @memberof CanvasRenderer
1095
1137
  * @function
1096
1138
  * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "additive", "screen"
1097
1139
  * @param {CanvasRenderingContext2D} [context]
@@ -1100,14 +1142,14 @@ export class CanvasRenderer extends Renderer {
1100
1142
  /**
1101
1143
  * render the main framebuffer on screen
1102
1144
  * @name flush
1103
- * @memberof CanvasRenderer.prototype
1145
+ * @memberof CanvasRenderer
1104
1146
  * @function
1105
1147
  */
1106
1148
  flush(): void;
1107
1149
  /**
1108
1150
  * Clears the main framebuffer with the given color
1109
1151
  * @name clearColor
1110
- * @memberof CanvasRenderer.prototype
1152
+ * @memberof CanvasRenderer
1111
1153
  * @function
1112
1154
  * @param {Color|string} [color="#000000"] CSS color.
1113
1155
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
@@ -1116,7 +1158,7 @@ export class CanvasRenderer extends Renderer {
1116
1158
  /**
1117
1159
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
1118
1160
  * @name clearRect
1119
- * @memberof CanvasRenderer.prototype
1161
+ * @memberof CanvasRenderer
1120
1162
  * @function
1121
1163
  * @param {number} x x axis of the coordinate for the rectangle starting point.
1122
1164
  * @param {number} y y axis of the coordinate for the rectangle starting point.
@@ -1127,7 +1169,7 @@ export class CanvasRenderer extends Renderer {
1127
1169
  /**
1128
1170
  * Create a pattern with the specified repetition
1129
1171
  * @name createPattern
1130
- * @memberof CanvasRenderer.prototype
1172
+ * @memberof CanvasRenderer
1131
1173
  * @function
1132
1174
  * @param {Image} image Source image
1133
1175
  * @param {string} repeat Define how the pattern should be repeated
@@ -1143,7 +1185,7 @@ export class CanvasRenderer extends Renderer {
1143
1185
  /**
1144
1186
  * Draw an image onto the main using the canvas api
1145
1187
  * @name drawImage
1146
- * @memberof CanvasRenderer.prototype
1188
+ * @memberof CanvasRenderer
1147
1189
  * @function
1148
1190
  * @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
1149
1191
  * @param {number} sx The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
@@ -1166,7 +1208,7 @@ export class CanvasRenderer extends Renderer {
1166
1208
  /**
1167
1209
  * Draw a pattern within the given rectangle.
1168
1210
  * @name drawPattern
1169
- * @memberof CanvasRenderer.prototype
1211
+ * @memberof CanvasRenderer
1170
1212
  * @function
1171
1213
  * @param {CanvasPattern} pattern Pattern object
1172
1214
  * @param {number} x
@@ -1179,7 +1221,7 @@ export class CanvasRenderer extends Renderer {
1179
1221
  /**
1180
1222
  * Stroke an arc at the specified coordinates with given radius, start and end points
1181
1223
  * @name strokeArc
1182
- * @memberof CanvasRenderer.prototype
1224
+ * @memberof CanvasRenderer
1183
1225
  * @function
1184
1226
  * @param {number} x arc center point x-axis
1185
1227
  * @param {number} y arc center point y-axis
@@ -1193,7 +1235,7 @@ export class CanvasRenderer extends Renderer {
1193
1235
  /**
1194
1236
  * Fill an arc at the specified coordinates with given radius, start and end points
1195
1237
  * @name fillArc
1196
- * @memberof CanvasRenderer.prototype
1238
+ * @memberof CanvasRenderer
1197
1239
  * @function
1198
1240
  * @param {number} x arc center point x-axis
1199
1241
  * @param {number} y arc center point y-axis
@@ -1206,7 +1248,7 @@ export class CanvasRenderer extends Renderer {
1206
1248
  /**
1207
1249
  * Stroke an ellipse at the specified coordinates with given radius
1208
1250
  * @name strokeEllipse
1209
- * @memberof CanvasRenderer.prototype
1251
+ * @memberof CanvasRenderer
1210
1252
  * @function
1211
1253
  * @param {number} x ellipse center point x-axis
1212
1254
  * @param {number} y ellipse center point y-axis
@@ -1218,7 +1260,7 @@ export class CanvasRenderer extends Renderer {
1218
1260
  /**
1219
1261
  * Fill an ellipse at the specified coordinates with given radius
1220
1262
  * @name fillEllipse
1221
- * @memberof CanvasRenderer.prototype
1263
+ * @memberof CanvasRenderer
1222
1264
  * @function
1223
1265
  * @param {number} x ellipse center point x-axis
1224
1266
  * @param {number} y ellipse center point y-axis
@@ -1229,7 +1271,7 @@ export class CanvasRenderer extends Renderer {
1229
1271
  /**
1230
1272
  * Stroke a line of the given two points
1231
1273
  * @name strokeLine
1232
- * @memberof CanvasRenderer.prototype
1274
+ * @memberof CanvasRenderer
1233
1275
  * @function
1234
1276
  * @param {number} startX the start x coordinate
1235
1277
  * @param {number} startY the start y coordinate
@@ -1240,7 +1282,7 @@ export class CanvasRenderer extends Renderer {
1240
1282
  /**
1241
1283
  * Fill a line of the given two points
1242
1284
  * @name fillLine
1243
- * @memberof CanvasRenderer.prototype
1285
+ * @memberof CanvasRenderer
1244
1286
  * @function
1245
1287
  * @param {number} startX the start x coordinate
1246
1288
  * @param {number} startY the start y coordinate
@@ -1251,7 +1293,7 @@ export class CanvasRenderer extends Renderer {
1251
1293
  /**
1252
1294
  * Stroke the given me.Polygon on the screen
1253
1295
  * @name strokePolygon
1254
- * @memberof CanvasRenderer.prototype
1296
+ * @memberof CanvasRenderer
1255
1297
  * @function
1256
1298
  * @param {Polygon} poly the shape to draw
1257
1299
  * @param {boolean} [fill=false] also fill the shape with the current color if true
@@ -1260,7 +1302,7 @@ export class CanvasRenderer extends Renderer {
1260
1302
  /**
1261
1303
  * Fill the given me.Polygon on the screen
1262
1304
  * @name fillPolygon
1263
- * @memberof CanvasRenderer.prototype
1305
+ * @memberof CanvasRenderer
1264
1306
  * @function
1265
1307
  * @param {Polygon} poly the shape to draw
1266
1308
  */
@@ -1268,7 +1310,7 @@ export class CanvasRenderer extends Renderer {
1268
1310
  /**
1269
1311
  * Stroke a rectangle at the specified coordinates
1270
1312
  * @name strokeRect
1271
- * @memberof CanvasRenderer.prototype
1313
+ * @memberof CanvasRenderer
1272
1314
  * @function
1273
1315
  * @param {number} x
1274
1316
  * @param {number} y
@@ -1280,7 +1322,7 @@ export class CanvasRenderer extends Renderer {
1280
1322
  /**
1281
1323
  * Draw a filled rectangle at the specified coordinates
1282
1324
  * @name fillRect
1283
- * @memberof CanvasRenderer.prototype
1325
+ * @memberof CanvasRenderer
1284
1326
  * @function
1285
1327
  * @param {number} x
1286
1328
  * @param {number} y
@@ -1288,10 +1330,35 @@ export class CanvasRenderer extends Renderer {
1288
1330
  * @param {number} height
1289
1331
  */
1290
1332
  fillRect(x: number, y: number, width: number, height: number): void;
1333
+ /**
1334
+ * Stroke a rounded rectangle at the specified coordinates
1335
+ * @name strokeRoundRect
1336
+ * @memberof CanvasRenderer
1337
+ * @function
1338
+ * @param {number} x
1339
+ * @param {number} y
1340
+ * @param {number} width
1341
+ * @param {number} height
1342
+ * @param {number} radius
1343
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
1344
+ */
1345
+ strokeRoundRect(x: number, y: number, width: number, height: number, radius: number, fill?: boolean): void;
1346
+ /**
1347
+ * Draw a rounded filled rectangle at the specified coordinates
1348
+ * @name fillRoundRect
1349
+ * @memberof CanvasRenderer
1350
+ * @function
1351
+ * @param {number} x
1352
+ * @param {number} y
1353
+ * @param {number} width
1354
+ * @param {number} height
1355
+ * @param {number} radius
1356
+ */
1357
+ fillRoundRect(x: number, y: number, width: number, height: number, radius: number): void;
1291
1358
  /**
1292
1359
  * return a reference to the system 2d Context
1293
1360
  * @name getContext
1294
- * @memberof CanvasRenderer.prototype
1361
+ * @memberof CanvasRenderer
1295
1362
  * @function
1296
1363
  * @returns {CanvasRenderingContext2D}
1297
1364
  */
@@ -1304,21 +1371,21 @@ export class CanvasRenderer extends Renderer {
1304
1371
  /**
1305
1372
  * save the canvas context
1306
1373
  * @name save
1307
- * @memberof CanvasRenderer.prototype
1374
+ * @memberof CanvasRenderer
1308
1375
  * @function
1309
1376
  */
1310
1377
  save(): void;
1311
1378
  /**
1312
1379
  * restores the canvas context
1313
1380
  * @name restore
1314
- * @memberof CanvasRenderer.prototype
1381
+ * @memberof CanvasRenderer
1315
1382
  * @function
1316
1383
  */
1317
1384
  restore(): void;
1318
1385
  /**
1319
1386
  * rotates the canvas context
1320
1387
  * @name rotate
1321
- * @memberof CanvasRenderer.prototype
1388
+ * @memberof CanvasRenderer
1322
1389
  * @function
1323
1390
  * @param {number} angle in radians
1324
1391
  */
@@ -1326,7 +1393,7 @@ export class CanvasRenderer extends Renderer {
1326
1393
  /**
1327
1394
  * scales the canvas context
1328
1395
  * @name scale
1329
- * @memberof CanvasRenderer.prototype
1396
+ * @memberof CanvasRenderer
1330
1397
  * @function
1331
1398
  * @param {number} x
1332
1399
  * @param {number} y
@@ -1336,23 +1403,31 @@ export class CanvasRenderer extends Renderer {
1336
1403
  * Set the current fill & stroke style color.
1337
1404
  * By default, or upon reset, the value is set to #000000.
1338
1405
  * @name setColor
1339
- * @memberof CanvasRenderer.prototype
1406
+ * @memberof CanvasRenderer
1340
1407
  * @function
1341
1408
  * @param {Color|string} color css color value
1342
1409
  */
1343
1410
  setColor(color: Color | string): void;
1344
1411
  /**
1345
- * Set the global alpha on the canvas context
1412
+ * Set the global alpha
1346
1413
  * @name setGlobalAlpha
1347
- * @memberof CanvasRenderer.prototype
1414
+ * @memberof CanvasRenderer
1348
1415
  * @function
1349
1416
  * @param {number} alpha 0.0 to 1.0 values accepted.
1350
1417
  */
1351
1418
  setGlobalAlpha(alpha: number): void;
1419
+ /**
1420
+ * Return the global alpha
1421
+ * @name getGlobalAlpha
1422
+ * @memberof CanvasRenderer
1423
+ * @function
1424
+ * @returns {number} global alpha value
1425
+ */
1426
+ getGlobalAlpha(): number;
1352
1427
  /**
1353
1428
  * Set the line width on the context
1354
1429
  * @name setLineWidth
1355
- * @memberof CanvasRenderer.prototype
1430
+ * @memberof CanvasRenderer
1356
1431
  * @function
1357
1432
  * @param {number} width Line width
1358
1433
  */
@@ -1361,7 +1436,7 @@ export class CanvasRenderer extends Renderer {
1361
1436
  * Reset (overrides) the renderer transformation matrix to the
1362
1437
  * identity one, and then apply the given transformation matrix.
1363
1438
  * @name setTransform
1364
- * @memberof CanvasRenderer.prototype
1439
+ * @memberof CanvasRenderer
1365
1440
  * @function
1366
1441
  * @param {Matrix2d} mat2d Matrix to transform by
1367
1442
  */
@@ -1369,7 +1444,7 @@ export class CanvasRenderer extends Renderer {
1369
1444
  /**
1370
1445
  * Multiply given matrix into the renderer tranformation matrix
1371
1446
  * @name transform
1372
- * @memberof CanvasRenderer.prototype
1447
+ * @memberof CanvasRenderer
1373
1448
  * @function
1374
1449
  * @param {Matrix2d} mat2d Matrix to transform by
1375
1450
  */
@@ -1377,7 +1452,7 @@ export class CanvasRenderer extends Renderer {
1377
1452
  /**
1378
1453
  * Translates the context to the given position
1379
1454
  * @name translate
1380
- * @memberof CanvasRenderer.prototype
1455
+ * @memberof CanvasRenderer
1381
1456
  * @function
1382
1457
  * @param {number} x
1383
1458
  * @param {number} y
@@ -1390,7 +1465,7 @@ export class CanvasRenderer extends Renderer {
1390
1465
  * and restore it (with the restore() method) any time in the future.
1391
1466
  * (<u>this is an experimental feature !</u>)
1392
1467
  * @name clipRect
1393
- * @memberof CanvasRenderer.prototype
1468
+ * @memberof CanvasRenderer
1394
1469
  * @function
1395
1470
  * @param {number} x
1396
1471
  * @param {number} y
@@ -1398,6 +1473,17 @@ export class CanvasRenderer extends Renderer {
1398
1473
  * @param {number} height
1399
1474
  */
1400
1475
  clipRect(x: number, y: number, width: number, height: number): void;
1476
+ /**
1477
+ * A mask limits rendering elements to the shape and position of the given mask object.
1478
+ * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
1479
+ * Mask are not preserved through renderer context save and restore.
1480
+ * @name setMask
1481
+ * @memberof CanvasRenderer
1482
+ * @function
1483
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
1484
+ * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
1485
+ */
1486
+ setMask(mask?: Rect | RoundRect | Polygon | Line | Ellipse, invert?: boolean): void;
1401
1487
  }
1402
1488
  /**
1403
1489
  * @classdesc
@@ -1609,7 +1695,7 @@ export class Color {
1609
1695
  * @function
1610
1696
  * @returns {string}
1611
1697
  */
1612
- toHex8(): string;
1698
+ toHex8(alpha?: number): string;
1613
1699
  /**
1614
1700
  * Get the color in "rgb(R,G,B)" format
1615
1701
  * @name toRGB
@@ -1623,9 +1709,10 @@ export class Color {
1623
1709
  * @name toRGBA
1624
1710
  * @memberof Color
1625
1711
  * @function
1712
+ * @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
1626
1713
  * @returns {string}
1627
1714
  */
1628
- toRGBA(): string;
1715
+ toRGBA(alpha?: number): string;
1629
1716
  }
1630
1717
  /**
1631
1718
  * @classdesc
@@ -1661,7 +1748,7 @@ export class ColorLayer extends Renderable {
1661
1748
  }
1662
1749
  /**
1663
1750
  * @classdesc
1664
- * me.Container represents a collection of child objects
1751
+ * Container represents a collection of child objects
1665
1752
  * @augments Renderable
1666
1753
  */
1667
1754
  export class Container extends Renderable {
@@ -1780,7 +1867,7 @@ export class Container extends Renderable {
1780
1867
  * orginal container. Then when the me.game.world.reset() is called the renderable
1781
1868
  * will not be in any container.
1782
1869
  * @name addChild
1783
- * @memberof Container.prototype
1870
+ * @memberof Container
1784
1871
  * @function
1785
1872
  * @param {Renderable} child
1786
1873
  * @param {number} [z] forces the z index of the child to the specified value
@@ -1791,7 +1878,7 @@ export class Container extends Renderable {
1791
1878
  * Add a child to the container at the specified index<br>
1792
1879
  * (the list won't be sorted after insertion)
1793
1880
  * @name addChildAt
1794
- * @memberof Container.prototype
1881
+ * @memberof Container
1795
1882
  * @function
1796
1883
  * @param {Renderable} child
1797
1884
  * @param {number} index
@@ -1805,7 +1892,7 @@ export class Container extends Renderable {
1805
1892
  * - The index of element in the array. <br>
1806
1893
  * - The array forEach() was called upon. <br>
1807
1894
  * @name forEach
1808
- * @memberof Container.prototype
1895
+ * @memberof Container
1809
1896
  * @function
1810
1897
  * @param {Function} callback fnction to execute on each element
1811
1898
  * @param {object} [thisArg] value to use as this(i.e reference Object) when executing callback.
@@ -1823,7 +1910,7 @@ export class Container extends Renderable {
1823
1910
  /**
1824
1911
  * Swaps the position (z-index) of 2 children
1825
1912
  * @name swapChildren
1826
- * @memberof Container.prototype
1913
+ * @memberof Container
1827
1914
  * @function
1828
1915
  * @param {Renderable} child
1829
1916
  * @param {Renderable} child2
@@ -1832,7 +1919,7 @@ export class Container extends Renderable {
1832
1919
  /**
1833
1920
  * Returns the Child at the specified index
1834
1921
  * @name getChildAt
1835
- * @memberof Container.prototype
1922
+ * @memberof Container
1836
1923
  * @function
1837
1924
  * @param {number} index
1838
1925
  * @returns {Renderable} the child at the specified index
@@ -1841,7 +1928,7 @@ export class Container extends Renderable {
1841
1928
  /**
1842
1929
  * Returns the index of the given Child
1843
1930
  * @name getChildIndex
1844
- * @memberof Container.prototype
1931
+ * @memberof Container
1845
1932
  * @function
1846
1933
  * @param {Renderable} child
1847
1934
  * @returns {number} index
@@ -1859,7 +1946,7 @@ export class Container extends Renderable {
1859
1946
  /**
1860
1947
  * Returns true if contains the specified Child
1861
1948
  * @name hasChild
1862
- * @memberof Container.prototype
1949
+ * @memberof Container
1863
1950
  * @function
1864
1951
  * @param {Renderable} child
1865
1952
  * @returns {boolean}
@@ -1870,7 +1957,7 @@ export class Container extends Renderable {
1870
1957
  * note : avoid calling this function every frame since
1871
1958
  * it parses the whole object tree each time
1872
1959
  * @name getChildByProp
1873
- * @memberof Container.prototype
1960
+ * @memberof Container
1874
1961
  * @public
1875
1962
  * @function
1876
1963
  * @param {string} prop Property name
@@ -1895,7 +1982,7 @@ export class Container extends Renderable {
1895
1982
  /**
1896
1983
  * returns the list of childs with the specified class type
1897
1984
  * @name getChildByType
1898
- * @memberof Container.prototype
1985
+ * @memberof Container
1899
1986
  * @public
1900
1987
  * @function
1901
1988
  * @param {object} classType
@@ -1908,7 +1995,7 @@ export class Container extends Renderable {
1908
1995
  * note : avoid calling this function every frame since
1909
1996
  * it parses the whole object list each time
1910
1997
  * @name getChildByName
1911
- * @memberof Container.prototype
1998
+ * @memberof Container
1912
1999
  * @public
1913
2000
  * @function
1914
2001
  * @param {string|RegExp|number|boolean} name child name
@@ -1920,7 +2007,7 @@ export class Container extends Renderable {
1920
2007
  * note : avoid calling this function every frame since
1921
2008
  * it parses the whole object list each time
1922
2009
  * @name getChildByGUID
1923
- * @memberof Container.prototype
2010
+ * @memberof Container
1924
2011
  * @public
1925
2012
  * @function
1926
2013
  * @param {string|RegExp|number|boolean} guid child GUID
@@ -1930,7 +2017,7 @@ export class Container extends Renderable {
1930
2017
  /**
1931
2018
  * return all child in this container
1932
2019
  * @name getChildren
1933
- * @memberof Container.prototype
2020
+ * @memberof Container
1934
2021
  * @public
1935
2022
  * @function
1936
2023
  * @returns {Renderable[]} an array of renderable object
@@ -1940,7 +2027,7 @@ export class Container extends Renderable {
1940
2027
  * update the bounding box for this shape.
1941
2028
  * @ignore
1942
2029
  * @name updateBounds
1943
- * @memberof Renderable.prototype
2030
+ * @memberof Renderable
1944
2031
  * @function
1945
2032
  * @returns {Bounds} this shape bounding box Rectangle object
1946
2033
  */
@@ -1949,7 +2036,7 @@ export class Container extends Renderable {
1949
2036
  * Checks if this container is root or if it's attached to the root container.
1950
2037
  * @private
1951
2038
  * @name isAttachedToRoot
1952
- * @memberof Container.prototype
2039
+ * @memberof Container
1953
2040
  * @function
1954
2041
  * @returns {boolean}
1955
2042
  */
@@ -1958,7 +2045,7 @@ export class Container extends Renderable {
1958
2045
  * update the cointainer's bounding rect (private)
1959
2046
  * @ignore
1960
2047
  * @name updateBoundsPos
1961
- * @memberof Container.prototype
2048
+ * @memberof Container
1962
2049
  * @function
1963
2050
  */
1964
2051
  updateBoundsPos(newX: any, newY: any): Bounds;
@@ -1969,7 +2056,7 @@ export class Container extends Renderable {
1969
2056
  /**
1970
2057
  * Invokes the removeChildNow in a defer, to ensure the child is removed safely after the update & draw stack has completed
1971
2058
  * @name removeChild
1972
- * @memberof Container.prototype
2059
+ * @memberof Container
1973
2060
  * @public
1974
2061
  * @function
1975
2062
  * @param {Renderable} child
@@ -1981,7 +2068,7 @@ export class Container extends Renderable {
1981
2068
  * (removal is immediate and unconditional)<br>
1982
2069
  * Never use keepalive=true with objects from {@link pool}. Doing so will create a memory leak.
1983
2070
  * @name removeChildNow
1984
- * @memberof Container.prototype
2071
+ * @memberof Container
1985
2072
  * @function
1986
2073
  * @param {Renderable} child
1987
2074
  * @param {boolean} [keepalive=False] True to prevent calling child.destroy()
@@ -1990,7 +2077,7 @@ export class Container extends Renderable {
1990
2077
  /**
1991
2078
  * Automatically set the specified property of all childs to the given value
1992
2079
  * @name setChildsProperty
1993
- * @memberof Container.prototype
2080
+ * @memberof Container
1994
2081
  * @function
1995
2082
  * @param {string} prop property name
1996
2083
  * @param {object} value property value
@@ -2000,7 +2087,7 @@ export class Container extends Renderable {
2000
2087
  /**
2001
2088
  * Move the child in the group one step forward (z depth).
2002
2089
  * @name moveUp
2003
- * @memberof Container.prototype
2090
+ * @memberof Container
2004
2091
  * @function
2005
2092
  * @param {Renderable} child
2006
2093
  */
@@ -2008,7 +2095,7 @@ export class Container extends Renderable {
2008
2095
  /**
2009
2096
  * Move the child in the group one step backward (z depth).
2010
2097
  * @name moveDown
2011
- * @memberof Container.prototype
2098
+ * @memberof Container
2012
2099
  * @function
2013
2100
  * @param {Renderable} child
2014
2101
  */
@@ -2016,7 +2103,7 @@ export class Container extends Renderable {
2016
2103
  /**
2017
2104
  * Move the specified child to the top(z depth).
2018
2105
  * @name moveToTop
2019
- * @memberof Container.prototype
2106
+ * @memberof Container
2020
2107
  * @function
2021
2108
  * @param {Renderable} child
2022
2109
  */
@@ -2024,7 +2111,7 @@ export class Container extends Renderable {
2024
2111
  /**
2025
2112
  * Move the specified child the bottom (z depth).
2026
2113
  * @name moveToBottom
2027
- * @memberof Container.prototype
2114
+ * @memberof Container
2028
2115
  * @function
2029
2116
  * @param {Renderable} child
2030
2117
  */
@@ -2032,7 +2119,7 @@ export class Container extends Renderable {
2032
2119
  /**
2033
2120
  * Manually trigger the sort of all the childs in the container</p>
2034
2121
  * @name sort
2035
- * @memberof Container.prototype
2122
+ * @memberof Container
2036
2123
  * @public
2037
2124
  * @function
2038
2125
  * @param {boolean} [recursive=false] recursively sort all containers if true
@@ -2066,7 +2153,7 @@ export class Container extends Renderable {
2066
2153
  * draw the container. <br>
2067
2154
  * automatically called by the game manager {@link game}
2068
2155
  * @name draw
2069
- * @memberof Container.prototype
2156
+ * @memberof Container
2070
2157
  * @function
2071
2158
  * @protected
2072
2159
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
@@ -2246,7 +2333,7 @@ export class Ellipse {
2246
2333
  * @public
2247
2334
  * @type {Vector2d}
2248
2335
  * @name pos
2249
- * @memberof Ellipse#
2336
+ * @memberof Ellipse
2250
2337
  */
2251
2338
  public pos: Vector2d;
2252
2339
  /**
@@ -2267,7 +2354,7 @@ export class Ellipse {
2267
2354
  * @public
2268
2355
  * @type {Vector2d}
2269
2356
  * @name radiusV
2270
- * @memberof Ellipse#
2357
+ * @memberof Ellipse
2271
2358
  */
2272
2359
  public radiusV: Vector2d;
2273
2360
  /**
@@ -2275,7 +2362,7 @@ export class Ellipse {
2275
2362
  * @public
2276
2363
  * @type {Vector2d}
2277
2364
  * @name radiusSq
2278
- * @memberof Ellipse#
2365
+ * @memberof Ellipse
2279
2366
  */
2280
2367
  public radiusSq: Vector2d;
2281
2368
  /**
@@ -2283,7 +2370,7 @@ export class Ellipse {
2283
2370
  * @public
2284
2371
  * @type {Vector2d}
2285
2372
  * @name ratio
2286
- * @memberof Ellipse#
2373
+ * @memberof Ellipse
2287
2374
  */
2288
2375
  public ratio: Vector2d;
2289
2376
  shapeType: string;
@@ -2292,7 +2379,7 @@ export class Ellipse {
2292
2379
  /**
2293
2380
  * set new value to the Ellipse shape
2294
2381
  * @name setShape
2295
- * @memberof Ellipse.prototype
2382
+ * @memberof Ellipse
2296
2383
  * @function
2297
2384
  * @param {number} x the center x coordinate of the ellipse
2298
2385
  * @param {number} y the center y coordinate of the ellipse
@@ -2304,7 +2391,7 @@ export class Ellipse {
2304
2391
  /**
2305
2392
  * Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
2306
2393
  * @name rotate
2307
- * @memberof Ellipse.prototype
2394
+ * @memberof Ellipse
2308
2395
  * @function
2309
2396
  * @param {number} angle The angle to rotate (in radians)
2310
2397
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -2314,7 +2401,7 @@ export class Ellipse {
2314
2401
  /**
2315
2402
  * Scale this Ellipse by the specified scalar.
2316
2403
  * @name scale
2317
- * @memberof Ellipse.prototype
2404
+ * @memberof Ellipse
2318
2405
  * @function
2319
2406
  * @param {number} x
2320
2407
  * @param {number} [y=x]
@@ -2324,7 +2411,7 @@ export class Ellipse {
2324
2411
  /**
2325
2412
  * Scale this Ellipse by the specified vector.
2326
2413
  * @name scale
2327
- * @memberof Ellipse.prototype
2414
+ * @memberof Ellipse
2328
2415
  * @function
2329
2416
  * @param {Vector2d} v
2330
2417
  * @returns {Ellipse} Reference to this object for method chaining
@@ -2333,7 +2420,7 @@ export class Ellipse {
2333
2420
  /**
2334
2421
  * apply the given transformation matrix to this ellipse
2335
2422
  * @name transform
2336
- * @memberof Ellipse.prototype
2423
+ * @memberof Ellipse
2337
2424
  * @function
2338
2425
  * @param {Matrix2d} matrix the transformation matrix
2339
2426
  * @returns {Polygon} Reference to this object for method chaining
@@ -2342,7 +2429,7 @@ export class Ellipse {
2342
2429
  /**
2343
2430
  * translate the circle/ellipse by the specified offset
2344
2431
  * @name translate
2345
- * @memberof Ellipse.prototype
2432
+ * @memberof Ellipse
2346
2433
  * @function
2347
2434
  * @param {number} x x offset
2348
2435
  * @param {number} y y offset
@@ -2351,7 +2438,7 @@ export class Ellipse {
2351
2438
  /**
2352
2439
  * translate the circle/ellipse by the specified vector
2353
2440
  * @name translate
2354
- * @memberof Ellipse.prototype
2441
+ * @memberof Ellipse
2355
2442
  * @function
2356
2443
  * @param {Vector2d} v vector offset
2357
2444
  * @returns {Ellipse} this ellipse
@@ -2360,7 +2447,7 @@ export class Ellipse {
2360
2447
  /**
2361
2448
  * check if this circle/ellipse contains the specified point
2362
2449
  * @name contains
2363
- * @memberof Ellipse.prototype
2450
+ * @memberof Ellipse
2364
2451
  * @function
2365
2452
  * @param {Vector2d} point
2366
2453
  * @returns {boolean} true if contains
@@ -2368,7 +2455,7 @@ export class Ellipse {
2368
2455
  /**
2369
2456
  * check if this circle/ellipse contains the specified point
2370
2457
  * @name contains
2371
- * @memberof Ellipse.prototype
2458
+ * @memberof Ellipse
2372
2459
  * @function
2373
2460
  * @param {number} x x coordinate
2374
2461
  * @param {number} y y coordinate
@@ -2378,7 +2465,7 @@ export class Ellipse {
2378
2465
  /**
2379
2466
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
2380
2467
  * @name getBounds
2381
- * @memberof Ellipse.prototype
2468
+ * @memberof Ellipse
2382
2469
  * @function
2383
2470
  * @returns {Bounds} this shape bounding box Rectangle object
2384
2471
  */
@@ -2386,7 +2473,7 @@ export class Ellipse {
2386
2473
  /**
2387
2474
  * clone this Ellipse
2388
2475
  * @name clone
2389
- * @memberof Ellipse.prototype
2476
+ * @memberof Ellipse
2390
2477
  * @function
2391
2478
  * @returns {Ellipse} new Ellipse
2392
2479
  */
@@ -2610,6 +2697,16 @@ export class GLShader {
2610
2697
  * myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
2611
2698
  */
2612
2699
  setUniform(name: string, value: object | Float32Array): void;
2700
+ /**
2701
+ * activate the given vertex attribute for this shader
2702
+ * @name setVertexAttributes
2703
+ * @memberof GLShader
2704
+ * @function
2705
+ * @param {WebGLRenderingContext} gl the current WebGL rendering context
2706
+ * @param {object[]} attributes an array of vertex attributes
2707
+ * @param {number} vertexByteSize the size of a single vertex in bytes
2708
+ */
2709
+ setVertexAttributes(gl: WebGLRenderingContext, attributes: object[], vertexByteSize: number): void;
2613
2710
  /**
2614
2711
  * destroy this shader objects resources (program, attributes, uniforms)
2615
2712
  * @name destroy
@@ -2700,7 +2797,7 @@ export class GUI_Object extends Sprite {
2700
2797
  /**
2701
2798
  * function called when the object is pressed (to be extended)
2702
2799
  * @name onClick
2703
- * @memberof GUI_Object.prototype
2800
+ * @memberof GUI_Object
2704
2801
  * @public
2705
2802
  * @function
2706
2803
  * @param {Pointer} event the event object
@@ -2715,7 +2812,7 @@ export class GUI_Object extends Sprite {
2715
2812
  /**
2716
2813
  * function called when the pointer is over the object
2717
2814
  * @name onOver
2718
- * @memberof GUI_Object.prototype
2815
+ * @memberof GUI_Object
2719
2816
  * @public
2720
2817
  * @function
2721
2818
  * @param {Pointer} event the event object
@@ -2729,7 +2826,7 @@ export class GUI_Object extends Sprite {
2729
2826
  /**
2730
2827
  * function called when the pointer is leaving the object area
2731
2828
  * @name onOut
2732
- * @memberof GUI_Object.prototype
2829
+ * @memberof GUI_Object
2733
2830
  * @public
2734
2831
  * @function
2735
2832
  * @param {Pointer} event the event object
@@ -2743,7 +2840,7 @@ export class GUI_Object extends Sprite {
2743
2840
  /**
2744
2841
  * function called when the object is pressed and released (to be extended)
2745
2842
  * @name onRelease
2746
- * @memberof GUI_Object.prototype
2843
+ * @memberof GUI_Object
2747
2844
  * @public
2748
2845
  * @function
2749
2846
  * @returns {boolean} return false if we need to stop propagating the event
@@ -2758,7 +2855,7 @@ export class GUI_Object extends Sprite {
2758
2855
  * function called when the object is pressed and held<br>
2759
2856
  * to be extended <br>
2760
2857
  * @name onHold
2761
- * @memberof GUI_Object.prototype
2858
+ * @memberof GUI_Object
2762
2859
  * @public
2763
2860
  * @function
2764
2861
  */
@@ -2840,7 +2937,7 @@ export class ImageLayer extends Renderable {
2840
2937
  /**
2841
2938
  * resize the Image Layer to match the given size
2842
2939
  * @name resize
2843
- * @memberof ImageLayer.prototype
2940
+ * @memberof ImageLayer
2844
2941
  * @function
2845
2942
  * @param {number} w new width
2846
2943
  * @param {number} h new height
@@ -2872,6 +2969,63 @@ export class ImageLayer extends Renderable {
2872
2969
  */
2873
2970
  destroy(): void;
2874
2971
  }
2972
+ /**
2973
+ * @classdesc
2974
+ * A 2D point light.
2975
+ * Note: this is a very experimental and work in progress feature, that provides a simple spot light effect.
2976
+ * The light effect is best rendered in WebGL, as they are few limitations when using the Canvas Renderer
2977
+ * (multiple lights are not supported, alpha component of the ambient light is ignored)
2978
+ * @see stage.lights
2979
+ */
2980
+ export class Light2d extends Renderable {
2981
+ /**
2982
+ * @param {number} x - The horizontal position of the light.
2983
+ * @param {number} y - The vertical position of the light.
2984
+ * @param {number} radius - The radius of the light.
2985
+ * @param {Color|string} [color="#FFF"] the color of the light
2986
+ * @param {number} [intensity=0.7] - The intensity of the light.
2987
+ */
2988
+ constructor(x: number, y: number, radius: number, color?: Color | string, intensity?: number);
2989
+ /**
2990
+ * the color of the light
2991
+ * @type {Color}
2992
+ * @default "#FFF"
2993
+ */
2994
+ color: Color;
2995
+ /**
2996
+ * The radius of the light
2997
+ * @type {number}
2998
+ */
2999
+ radius: number;
3000
+ /**
3001
+ * The intensity of the light
3002
+ * @type {number}
3003
+ * @default 0.7
3004
+ */
3005
+ intensity: number;
3006
+ /** @ignore */
3007
+ visibleArea: any;
3008
+ /** @ignore */
3009
+ texture: any;
3010
+ /**
3011
+ * returns a geometry representing the visible area of this light
3012
+ * @name getVisibleArea
3013
+ * @memberof Light2d
3014
+ * @function
3015
+ * @returns {Ellipse} the light visible mask
3016
+ */
3017
+ getVisibleArea(): Ellipse;
3018
+ /**
3019
+ * object draw (Called internally by the engine).
3020
+ * @ignore
3021
+ */
3022
+ draw(renderer: any): void;
3023
+ /**
3024
+ * Destroy function<br>
3025
+ * @ignore
3026
+ */
3027
+ destroy(): void;
3028
+ }
2875
3029
  /**
2876
3030
  * @classdesc
2877
3031
  * a line segment Object
@@ -4064,7 +4218,7 @@ export class Particle extends Renderable {
4064
4218
  * @ignore
4065
4219
  */
4066
4220
  onResetEvent(emitter: any, newInstance?: boolean): void;
4067
- vel: Vector2d;
4221
+ vel: any;
4068
4222
  image: any;
4069
4223
  life: any;
4070
4224
  startLife: any;
@@ -4092,14 +4246,17 @@ export class ParticleEmitter extends Container {
4092
4246
  * @param {number} y y position of the particle emitter
4093
4247
  * @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
4094
4248
  * @example
4095
- * // Create a basic emitter at position 100, 100
4096
- * var emitter = new ParticleEmitter(100, 100);
4097
- *
4098
- * // Adjust the emitter properties
4099
- * emitter.totalParticles = 200;
4100
- * emitter.minLife = 1000;
4101
- * emitter.maxLife = 3000;
4102
- * emitter.z = 10;
4249
+ * // Create a particle emitter at position 100, 100
4250
+ * var emitter = new ParticleEmitter(100, 100, {
4251
+ * width: 16,
4252
+ * height : 16,
4253
+ * tint: "#f00",
4254
+ * totalParticles: 32,
4255
+ * angle: 0,
4256
+ * angleVariation: 6.283185307179586,
4257
+ * maxLife: 5,
4258
+ * speed: 3
4259
+ * });
4103
4260
  *
4104
4261
  * // Add the emitter to the game world
4105
4262
  * me.game.world.addChild(emitter);
@@ -4389,140 +4546,696 @@ export class ParticleEmitter extends Container {
4389
4546
  */
4390
4547
  framesToSkip: number;
4391
4548
  });
4392
- /** @ignore */
4393
- _stream: boolean;
4394
- /** @ignore */
4395
- _frequencyTimer: number;
4396
- /** @ignore */
4397
- _durationTimer: number;
4398
- /** @ignore */
4399
- _enabled: boolean;
4400
- _updateCount: number;
4401
- settings: {};
4402
- _dt: number;
4403
- /**
4404
- * Reset the emitter with particle emitter settings.
4405
- * @param {object} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
4406
- */
4407
- reset(settings?: object): void;
4408
- /**
4409
- * returns a random point on the x axis within the bounds of this emitter
4410
- * @returns {number}
4411
- */
4412
- getRandomPointX(): number;
4413
- /**
4414
- * returns a random point on the y axis within the bounds this emitter
4415
- * @returns {number}
4416
- */
4417
- getRandomPointY(): number;
4418
- /** @ignore */
4419
- addParticles(count: any): void;
4420
- /**
4421
- * Emitter is of type stream and is launching particles
4422
- * @returns {boolean} Emitter is Stream and is launching particles
4423
- */
4424
- isRunning(): boolean;
4425
- /**
4426
- * Launch particles from emitter constantly (e.g. for stream)
4427
- * @param {number} duration [optional] time that the emitter releases particles in ms
4428
- */
4429
- streamParticles(duration: number): void;
4430
- /**
4431
- * Stop the emitter from generating new particles (used only if emitter is Stream)
4432
- */
4433
- stopStream(): void;
4434
- /**
4435
- * Launch all particles from emitter and stop (e.g. for explosion)
4436
- * @param {number} total [optional] number of particles to launch
4437
- */
4438
- burstParticles(total: number): void;
4439
- /**
4440
- * @ignore
4441
- */
4442
- update(dt: any): boolean;
4443
- }
4444
- export namespace ParticleEmitterSettings {
4445
- const width: number;
4446
- const height: number;
4447
- const image: HTMLCanvasElement;
4448
- const textureSize: number;
4449
- const tint: string;
4450
- const totalParticles: number;
4451
- const angle: number;
4452
- const angleVariation: number;
4453
- const minLife: number;
4454
- const maxLife: number;
4455
- const speed: number;
4456
- const speedVariation: number;
4457
- const minRotation: number;
4458
- const maxRotation: number;
4459
- const minStartScale: number;
4460
- const maxStartScale: number;
4461
- const minEndScale: number;
4462
- const maxEndScale: number;
4463
- const gravity: number;
4464
- const wind: number;
4465
- const followTrajectory: boolean;
4466
- const textureAdditive: boolean;
4467
- const blendMode: string;
4468
- const onlyInViewport: boolean;
4469
- const floating: boolean;
4470
- const maxParticles: number;
4471
- const frequency: number;
4472
- const duration: number;
4473
- const framesToSkip: number;
4474
- }
4475
- /**
4476
- * @classdesc
4477
- * a pointer object, representing a single finger on a touch enabled device.
4478
- * @class Pointer
4479
- * @augments Bounds
4480
- */
4481
- export class Pointer extends Bounds {
4482
- /**
4483
- * @ignore
4484
- */
4485
- constructor(x?: number, y?: number, w?: number, h?: number);
4486
- /**
4487
- * constant for left button
4488
- * @public
4489
- * @type {number}
4490
- * @name LEFT
4491
- * @memberof Pointer
4492
- */
4493
- public LEFT: number;
4494
- /**
4495
- * constant for middle button
4496
- * @public
4497
- * @type {number}
4498
- * @name MIDDLE
4499
- * @memberof Pointer
4500
- */
4501
- public MIDDLE: number;
4502
- /**
4503
- * constant for right button
4504
- * @public
4505
- * @type {number}
4506
- * @name RIGHT
4507
- * @memberof Pointer
4508
- */
4509
- public RIGHT: number;
4510
4549
  /**
4511
- * the originating Event Object
4550
+ * the current (active) emitter settings
4512
4551
  * @public
4513
- * @type {PointerEvent|TouchEvent|MouseEvent}
4514
- * @name event
4515
- * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
4516
- * @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent
4517
- * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
4518
- * @memberof Pointer
4552
+ * @type {ParticleEmitterSettings}
4553
+ * @name settings
4554
+ * @memberof ParticleEmitter
4519
4555
  */
4520
- public event: PointerEvent | TouchEvent | MouseEvent;
4521
- /**
4522
- * a string containing the event's type.
4523
- * @public
4524
- * @type {string}
4525
- * @name type
4556
+ public settings: {
4557
+ /**
4558
+ * Width of the particle spawn area.
4559
+ * @type {number}
4560
+ * @name width
4561
+ * @memberof ParticleEmitterSettings
4562
+ * @default 1
4563
+ */
4564
+ width: number;
4565
+ /**
4566
+ * Height of the particle spawn area
4567
+ * @public
4568
+ * @type {number}
4569
+ * @name height
4570
+ * @memberof ParticleEmitterSettings
4571
+ * @default 1
4572
+ */
4573
+ height: number;
4574
+ /**
4575
+ * image used for particles texture
4576
+ * (by default melonJS will create an white 8x8 texture image)
4577
+ * @public
4578
+ * @type {HTMLCanvasElement}
4579
+ * @name image
4580
+ * @memberof ParticleEmitterSettings
4581
+ * @default undefined
4582
+ * @see ParticleEmitterSettings.textureSize
4583
+ */
4584
+ image: HTMLCanvasElement;
4585
+ /**
4586
+ * default texture size used for particles if no image is specified
4587
+ * (by default melonJS will create an white 8x8 texture image)
4588
+ * @public
4589
+ * @type {number}
4590
+ * @name textureSize
4591
+ * @memberof ParticleEmitterSettings
4592
+ * @default 8
4593
+ * @see ParticleEmitterSettings.image
4594
+ */
4595
+ textureSize: number;
4596
+ /**
4597
+ * tint to be applied to particles
4598
+ * @public
4599
+ * @type {string}
4600
+ * @name tint
4601
+ * @memberof ParticleEmitterSettings
4602
+ * @default "#fff"
4603
+ */
4604
+ tint: string;
4605
+ /**
4606
+ * Total number of particles in the emitter
4607
+ * @public
4608
+ * @type {number}
4609
+ * @name totalParticles
4610
+ * @default 50
4611
+ * @memberof ParticleEmitterSettings
4612
+ */
4613
+ totalParticles: number;
4614
+ /**
4615
+ * Start angle for particle launch in Radians
4616
+ * @public
4617
+ * @type {number}
4618
+ * @name angle
4619
+ * @default Math.PI / 2
4620
+ * @memberof ParticleEmitterSettings
4621
+ */
4622
+ angle: number;
4623
+ /**
4624
+ * Variation in the start angle for particle launch in Radians.
4625
+ * @public
4626
+ * @type {number}
4627
+ * @name angleVariation
4628
+ * @default 0
4629
+ * @memberof ParticleEmitterSettings
4630
+ */
4631
+ angleVariation: number;
4632
+ /**
4633
+ * Minimum time each particle lives once it is emitted in ms.
4634
+ * @public
4635
+ * @type {number}
4636
+ * @name minLife
4637
+ * @default 1000
4638
+ * @memberof ParticleEmitterSettings
4639
+ */
4640
+ minLife: number;
4641
+ /**
4642
+ * Maximum time each particle lives once it is emitted in ms.
4643
+ * @public
4644
+ * @type {number}
4645
+ * @name maxLife
4646
+ * @default 3000
4647
+ * @memberof ParticleEmitterSettings
4648
+ */
4649
+ maxLife: number;
4650
+ /**
4651
+ * Start speed of particles.<br>
4652
+ * @public
4653
+ * @type {number}
4654
+ * @name speed
4655
+ * @default 2
4656
+ * @memberof ParticleEmitterSettings
4657
+ */
4658
+ speed: number;
4659
+ /**
4660
+ * Variation in the start speed of particles
4661
+ * @public
4662
+ * @type {number}
4663
+ * @name speedVariation
4664
+ * @default 1
4665
+ * @memberof ParticleEmitterSettings
4666
+ */
4667
+ speedVariation: number;
4668
+ /**
4669
+ * Minimum start rotation for particles sprites in Radians
4670
+ * @public
4671
+ * @type {number}
4672
+ * @name minRotation
4673
+ * @default 0
4674
+ * @memberof ParticleEmitterSettings
4675
+ */
4676
+ minRotation: number;
4677
+ /**
4678
+ * Maximum start rotation for particles sprites in Radians
4679
+ * @public
4680
+ * @type {number}
4681
+ * @name maxRotation
4682
+ * @default 0
4683
+ * @memberof ParticleEmitterSettings
4684
+ */
4685
+ maxRotation: number;
4686
+ /**
4687
+ * Minimum start scale ratio for particles (1 = no scaling)
4688
+ * @public
4689
+ * @type {number}
4690
+ * @name minStartScale
4691
+ * @default 1
4692
+ * @memberof ParticleEmitterSettings
4693
+ */
4694
+ minStartScale: number;
4695
+ /**
4696
+ * Maximum start scale ratio for particles (1 = no scaling)
4697
+ * @public
4698
+ * @type {number}
4699
+ * @name maxStartScale
4700
+ * @default 1
4701
+ * @memberof ParticleEmitterSettings
4702
+ */
4703
+ maxStartScale: number;
4704
+ /**
4705
+ * Minimum end scale ratio for particles
4706
+ * @public
4707
+ * @type {number}
4708
+ * @name minEndScale
4709
+ * @default 0
4710
+ * @memberof ParticleEmitterSettings
4711
+ */
4712
+ minEndScale: number;
4713
+ /**
4714
+ * Maximum end scale ratio for particles
4715
+ * @public
4716
+ * @type {number}
4717
+ * @name maxEndScale
4718
+ * @default 0
4719
+ * @memberof ParticleEmitterSettings
4720
+ */
4721
+ maxEndScale: number;
4722
+ /**
4723
+ * Vertical force (Gravity) for each particle
4724
+ * @public
4725
+ * @type {number}
4726
+ * @name gravity
4727
+ * @default 0
4728
+ * @memberof ParticleEmitterSettings
4729
+ * @see game.world.gravity
4730
+ */
4731
+ gravity: number;
4732
+ /**
4733
+ * Horizontal force (like a Wind) for each particle
4734
+ * @public
4735
+ * @type {number}
4736
+ * @name wind
4737
+ * @default 0
4738
+ * @memberof ParticleEmitterSettings
4739
+ */
4740
+ wind: number;
4741
+ /**
4742
+ * Update the rotation of particle in accordance the particle trajectory.<br>
4743
+ * The particle sprite should aim at zero angle (draw from left to right).<br>
4744
+ * Override the particle minRotation and maxRotation.<br>
4745
+ * @public
4746
+ * @type {boolean}
4747
+ * @name followTrajectory
4748
+ * @default false
4749
+ * @memberof ParticleEmitterSettings
4750
+ */
4751
+ followTrajectory: boolean;
4752
+ /**
4753
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
4754
+ * @public
4755
+ * @type {boolean}
4756
+ * @name textureAdditive
4757
+ * @default false
4758
+ * @memberof ParticleEmitterSettings
4759
+ * @see ParticleEmitterSettings.blendMode
4760
+ */
4761
+ textureAdditive: boolean;
4762
+ /**
4763
+ * the blend mode to be applied when rendering particles.
4764
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
4765
+ * @public
4766
+ * @type {string}
4767
+ * @name blendMode
4768
+ * @default normal
4769
+ * @memberof ParticleEmitterSettings
4770
+ * @see CanvasRenderer#setBlendMode
4771
+ * @see WebGLRenderer#setBlendMode
4772
+ */
4773
+ blendMode: string;
4774
+ /**
4775
+ * Update particles only in the viewport, remove it when out of viewport.
4776
+ * @public
4777
+ * @type {boolean}
4778
+ * @name onlyInViewport
4779
+ * @default true
4780
+ * @memberof ParticleEmitterSettings
4781
+ */
4782
+ onlyInViewport: boolean;
4783
+ /**
4784
+ * Render particles in screen space.
4785
+ * @public
4786
+ * @type {boolean}
4787
+ * @name floating
4788
+ * @default false
4789
+ * @memberof ParticleEmitterSettings
4790
+ */
4791
+ floating: boolean;
4792
+ /**
4793
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
4794
+ * @public
4795
+ * @type {number}
4796
+ * @name maxParticles
4797
+ * @default 10
4798
+ * @memberof ParticleEmitterSettings
4799
+ */
4800
+ maxParticles: number;
4801
+ /**
4802
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
4803
+ * @public
4804
+ * @type {number}
4805
+ * @name frequency
4806
+ * @default 100
4807
+ * @memberof ParticleEmitterSettings
4808
+ */
4809
+ frequency: number;
4810
+ /**
4811
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
4812
+ * After this period, the emitter stop the launch of particles.
4813
+ * @public
4814
+ * @type {number}
4815
+ * @name duration
4816
+ * @default Infinity
4817
+ * @memberof ParticleEmitterSettings
4818
+ */
4819
+ duration: number;
4820
+ /**
4821
+ * Skip n frames after updating the particle system once.
4822
+ * This can be used to reduce the performance impact of emitters with many particles.
4823
+ * @public
4824
+ * @type {number}
4825
+ * @name framesToSkip
4826
+ * @default 0
4827
+ * @memberof ParticleEmitterSettings
4828
+ */
4829
+ framesToSkip: number;
4830
+ };
4831
+ /** @ignore */
4832
+ _stream: boolean;
4833
+ /** @ignore */
4834
+ _frequencyTimer: number;
4835
+ /** @ignore */
4836
+ _durationTimer: number;
4837
+ /** @ignore */
4838
+ _enabled: boolean;
4839
+ _updateCount: number;
4840
+ _dt: number;
4841
+ /**
4842
+ * Reset the emitter with particle emitter settings.
4843
+ * @param {ParticleEmitterSettings} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
4844
+ */
4845
+ reset(settings?: {
4846
+ /**
4847
+ * Width of the particle spawn area.
4848
+ * @type {number}
4849
+ * @name width
4850
+ * @memberof ParticleEmitterSettings
4851
+ * @default 1
4852
+ */
4853
+ width: number;
4854
+ /**
4855
+ * Height of the particle spawn area
4856
+ * @public
4857
+ * @type {number}
4858
+ * @name height
4859
+ * @memberof ParticleEmitterSettings
4860
+ * @default 1
4861
+ */
4862
+ height: number;
4863
+ /**
4864
+ * image used for particles texture
4865
+ * (by default melonJS will create an white 8x8 texture image)
4866
+ * @public
4867
+ * @type {HTMLCanvasElement}
4868
+ * @name image
4869
+ * @memberof ParticleEmitterSettings
4870
+ * @default undefined
4871
+ * @see ParticleEmitterSettings.textureSize
4872
+ */
4873
+ image: HTMLCanvasElement;
4874
+ /**
4875
+ * default texture size used for particles if no image is specified
4876
+ * (by default melonJS will create an white 8x8 texture image)
4877
+ * @public
4878
+ * @type {number}
4879
+ * @name textureSize
4880
+ * @memberof ParticleEmitterSettings
4881
+ * @default 8
4882
+ * @see ParticleEmitterSettings.image
4883
+ */
4884
+ textureSize: number;
4885
+ /**
4886
+ * tint to be applied to particles
4887
+ * @public
4888
+ * @type {string}
4889
+ * @name tint
4890
+ * @memberof ParticleEmitterSettings
4891
+ * @default "#fff"
4892
+ */
4893
+ tint: string;
4894
+ /**
4895
+ * Total number of particles in the emitter
4896
+ * @public
4897
+ * @type {number}
4898
+ * @name totalParticles
4899
+ * @default 50
4900
+ * @memberof ParticleEmitterSettings
4901
+ */
4902
+ totalParticles: number;
4903
+ /**
4904
+ * Start angle for particle launch in Radians
4905
+ * @public
4906
+ * @type {number}
4907
+ * @name angle
4908
+ * @default Math.PI / 2
4909
+ * @memberof ParticleEmitterSettings
4910
+ */
4911
+ angle: number;
4912
+ /**
4913
+ * Variation in the start angle for particle launch in Radians.
4914
+ * @public
4915
+ * @type {number}
4916
+ * @name angleVariation
4917
+ * @default 0
4918
+ * @memberof ParticleEmitterSettings
4919
+ */
4920
+ angleVariation: number;
4921
+ /**
4922
+ * Minimum time each particle lives once it is emitted in ms.
4923
+ * @public
4924
+ * @type {number}
4925
+ * @name minLife
4926
+ * @default 1000
4927
+ * @memberof ParticleEmitterSettings
4928
+ */
4929
+ minLife: number;
4930
+ /**
4931
+ * Maximum time each particle lives once it is emitted in ms.
4932
+ * @public
4933
+ * @type {number}
4934
+ * @name maxLife
4935
+ * @default 3000
4936
+ * @memberof ParticleEmitterSettings
4937
+ */
4938
+ maxLife: number;
4939
+ /**
4940
+ * Start speed of particles.<br>
4941
+ * @public
4942
+ * @type {number}
4943
+ * @name speed
4944
+ * @default 2
4945
+ * @memberof ParticleEmitterSettings
4946
+ */
4947
+ speed: number;
4948
+ /**
4949
+ * Variation in the start speed of particles
4950
+ * @public
4951
+ * @type {number}
4952
+ * @name speedVariation
4953
+ * @default 1
4954
+ * @memberof ParticleEmitterSettings
4955
+ */
4956
+ speedVariation: number;
4957
+ /**
4958
+ * Minimum start rotation for particles sprites in Radians
4959
+ * @public
4960
+ * @type {number}
4961
+ * @name minRotation
4962
+ * @default 0
4963
+ * @memberof ParticleEmitterSettings
4964
+ */
4965
+ minRotation: number;
4966
+ /**
4967
+ * Maximum start rotation for particles sprites in Radians
4968
+ * @public
4969
+ * @type {number}
4970
+ * @name maxRotation
4971
+ * @default 0
4972
+ * @memberof ParticleEmitterSettings
4973
+ */
4974
+ maxRotation: number;
4975
+ /**
4976
+ * Minimum start scale ratio for particles (1 = no scaling)
4977
+ * @public
4978
+ * @type {number}
4979
+ * @name minStartScale
4980
+ * @default 1
4981
+ * @memberof ParticleEmitterSettings
4982
+ */
4983
+ minStartScale: number;
4984
+ /**
4985
+ * Maximum start scale ratio for particles (1 = no scaling)
4986
+ * @public
4987
+ * @type {number}
4988
+ * @name maxStartScale
4989
+ * @default 1
4990
+ * @memberof ParticleEmitterSettings
4991
+ */
4992
+ maxStartScale: number;
4993
+ /**
4994
+ * Minimum end scale ratio for particles
4995
+ * @public
4996
+ * @type {number}
4997
+ * @name minEndScale
4998
+ * @default 0
4999
+ * @memberof ParticleEmitterSettings
5000
+ */
5001
+ minEndScale: number;
5002
+ /**
5003
+ * Maximum end scale ratio for particles
5004
+ * @public
5005
+ * @type {number}
5006
+ * @name maxEndScale
5007
+ * @default 0
5008
+ * @memberof ParticleEmitterSettings
5009
+ */
5010
+ maxEndScale: number;
5011
+ /**
5012
+ * Vertical force (Gravity) for each particle
5013
+ * @public
5014
+ * @type {number}
5015
+ * @name gravity
5016
+ * @default 0
5017
+ * @memberof ParticleEmitterSettings
5018
+ * @see game.world.gravity
5019
+ */
5020
+ gravity: number;
5021
+ /**
5022
+ * Horizontal force (like a Wind) for each particle
5023
+ * @public
5024
+ * @type {number}
5025
+ * @name wind
5026
+ * @default 0
5027
+ * @memberof ParticleEmitterSettings
5028
+ */
5029
+ wind: number;
5030
+ /**
5031
+ * Update the rotation of particle in accordance the particle trajectory.<br>
5032
+ * The particle sprite should aim at zero angle (draw from left to right).<br>
5033
+ * Override the particle minRotation and maxRotation.<br>
5034
+ * @public
5035
+ * @type {boolean}
5036
+ * @name followTrajectory
5037
+ * @default false
5038
+ * @memberof ParticleEmitterSettings
5039
+ */
5040
+ followTrajectory: boolean;
5041
+ /**
5042
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
5043
+ * @public
5044
+ * @type {boolean}
5045
+ * @name textureAdditive
5046
+ * @default false
5047
+ * @memberof ParticleEmitterSettings
5048
+ * @see ParticleEmitterSettings.blendMode
5049
+ */
5050
+ textureAdditive: boolean;
5051
+ /**
5052
+ * the blend mode to be applied when rendering particles.
5053
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
5054
+ * @public
5055
+ * @type {string}
5056
+ * @name blendMode
5057
+ * @default normal
5058
+ * @memberof ParticleEmitterSettings
5059
+ * @see CanvasRenderer#setBlendMode
5060
+ * @see WebGLRenderer#setBlendMode
5061
+ */
5062
+ blendMode: string;
5063
+ /**
5064
+ * Update particles only in the viewport, remove it when out of viewport.
5065
+ * @public
5066
+ * @type {boolean}
5067
+ * @name onlyInViewport
5068
+ * @default true
5069
+ * @memberof ParticleEmitterSettings
5070
+ */
5071
+ onlyInViewport: boolean;
5072
+ /**
5073
+ * Render particles in screen space.
5074
+ * @public
5075
+ * @type {boolean}
5076
+ * @name floating
5077
+ * @default false
5078
+ * @memberof ParticleEmitterSettings
5079
+ */
5080
+ floating: boolean;
5081
+ /**
5082
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
5083
+ * @public
5084
+ * @type {number}
5085
+ * @name maxParticles
5086
+ * @default 10
5087
+ * @memberof ParticleEmitterSettings
5088
+ */
5089
+ maxParticles: number;
5090
+ /**
5091
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
5092
+ * @public
5093
+ * @type {number}
5094
+ * @name frequency
5095
+ * @default 100
5096
+ * @memberof ParticleEmitterSettings
5097
+ */
5098
+ frequency: number;
5099
+ /**
5100
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
5101
+ * After this period, the emitter stop the launch of particles.
5102
+ * @public
5103
+ * @type {number}
5104
+ * @name duration
5105
+ * @default Infinity
5106
+ * @memberof ParticleEmitterSettings
5107
+ */
5108
+ duration: number;
5109
+ /**
5110
+ * Skip n frames after updating the particle system once.
5111
+ * This can be used to reduce the performance impact of emitters with many particles.
5112
+ * @public
5113
+ * @type {number}
5114
+ * @name framesToSkip
5115
+ * @default 0
5116
+ * @memberof ParticleEmitterSettings
5117
+ */
5118
+ framesToSkip: number;
5119
+ }): void;
5120
+ _defaultParticle: any;
5121
+ /**
5122
+ * returns a random point on the x axis within the bounds of this emitter
5123
+ * @returns {number}
5124
+ */
5125
+ getRandomPointX(): number;
5126
+ /**
5127
+ * returns a random point on the y axis within the bounds this emitter
5128
+ * @returns {number}
5129
+ */
5130
+ getRandomPointY(): number;
5131
+ /** @ignore */
5132
+ addParticles(count: any): void;
5133
+ /**
5134
+ * Emitter is of type stream and is launching particles
5135
+ * @returns {boolean} Emitter is Stream and is launching particles
5136
+ */
5137
+ isRunning(): boolean;
5138
+ /**
5139
+ * Launch particles from emitter constantly (e.g. for stream)
5140
+ * @param {number} duration [optional] time that the emitter releases particles in ms
5141
+ */
5142
+ streamParticles(duration: number): void;
5143
+ /**
5144
+ * Stop the emitter from generating new particles (used only if emitter is Stream)
5145
+ */
5146
+ stopStream(): void;
5147
+ /**
5148
+ * Launch all particles from emitter and stop (e.g. for explosion)
5149
+ * @param {number} total [optional] number of particles to launch
5150
+ */
5151
+ burstParticles(total: number): void;
5152
+ /**
5153
+ * @ignore
5154
+ */
5155
+ update(dt: any): boolean;
5156
+ }
5157
+ export namespace ParticleEmitterSettings {
5158
+ const width: number;
5159
+ const height: number;
5160
+ const image: HTMLCanvasElement;
5161
+ const textureSize: number;
5162
+ const tint: string;
5163
+ const totalParticles: number;
5164
+ const angle: number;
5165
+ const angleVariation: number;
5166
+ const minLife: number;
5167
+ const maxLife: number;
5168
+ const speed: number;
5169
+ const speedVariation: number;
5170
+ const minRotation: number;
5171
+ const maxRotation: number;
5172
+ const minStartScale: number;
5173
+ const maxStartScale: number;
5174
+ const minEndScale: number;
5175
+ const maxEndScale: number;
5176
+ const gravity: number;
5177
+ const wind: number;
5178
+ const followTrajectory: boolean;
5179
+ const textureAdditive: boolean;
5180
+ const blendMode: string;
5181
+ const onlyInViewport: boolean;
5182
+ const floating: boolean;
5183
+ const maxParticles: number;
5184
+ const frequency: number;
5185
+ const duration: number;
5186
+ const framesToSkip: number;
5187
+ }
5188
+ /**
5189
+ * @classdesc
5190
+ * a pointer object, representing a single finger on a touch enabled device.
5191
+ * @class Pointer
5192
+ * @augments Bounds
5193
+ */
5194
+ export class Pointer extends Bounds {
5195
+ /**
5196
+ * @ignore
5197
+ */
5198
+ constructor(x?: number, y?: number, w?: number, h?: number);
5199
+ /**
5200
+ * constant for left button
5201
+ * @public
5202
+ * @type {number}
5203
+ * @name LEFT
5204
+ * @memberof Pointer
5205
+ */
5206
+ public LEFT: number;
5207
+ /**
5208
+ * constant for middle button
5209
+ * @public
5210
+ * @type {number}
5211
+ * @name MIDDLE
5212
+ * @memberof Pointer
5213
+ */
5214
+ public MIDDLE: number;
5215
+ /**
5216
+ * constant for right button
5217
+ * @public
5218
+ * @type {number}
5219
+ * @name RIGHT
5220
+ * @memberof Pointer
5221
+ */
5222
+ public RIGHT: number;
5223
+ /**
5224
+ * the originating Event Object
5225
+ * @public
5226
+ * @type {PointerEvent|TouchEvent|MouseEvent}
5227
+ * @name event
5228
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent
5229
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent
5230
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
5231
+ * @memberof Pointer
5232
+ */
5233
+ public event: PointerEvent | TouchEvent | MouseEvent;
5234
+ /**
5235
+ * a string containing the event's type.
5236
+ * @public
5237
+ * @type {string}
5238
+ * @name type
4526
5239
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Event/type
4527
5240
  * @memberof Pointer
4528
5241
  */
@@ -4762,7 +5475,7 @@ export class Polygon {
4762
5475
  * @public
4763
5476
  * @type {Vector2d}
4764
5477
  * @name pos
4765
- * @memberof Polygon#
5478
+ * @memberof Polygon
4766
5479
  */
4767
5480
  public pos: Vector2d;
4768
5481
  /**
@@ -4770,7 +5483,7 @@ export class Polygon {
4770
5483
  * @ignore
4771
5484
  * @type {Bounds}
4772
5485
  * @name _bounds
4773
- * @memberof Polygon#
5486
+ * @memberof Polygon
4774
5487
  */
4775
5488
  _bounds: Bounds;
4776
5489
  /**
@@ -4779,7 +5492,7 @@ export class Polygon {
4779
5492
  * @public
4780
5493
  * @type {Vector2d[]}
4781
5494
  * @name points
4782
- * @memberof Polygon#
5495
+ * @memberof Polygon
4783
5496
  */
4784
5497
  public points: Vector2d[];
4785
5498
  /**
@@ -4807,7 +5520,7 @@ export class Polygon {
4807
5520
  /**
4808
5521
  * set new value to the Polygon
4809
5522
  * @name setShape
4810
- * @memberof Polygon.prototype
5523
+ * @memberof Polygon
4811
5524
  * @function
4812
5525
  * @param {number} x position of the Polygon
4813
5526
  * @param {number} y position of the Polygon
@@ -4818,7 +5531,7 @@ export class Polygon {
4818
5531
  /**
4819
5532
  * set the vertices defining this Polygon
4820
5533
  * @name setVertices
4821
- * @memberof Polygon.prototype
5534
+ * @memberof Polygon
4822
5535
  * @function
4823
5536
  * @param {Vector2d[]} vertices array of vector or vertice defining the Polygon
4824
5537
  * @returns {Polygon} this instance for objecf chaining
@@ -4827,7 +5540,7 @@ export class Polygon {
4827
5540
  /**
4828
5541
  * apply the given transformation matrix to this Polygon
4829
5542
  * @name transform
4830
- * @memberof Polygon.prototype
5543
+ * @memberof Polygon
4831
5544
  * @function
4832
5545
  * @param {Matrix2d} m the transformation matrix
4833
5546
  * @returns {Polygon} Reference to this object for method chaining
@@ -4836,7 +5549,7 @@ export class Polygon {
4836
5549
  /**
4837
5550
  * apply an isometric projection to this shape
4838
5551
  * @name toIso
4839
- * @memberof Polygon.prototype
5552
+ * @memberof Polygon
4840
5553
  * @function
4841
5554
  * @returns {Polygon} Reference to this object for method chaining
4842
5555
  */
@@ -4844,7 +5557,7 @@ export class Polygon {
4844
5557
  /**
4845
5558
  * apply a 2d projection to this shape
4846
5559
  * @name to2d
4847
- * @memberof Polygon.prototype
5560
+ * @memberof Polygon
4848
5561
  * @function
4849
5562
  * @returns {Polygon} Reference to this object for method chaining
4850
5563
  */
@@ -4852,7 +5565,7 @@ export class Polygon {
4852
5565
  /**
4853
5566
  * Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
4854
5567
  * @name rotate
4855
- * @memberof Polygon.prototype
5568
+ * @memberof Polygon
4856
5569
  * @function
4857
5570
  * @param {number} angle The angle to rotate (in radians)
4858
5571
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -4862,7 +5575,7 @@ export class Polygon {
4862
5575
  /**
4863
5576
  * Scale this Polygon by the given scalar.
4864
5577
  * @name scale
4865
- * @memberof Polygon.prototype
5578
+ * @memberof Polygon
4866
5579
  * @function
4867
5580
  * @param {number} x
4868
5581
  * @param {number} [y=x]
@@ -4872,7 +5585,7 @@ export class Polygon {
4872
5585
  /**
4873
5586
  * Scale this Polygon by the given vector
4874
5587
  * @name scaleV
4875
- * @memberof Polygon.prototype
5588
+ * @memberof Polygon
4876
5589
  * @function
4877
5590
  * @param {Vector2d} v
4878
5591
  * @returns {Polygon} Reference to this object for method chaining
@@ -4882,7 +5595,7 @@ export class Polygon {
4882
5595
  * Computes the calculated collision polygon.
4883
5596
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
4884
5597
  * @name recalc
4885
- * @memberof Polygon.prototype
5598
+ * @memberof Polygon
4886
5599
  * @function
4887
5600
  * @returns {Polygon} Reference to this object for method chaining
4888
5601
  */
@@ -4890,7 +5603,7 @@ export class Polygon {
4890
5603
  /**
4891
5604
  * returns a list of indices for all triangles defined in this polygon
4892
5605
  * @name getIndices
4893
- * @memberof Polygon.prototype
5606
+ * @memberof Polygon
4894
5607
  * @function
4895
5608
  * @returns {Array} an array of vertex indices for all triangles forming this polygon.
4896
5609
  */
@@ -4898,7 +5611,7 @@ export class Polygon {
4898
5611
  /**
4899
5612
  * Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
4900
5613
  * @name isConvex
4901
- * @memberof Polygon.prototype
5614
+ * @memberof Polygon
4902
5615
  * @function
4903
5616
  * @returns {boolean} true if the vertices are convex, false if not, null if not computable
4904
5617
  */
@@ -4906,7 +5619,7 @@ export class Polygon {
4906
5619
  /**
4907
5620
  * translate the Polygon by the specified offset
4908
5621
  * @name translate
4909
- * @memberof Polygon.prototype
5622
+ * @memberof Polygon
4910
5623
  * @function
4911
5624
  * @param {number} x x offset
4912
5625
  * @param {number} y y offset
@@ -4915,7 +5628,7 @@ export class Polygon {
4915
5628
  /**
4916
5629
  * translate the Polygon by the specified vector
4917
5630
  * @name translate
4918
- * @memberof Polygon.prototype
5631
+ * @memberof Polygon
4919
5632
  * @function
4920
5633
  * @param {Vector2d} v vector offset
4921
5634
  * @returns {Polygon} Reference to this object for method chaining
@@ -4942,7 +5655,7 @@ export class Polygon {
4942
5655
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
4943
5656
  * bounding rect, as the function can be highly consuming with complex shapes)
4944
5657
  * @name contains
4945
- * @memberof Polygon.prototype
5658
+ * @memberof Polygon
4946
5659
  * @function
4947
5660
  * @param {Vector2d} point
4948
5661
  * @returns {boolean} true if contains
@@ -4952,7 +5665,7 @@ export class Polygon {
4952
5665
  * (Note: it is highly recommended to first do a hit test on the corresponding <br>
4953
5666
  * bounding rect, as the function can be highly consuming with complex shapes)
4954
5667
  * @name contains
4955
- * @memberof Polygon.prototype
5668
+ * @memberof Polygon
4956
5669
  * @function
4957
5670
  * @param {number} x x coordinate
4958
5671
  * @param {number} y y coordinate
@@ -4962,7 +5675,7 @@ export class Polygon {
4962
5675
  /**
4963
5676
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
4964
5677
  * @name getBounds
4965
- * @memberof Polygon.prototype
5678
+ * @memberof Polygon
4966
5679
  * @function
4967
5680
  * @returns {Bounds} this shape bounding box Rectangle object
4968
5681
  */
@@ -4971,7 +5684,7 @@ export class Polygon {
4971
5684
  * update the bounding box for this shape.
4972
5685
  * @ignore
4973
5686
  * @name updateBounds
4974
- * @memberof Polygon.prototype
5687
+ * @memberof Polygon
4975
5688
  * @function
4976
5689
  * @returns {Bounds} this shape bounding box Rectangle object
4977
5690
  */
@@ -4979,7 +5692,7 @@ export class Polygon {
4979
5692
  /**
4980
5693
  * clone this Polygon
4981
5694
  * @name clone
4982
- * @memberof Polygon.prototype
5695
+ * @memberof Polygon
4983
5696
  * @function
4984
5697
  * @returns {Polygon} new Polygon
4985
5698
  */
@@ -5074,7 +5787,7 @@ export class QuadTree {
5074
5787
  * a rectangle Object
5075
5788
  * @augments Polygon
5076
5789
  */
5077
- export class Rect extends Polygon {
5790
+ declare class Rect$1 extends Polygon {
5078
5791
  /**
5079
5792
  * @param {number} x position of the Rectangle
5080
5793
  * @param {number} y position of the Rectangle
@@ -5087,7 +5800,7 @@ export class Rect extends Polygon {
5087
5800
  /**
5088
5801
  * set new value to the rectangle shape
5089
5802
  * @name setShape
5090
- * @memberof Rect.prototype
5803
+ * @memberof Rect
5091
5804
  * @function
5092
5805
  * @param {number} x position of the Rectangle
5093
5806
  * @param {number} y position of the Rectangle
@@ -5167,7 +5880,7 @@ export class Rect extends Polygon {
5167
5880
  /**
5168
5881
  * center the rectangle position around the given coordinates
5169
5882
  * @name centerOn
5170
- * @memberof Rect.prototype
5883
+ * @memberof Rect
5171
5884
  * @function
5172
5885
  * @param {number} x the x coordinate around which to center this rectangle
5173
5886
  * @param {number} x the y coordinate around which to center this rectangle
@@ -5177,7 +5890,7 @@ export class Rect extends Polygon {
5177
5890
  /**
5178
5891
  * resize the rectangle
5179
5892
  * @name resize
5180
- * @memberof Rect.prototype
5893
+ * @memberof Rect
5181
5894
  * @function
5182
5895
  * @param {number} w new width of the rectangle
5183
5896
  * @param {number} h new height of the rectangle
@@ -5187,7 +5900,7 @@ export class Rect extends Polygon {
5187
5900
  /**
5188
5901
  * scale the rectangle
5189
5902
  * @name scale
5190
- * @memberof Rect.prototype
5903
+ * @memberof Rect
5191
5904
  * @function
5192
5905
  * @param {number} x a number representing the abscissa of the scaling vector.
5193
5906
  * @param {number} [y=x] a number representing the ordinate of the scaling vector.
@@ -5197,7 +5910,7 @@ export class Rect extends Polygon {
5197
5910
  /**
5198
5911
  * clone this rectangle
5199
5912
  * @name clone
5200
- * @memberof Rect.prototype
5913
+ * @memberof Rect
5201
5914
  * @function
5202
5915
  * @returns {Rect} new rectangle
5203
5916
  */
@@ -5205,7 +5918,7 @@ export class Rect extends Polygon {
5205
5918
  /**
5206
5919
  * copy the position and size of the given rectangle into this one
5207
5920
  * @name copy
5208
- * @memberof Rect.prototype
5921
+ * @memberof Rect
5209
5922
  * @function
5210
5923
  * @param {Rect} rect Source rectangle
5211
5924
  * @returns {Rect} new rectangle
@@ -5214,7 +5927,7 @@ export class Rect extends Polygon {
5214
5927
  /**
5215
5928
  * merge this rectangle with another one
5216
5929
  * @name union
5217
- * @memberof Rect.prototype
5930
+ * @memberof Rect
5218
5931
  * @function
5219
5932
  * @param {Rect} rect other rectangle to union with
5220
5933
  * @returns {Rect} the union(ed) rectangle
@@ -5223,7 +5936,7 @@ export class Rect extends Polygon {
5223
5936
  /**
5224
5937
  * check if this rectangle is intersecting with the specified one
5225
5938
  * @name overlaps
5226
- * @memberof Rect.prototype
5939
+ * @memberof Rect
5227
5940
  * @function
5228
5941
  * @param {Rect} rect
5229
5942
  * @returns {boolean} true if overlaps
@@ -5232,7 +5945,7 @@ export class Rect extends Polygon {
5232
5945
  /**
5233
5946
  * check if this rectangle is identical to the specified one
5234
5947
  * @name equals
5235
- * @memberof Rect.prototype
5948
+ * @memberof Rect
5236
5949
  * @function
5237
5950
  * @param {Rect} rect
5238
5951
  * @returns {boolean} true if equals
@@ -5241,7 +5954,7 @@ export class Rect extends Polygon {
5241
5954
  /**
5242
5955
  * determines whether all coordinates of this rectangle are finite numbers.
5243
5956
  * @name isFinite
5244
- * @memberof Rect.prototype
5957
+ * @memberof Rect
5245
5958
  * @function
5246
5959
  * @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
5247
5960
  */
@@ -5249,7 +5962,7 @@ export class Rect extends Polygon {
5249
5962
  /**
5250
5963
  * Returns a polygon whose edges are the same as this box.
5251
5964
  * @name toPolygon
5252
- * @memberof Rect.prototype
5965
+ * @memberof Rect
5253
5966
  * @function
5254
5967
  * @returns {Polygon} a new Polygon that represents this rectangle.
5255
5968
  */
@@ -5260,7 +5973,14 @@ export class Rect extends Polygon {
5260
5973
  * A base class for renderable objects.
5261
5974
  * @augments Rect
5262
5975
  */
5263
- export class Renderable extends Rect {
5976
+ export class Renderable {
5977
+ /**
5978
+ * @param {number} x position of the renderable object (accessible through inherited pos.x property)
5979
+ * @param {number} y position of the renderable object (accessible through inherited pos.y property)
5980
+ * @param {number} width object width
5981
+ * @param {number} height object height
5982
+ */
5983
+ constructor(x: number, y: number, width: number, height: number);
5264
5984
  /**
5265
5985
  * to identify the object as a renderable object
5266
5986
  * @ignore
@@ -5444,7 +6164,7 @@ export class Renderable extends Rect {
5444
6164
  * A mask limits rendering elements to the shape and position of the given mask object.
5445
6165
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
5446
6166
  * @public
5447
- * @type {Rect|Polygon|Line|Ellipse}
6167
+ * @type {Rect|RoundRect|Polygon|Line|Ellipse}
5448
6168
  * @name mask
5449
6169
  * @default undefined
5450
6170
  * @memberof Renderable#
@@ -5464,7 +6184,7 @@ export class Renderable extends Rect {
5464
6184
  * {x: -14, y: 30}
5465
6185
  * ]);
5466
6186
  */
5467
- public mask: Rect | Polygon | Line | Ellipse;
6187
+ public mask: Rect | RoundRect | Polygon | Line | Ellipse;
5468
6188
  /**
5469
6189
  * define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
5470
6190
  * @public
@@ -5556,11 +6276,19 @@ export class Renderable extends Rect {
5556
6276
  * @name isFlippedY
5557
6277
  * @memberof Renderable
5558
6278
  */
5559
- public get isFlippedY(): boolean;
6279
+ public get isFlippedY(): boolean;
6280
+ /**
6281
+ * returns the bounding box for this renderable
6282
+ * @name getBounds
6283
+ * @memberof Renderable
6284
+ * @function
6285
+ * @returns {Bounds} bounding box Rectangle object
6286
+ */
6287
+ getBounds(): Bounds;
5560
6288
  /**
5561
6289
  * get the renderable alpha channel value<br>
5562
6290
  * @name getOpacity
5563
- * @memberof Renderable.prototype
6291
+ * @memberof Renderable
5564
6292
  * @function
5565
6293
  * @returns {number} current opacity value between 0 and 1
5566
6294
  */
@@ -5568,7 +6296,7 @@ export class Renderable extends Rect {
5568
6296
  /**
5569
6297
  * set the renderable alpha channel value<br>
5570
6298
  * @name setOpacity
5571
- * @memberof Renderable.prototype
6299
+ * @memberof Renderable
5572
6300
  * @function
5573
6301
  * @param {number} alpha opacity value between 0.0 and 1.0
5574
6302
  */
@@ -5577,7 +6305,7 @@ export class Renderable extends Rect {
5577
6305
  * flip the renderable on the horizontal axis (around the center of the renderable)
5578
6306
  * @see Matrix2d#scaleX
5579
6307
  * @name flipX
5580
- * @memberof Renderable.prototype
6308
+ * @memberof Renderable
5581
6309
  * @function
5582
6310
  * @param {boolean} [flip=true] `true` to flip this renderable.
5583
6311
  * @returns {Renderable} Reference to this object for method chaining
@@ -5587,7 +6315,7 @@ export class Renderable extends Rect {
5587
6315
  * flip the renderable on the vertical axis (around the center of the renderable)
5588
6316
  * @see Matrix2d#scaleY
5589
6317
  * @name flipY
5590
- * @memberof Renderable.prototype
6318
+ * @memberof Renderable
5591
6319
  * @function
5592
6320
  * @param {boolean} [flip=true] `true` to flip this renderable.
5593
6321
  * @returns {Renderable} Reference to this object for method chaining
@@ -5596,7 +6324,7 @@ export class Renderable extends Rect {
5596
6324
  /**
5597
6325
  * multiply the renderable currentTransform with the given matrix
5598
6326
  * @name transform
5599
- * @memberof Renderable.prototype
6327
+ * @memberof Renderable
5600
6328
  * @see Renderable#currentTransform
5601
6329
  * @function
5602
6330
  * @param {Matrix2d} m the transformation matrix
@@ -5624,7 +6352,7 @@ export class Renderable extends Rect {
5624
6352
  /**
5625
6353
  * Rotate this renderable towards the given target.
5626
6354
  * @name lookAt
5627
- * @memberof Renderable.prototype
6355
+ * @memberof Renderable
5628
6356
  * @function
5629
6357
  * @param {Renderable|Vector2d|Vector3d} target the renderable or position to look at
5630
6358
  * @returns {Renderable} Reference to this object for method chaining
@@ -5633,7 +6361,7 @@ export class Renderable extends Rect {
5633
6361
  /**
5634
6362
  * Rotate this renderable by the specified angle (in radians).
5635
6363
  * @name rotate
5636
- * @memberof Renderable.prototype
6364
+ * @memberof Renderable
5637
6365
  * @function
5638
6366
  * @param {number} angle The angle to rotate (in radians)
5639
6367
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
@@ -5647,7 +6375,7 @@ export class Renderable extends Rect {
5647
6375
  * is an image, the image.width and image.height properties are unaltered but the currentTransform
5648
6376
  * member will be changed.
5649
6377
  * @name scale
5650
- * @memberof Renderable.prototype
6378
+ * @memberof Renderable
5651
6379
  * @function
5652
6380
  * @param {number} x a number representing the abscissa of the scaling vector.
5653
6381
  * @param {number} [y=x] a number representing the ordinate of the scaling vector.
@@ -5657,7 +6385,7 @@ export class Renderable extends Rect {
5657
6385
  /**
5658
6386
  * scale the renderable around his anchor point
5659
6387
  * @name scaleV
5660
- * @memberof Renderable.prototype
6388
+ * @memberof Renderable
5661
6389
  * @function
5662
6390
  * @param {Vector2d} v scaling vector
5663
6391
  * @returns {Renderable} Reference to this object for method chaining
@@ -5667,25 +6395,34 @@ export class Renderable extends Rect {
5667
6395
  * update function. <br>
5668
6396
  * automatically called by the game manager {@link game}
5669
6397
  * @name update
5670
- * @memberof Renderable.prototype
6398
+ * @memberof Renderable
5671
6399
  * @function
5672
6400
  * @protected
5673
6401
  * @param {number} dt time since the last update in milliseconds.
5674
6402
  * @returns {boolean} true if the renderable is dirty
5675
6403
  */
5676
6404
  protected update(dt: number): boolean;
6405
+ /**
6406
+ * update the bounding box for this shape.
6407
+ * @ignore
6408
+ * @name updateBounds
6409
+ * @memberof Renderable
6410
+ * @function
6411
+ * @returns {Bounds} this shape bounding box Rectangle object
6412
+ */
6413
+ updateBounds(): Bounds;
5677
6414
  /**
5678
6415
  * update the renderable's bounding rect (private)
5679
6416
  * @ignore
5680
6417
  * @name updateBoundsPos
5681
- * @memberof Renderable.prototype
6418
+ * @memberof Renderable
5682
6419
  * @function
5683
6420
  */
5684
6421
  updateBoundsPos(newX: any, newY: any): void;
5685
6422
  /**
5686
6423
  * return the renderable absolute position in the game world
5687
6424
  * @name getAbsolutePosition
5688
- * @memberof Renderable.prototype
6425
+ * @memberof Renderable
5689
6426
  * @function
5690
6427
  * @returns {Vector2d}
5691
6428
  */
@@ -5695,7 +6432,7 @@ export class Renderable extends Rect {
5695
6432
  * called when the anchor point value is changed
5696
6433
  * @private
5697
6434
  * @name onAnchorUpdate
5698
- * @memberof Renderable.prototype
6435
+ * @memberof Renderable
5699
6436
  * @function
5700
6437
  * @param {number} x the new X value to be set for the anchor
5701
6438
  * @param {number} y the new Y value to be set for the anchor
@@ -5706,7 +6443,7 @@ export class Renderable extends Rect {
5706
6443
  * (apply defined transforms, anchor point). <br>
5707
6444
  * automatically called by the game manager {@link game}
5708
6445
  * @name preDraw
5709
- * @memberof Renderable.prototype
6446
+ * @memberof Renderable
5710
6447
  * @function
5711
6448
  * @protected
5712
6449
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
@@ -5716,7 +6453,7 @@ export class Renderable extends Rect {
5716
6453
  * object draw. <br>
5717
6454
  * automatically called by the game manager {@link game}
5718
6455
  * @name draw
5719
- * @memberof Renderable.prototype
6456
+ * @memberof Renderable
5720
6457
  * @function
5721
6458
  * @protected
5722
6459
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
@@ -5726,7 +6463,7 @@ export class Renderable extends Rect {
5726
6463
  * restore the rendering context after drawing. <br>
5727
6464
  * automatically called by the game manager {@link game}
5728
6465
  * @name postDraw
5729
- * @memberof Renderable.prototype
6466
+ * @memberof Renderable
5730
6467
  * @function
5731
6468
  * @protected
5732
6469
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
@@ -5736,7 +6473,7 @@ export class Renderable extends Rect {
5736
6473
  * onCollision callback, triggered in case of collision,
5737
6474
  * when this renderable body is colliding with another one
5738
6475
  * @name onCollision
5739
- * @memberof Renderable.prototype
6476
+ * @memberof Renderable
5740
6477
  * @function
5741
6478
  * @param {collision.ResponseObject} response the collision response object
5742
6479
  * @param {Renderable} other the other renderable touching this one (a reference to response.a or response.b)
@@ -5761,6 +6498,7 @@ export class Renderable extends Rect {
5761
6498
  * @ignore
5762
6499
  */
5763
6500
  destroy(...args: any[]): void;
6501
+ _bounds: any;
5764
6502
  /**
5765
6503
  * OnDestroy Notification function<br>
5766
6504
  * Called by engine before deleting the object
@@ -5828,15 +6566,26 @@ export class Renderer {
5828
6566
  /**
5829
6567
  * true if the current rendering context is valid
5830
6568
  * @name isContextValid
5831
- * @memberof Renderer
6569
+ * @memberof Renderer#
5832
6570
  * @default true
5833
6571
  * type {boolean}
5834
6572
  */
5835
6573
  isContextValid: boolean;
6574
+ /**
6575
+ * The Path2D instance used by the renderer to draw primitives
6576
+ * @name path2D
6577
+ * @type {Path2D}
6578
+ * @memberof Renderer#
6579
+ */
6580
+ path2D: Path2D;
5836
6581
  /**
5837
6582
  * @ignore
5838
6583
  */
5839
6584
  currentScissor: Int32Array;
6585
+ /**
6586
+ * @ignore
6587
+ */
6588
+ maskLevel: number;
5840
6589
  /**
5841
6590
  * @ignore
5842
6591
  */
@@ -5851,21 +6600,21 @@ export class Renderer {
5851
6600
  /**
5852
6601
  * prepare the framebuffer for drawing a new frame
5853
6602
  * @name clear
5854
- * @memberof Renderer.prototype
6603
+ * @memberof Renderer
5855
6604
  * @function
5856
6605
  */
5857
6606
  clear(): void;
5858
6607
  /**
5859
6608
  * Reset context state
5860
6609
  * @name reset
5861
- * @memberof Renderer.prototype
6610
+ * @memberof Renderer
5862
6611
  * @function
5863
6612
  */
5864
6613
  reset(): void;
5865
6614
  /**
5866
6615
  * return a reference to the system canvas
5867
6616
  * @name getCanvas
5868
- * @memberof Renderer.prototype
6617
+ * @memberof Renderer
5869
6618
  * @function
5870
6619
  * @returns {HTMLCanvasElement}
5871
6620
  */
@@ -5873,7 +6622,7 @@ export class Renderer {
5873
6622
  /**
5874
6623
  * return a reference to the screen canvas
5875
6624
  * @name getScreenCanvas
5876
- * @memberof Renderer.prototype
6625
+ * @memberof Renderer
5877
6626
  * @function
5878
6627
  * @returns {HTMLCanvasElement}
5879
6628
  */
@@ -5882,7 +6631,7 @@ export class Renderer {
5882
6631
  * return a reference to the screen canvas corresponding 2d Context<br>
5883
6632
  * (will return buffered context if double buffering is enabled, or a reference to the Screen Context)
5884
6633
  * @name getScreenContext
5885
- * @memberof Renderer.prototype
6634
+ * @memberof Renderer
5886
6635
  * @function
5887
6636
  * @returns {CanvasRenderingContext2D}
5888
6637
  */
@@ -5890,7 +6639,7 @@ export class Renderer {
5890
6639
  /**
5891
6640
  * returns the current blend mode for this renderer
5892
6641
  * @name getBlendMode
5893
- * @memberof Renderer.prototype
6642
+ * @memberof Renderer
5894
6643
  * @function
5895
6644
  * @returns {string} blend mode
5896
6645
  */
@@ -5899,7 +6648,7 @@ export class Renderer {
5899
6648
  * Returns the 2D Context object of the given Canvas<br>
5900
6649
  * Also configures anti-aliasing and blend modes based on constructor options.
5901
6650
  * @name getContext2d
5902
- * @memberof Renderer.prototype
6651
+ * @memberof Renderer
5903
6652
  * @function
5904
6653
  * @param {HTMLCanvasElement} canvas
5905
6654
  * @param {boolean} [transparent=true] use false to disable transparency
@@ -5909,7 +6658,7 @@ export class Renderer {
5909
6658
  /**
5910
6659
  * return the width of the system Canvas
5911
6660
  * @name getWidth
5912
- * @memberof Renderer.prototype
6661
+ * @memberof Renderer
5913
6662
  * @function
5914
6663
  * @returns {number}
5915
6664
  */
@@ -5917,7 +6666,7 @@ export class Renderer {
5917
6666
  /**
5918
6667
  * return the height of the system Canvas
5919
6668
  * @name getHeight
5920
- * @memberof Renderer.prototype
6669
+ * @memberof Renderer
5921
6670
  * @function
5922
6671
  * @returns {number} height of the system Canvas
5923
6672
  */
@@ -5925,7 +6674,7 @@ export class Renderer {
5925
6674
  /**
5926
6675
  * get the current fill & stroke style color.
5927
6676
  * @name getColor
5928
- * @memberof Renderer.prototype
6677
+ * @memberof Renderer
5929
6678
  * @function
5930
6679
  * @returns {Color} current global color
5931
6680
  */
@@ -5933,7 +6682,7 @@ export class Renderer {
5933
6682
  /**
5934
6683
  * return the current global alpha
5935
6684
  * @name globalAlpha
5936
- * @memberof Renderer.prototype
6685
+ * @memberof Renderer
5937
6686
  * @function
5938
6687
  * @returns {number}
5939
6688
  */
@@ -5941,7 +6690,7 @@ export class Renderer {
5941
6690
  /**
5942
6691
  * check if the given rect or bounds overlaps with the renderer screen coordinates
5943
6692
  * @name overlaps
5944
- * @memberof Renderer.prototype
6693
+ * @memberof Renderer
5945
6694
  * @function
5946
6695
  * @param {Rect|Bounds} bounds
5947
6696
  * @returns {boolean} true if overlaps
@@ -5950,7 +6699,7 @@ export class Renderer {
5950
6699
  /**
5951
6700
  * resizes the system canvas
5952
6701
  * @name resize
5953
- * @memberof Renderer.prototype
6702
+ * @memberof Renderer
5954
6703
  * @function
5955
6704
  * @param {number} width new width of the canvas
5956
6705
  * @param {number} height new height of the canvas
@@ -5959,7 +6708,7 @@ export class Renderer {
5959
6708
  /**
5960
6709
  * enable/disable image smoothing (scaling interpolation) for the given context
5961
6710
  * @name setAntiAlias
5962
- * @memberof Renderer.prototype
6711
+ * @memberof Renderer
5963
6712
  * @function
5964
6713
  * @param {CanvasRenderingContext2D} context
5965
6714
  * @param {boolean} [enable=false]
@@ -5968,7 +6717,7 @@ export class Renderer {
5968
6717
  /**
5969
6718
  * set/change the current projection matrix (WebGL only)
5970
6719
  * @name setProjection
5971
- * @memberof Renderer.prototype
6720
+ * @memberof Renderer
5972
6721
  * @function
5973
6722
  * @param {Matrix3d} matrix
5974
6723
  */
@@ -5976,16 +6725,24 @@ export class Renderer {
5976
6725
  /**
5977
6726
  * stroke the given shape
5978
6727
  * @name stroke
5979
- * @memberof Renderer.prototype
6728
+ * @memberof Renderer
5980
6729
  * @function
5981
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
6730
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
5982
6731
  * @param {boolean} [fill=false] fill the shape with the current color if true
5983
6732
  */
5984
- stroke(shape: Rect | Polygon | Line | Ellipse, fill?: boolean): void;
6733
+ stroke(shape: Rect | RoundRect | Polygon | Line | Ellipse, fill?: boolean): void;
6734
+ /**
6735
+ * fill the given shape
6736
+ * @name fill
6737
+ * @memberof Renderer
6738
+ * @function
6739
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to fill
6740
+ */
6741
+ fill(shape: Rect | RoundRect | Polygon | Line | Ellipse): void;
5985
6742
  /**
5986
6743
  * tint the given image or canvas using the given color
5987
6744
  * @name tint
5988
- * @memberof Renderer.prototype
6745
+ * @memberof Renderer
5989
6746
  * @function
5990
6747
  * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
5991
6748
  * @param {Color|string} color the color that will be used to tint the image
@@ -5993,36 +6750,29 @@ export class Renderer {
5993
6750
  * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
5994
6751
  */
5995
6752
  tint(src: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, color: Color | string, mode?: string): HTMLCanvasElement | OffscreenCanvas;
5996
- /**
5997
- * fill the given shape
5998
- * @name fill
5999
- * @memberof Renderer.prototype
6000
- * @function
6001
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
6002
- */
6003
- fill(shape: Rect | Polygon | Line | Ellipse): void;
6004
6753
  /**
6005
6754
  * A mask limits rendering elements to the shape and position of the given mask object.
6006
6755
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
6007
6756
  * Mask are not preserved through renderer context save and restore.
6008
6757
  * @name setMask
6009
- * @memberof Renderer.prototype
6758
+ * @memberof Renderer
6010
6759
  * @function
6011
- * @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
6760
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
6761
+ * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
6012
6762
  */
6013
- setMask(mask?: Rect | Polygon | Line | Ellipse): void;
6763
+ setMask(mask?: Rect | RoundRect | Polygon | Line | Ellipse): void;
6014
6764
  /**
6015
6765
  * disable (remove) the rendering mask set through setMask.
6016
6766
  * @name clearMask
6017
6767
  * @see Renderer#setMask
6018
- * @memberof Renderer.prototype
6768
+ * @memberof Renderer
6019
6769
  * @function
6020
6770
  */
6021
6771
  clearMask(): void;
6022
6772
  /**
6023
6773
  * set a coloring tint for sprite based renderables
6024
6774
  * @name setTint
6025
- * @memberof Renderer.prototype
6775
+ * @memberof Renderer
6026
6776
  * @function
6027
6777
  * @param {Color} tint the tint color
6028
6778
  * @param {number} [alpha] an alpha value to be applied to the tint
@@ -6032,7 +6782,7 @@ export class Renderer {
6032
6782
  * clear the rendering tint set through setTint.
6033
6783
  * @name clearTint
6034
6784
  * @see Renderer#setTint
6035
- * @memberof Renderer.prototype
6785
+ * @memberof Renderer
6036
6786
  * @function
6037
6787
  */
6038
6788
  clearTint(): void;
@@ -6042,6 +6792,78 @@ export class Renderer {
6042
6792
  drawFont(): void;
6043
6793
  get Texture(): typeof TextureAtlas;
6044
6794
  }
6795
+ /**
6796
+ * @classdesc
6797
+ * a rectangle object with rounded corners
6798
+ * @augments Rect
6799
+ */
6800
+ export class RoundRect {
6801
+ /**
6802
+ * @param {number} x position of the rounded rectangle
6803
+ * @param {number} y position of the rounded rectangle
6804
+ * @param {number} width the rectangle width
6805
+ * @param {number} height the rectangle height
6806
+ * @param {number} [radius=20] the radius of the rounded corner
6807
+ */
6808
+ constructor(x: number, y: number, width: number, height: number, radius?: number);
6809
+ public set radius(arg: number);
6810
+ /**
6811
+ * the radius of the rounded corner
6812
+ * @public
6813
+ * @type {number}
6814
+ * @default 20
6815
+ * @name radius
6816
+ * @memberof RoundRect
6817
+ */
6818
+ public get radius(): number;
6819
+ /** @ignore */
6820
+ onResetEvent(x: any, y: any, w: any, h: any, radius: any): void;
6821
+ _radius: number;
6822
+ /**
6823
+ * copy the position, size and radius of the given rounded rectangle into this one
6824
+ * @name copy
6825
+ * @memberof RoundRect
6826
+ * @function
6827
+ * @param {RoundRect} rrect source rounded rectangle
6828
+ * @returns {RoundRect} new rectangle
6829
+ */
6830
+ copy(rrect: RoundRect): RoundRect;
6831
+ /**
6832
+ * Returns true if the rounded rectangle contains the given point
6833
+ * @name contains
6834
+ * @memberof RoundRect
6835
+ * @function
6836
+ * @param {number} x x coordinate
6837
+ * @param {number} y y coordinate
6838
+ * @returns {boolean} true if contains
6839
+ */
6840
+ /**
6841
+ * Returns true if the rounded rectangle contains the given point
6842
+ * @name contains
6843
+ * @memberof RoundRect
6844
+ * @function
6845
+ * @param {Vector2d} point
6846
+ * @returns {boolean} true if contains
6847
+ */
6848
+ contains(...args: any[]): boolean;
6849
+ /**
6850
+ * check if this RoundRect is identical to the specified one
6851
+ * @name equals
6852
+ * @memberof RoundRect
6853
+ * @function
6854
+ * @param {RoundRect} rrect
6855
+ * @returns {boolean} true if equals
6856
+ */
6857
+ equals(rrect: RoundRect): boolean;
6858
+ /**
6859
+ * clone this RoundRect
6860
+ * @name clone
6861
+ * @memberof RoundRect
6862
+ * @function
6863
+ * @returns {RoundRect} new RoundRect
6864
+ */
6865
+ clone(): RoundRect;
6866
+ }
6045
6867
  /**
6046
6868
  * @classdesc
6047
6869
  * An object to display a fixed or animated sprite on screen.
@@ -6129,7 +6951,7 @@ export class Sprite extends Renderable {
6129
6951
  current: {
6130
6952
  name: string;
6131
6953
  length: number;
6132
- offset: Vector2d;
6954
+ offset: any;
6133
6955
  width: number;
6134
6956
  height: number;
6135
6957
  angle: number;
@@ -6145,10 +6967,12 @@ export class Sprite extends Renderable {
6145
6967
  image: HTMLCanvasElement | HTMLImageElement;
6146
6968
  textureAtlas: any;
6147
6969
  atlasIndices: any;
6970
+ width: number;
6971
+ height: number;
6148
6972
  /**
6149
6973
  * return the flickering state of the object
6150
6974
  * @name isFlickering
6151
- * @memberof Sprite.prototype
6975
+ * @memberof Sprite
6152
6976
  * @function
6153
6977
  * @returns {boolean}
6154
6978
  */
@@ -6156,7 +6980,7 @@ export class Sprite extends Renderable {
6156
6980
  /**
6157
6981
  * make the object flicker
6158
6982
  * @name flicker
6159
- * @memberof Sprite.prototype
6983
+ * @memberof Sprite
6160
6984
  * @function
6161
6985
  * @param {number} duration expressed in milliseconds
6162
6986
  * @param {Function} callback Function to call when flickering ends
@@ -6175,7 +6999,7 @@ export class Sprite extends Renderable {
6175
6999
  * logic as per the following example :<br>
6176
7000
  * <img src="images/spritesheet_grid.png"/>
6177
7001
  * @name addAnimation
6178
- * @memberof Sprite.prototype
7002
+ * @memberof Sprite
6179
7003
  * @function
6180
7004
  * @param {string} name animation id
6181
7005
  * @param {number[]|string[]|object[]} index list of sprite index or name
@@ -6208,7 +7032,7 @@ export class Sprite extends Renderable {
6208
7032
  * set the current animation
6209
7033
  * this will always change the animation & set the frame to zero
6210
7034
  * @name setCurrentAnimation
6211
- * @memberof Sprite.prototype
7035
+ * @memberof Sprite
6212
7036
  * @function
6213
7037
  * @param {string} name animation id
6214
7038
  * @param {string|Function} [resetAnim] animation id to switch to when complete, or callback
@@ -6248,7 +7072,7 @@ export class Sprite extends Renderable {
6248
7072
  /**
6249
7073
  * reverse the given or current animation if none is specified
6250
7074
  * @name reverseAnimation
6251
- * @memberof Sprite.prototype
7075
+ * @memberof Sprite
6252
7076
  * @function
6253
7077
  * @param {string} [name] animation id
6254
7078
  * @returns {Sprite} Reference to this object for method chaining
@@ -6258,7 +7082,7 @@ export class Sprite extends Renderable {
6258
7082
  /**
6259
7083
  * return true if the specified animation is the current one.
6260
7084
  * @name isCurrentAnimation
6261
- * @memberof Sprite.prototype
7085
+ * @memberof Sprite
6262
7086
  * @function
6263
7087
  * @param {string} name animation id
6264
7088
  * @returns {boolean}
@@ -6272,7 +7096,7 @@ export class Sprite extends Renderable {
6272
7096
  * change the current texture atlas region for this sprite
6273
7097
  * @see Texture.getRegion
6274
7098
  * @name setRegion
6275
- * @memberof Sprite.prototype
7099
+ * @memberof Sprite
6276
7100
  * @function
6277
7101
  * @param {object} region typically returned through me.Texture.getRegion()
6278
7102
  * @returns {Sprite} Reference to this object for method chaining
@@ -6284,7 +7108,7 @@ export class Sprite extends Renderable {
6284
7108
  /**
6285
7109
  * force the current animation frame index.
6286
7110
  * @name setAnimationFrame
6287
- * @memberof Sprite.prototype
7111
+ * @memberof Sprite
6288
7112
  * @function
6289
7113
  * @param {number} [idx=0] animation frame index
6290
7114
  * @returns {Sprite} Reference to this object for method chaining
@@ -6296,7 +7120,7 @@ export class Sprite extends Renderable {
6296
7120
  /**
6297
7121
  * return the current animation frame index.
6298
7122
  * @name getCurrentAnimationFrame
6299
- * @memberof Sprite.prototype
7123
+ * @memberof Sprite
6300
7124
  * @function
6301
7125
  * @returns {number} current animation frame index
6302
7126
  */
@@ -6304,7 +7128,7 @@ export class Sprite extends Renderable {
6304
7128
  /**
6305
7129
  * Returns the frame object by the index.
6306
7130
  * @name getAnimationFrameObjectByIndex
6307
- * @memberof Sprite.prototype
7131
+ * @memberof Sprite
6308
7132
  * @function
6309
7133
  * @ignore
6310
7134
  * @param {number} id the frame id
@@ -6341,11 +7165,43 @@ export class Stage {
6341
7165
  * Cameras will be renderered based on this order defined in this list.
6342
7166
  * Only the "default" camera will be resized when the window or canvas is resized.
6343
7167
  * @public
6344
- * @type {Map}
7168
+ * @type {Map<Camera2d>}
6345
7169
  * @name cameras
6346
7170
  * @memberof Stage
6347
7171
  */
6348
- public cameras: Map<any, any>;
7172
+ public cameras: Map<Camera2d, any>;
7173
+ /**
7174
+ * The list of active lights in this stage.
7175
+ * (Note: Canvas Renderering mode will only properly support one light per stage)
7176
+ * @public
7177
+ * @type {Map<Light2d>}
7178
+ * @name lights
7179
+ * @memberof Stage
7180
+ * @see Light2d
7181
+ * @see Stage.ambientLight
7182
+ * @example
7183
+ * // create a white spot light
7184
+ * var whiteLight = new me.Light2d(0, 0, 140, "#fff", 0.7);
7185
+ * // and add the light to this current stage
7186
+ * this.lights.set("whiteLight", whiteLight);
7187
+ * // set a dark ambient light
7188
+ * this.ambientLight.parseCSS("#1117");
7189
+ * // make the light follow the mouse
7190
+ * me.input.registerPointerEvent("pointermove", me.game.viewport, (event) => {
7191
+ * whiteLight.centerOn(event.gameX, event.gameY);
7192
+ * });
7193
+ */
7194
+ public lights: Map<Light2d, any>;
7195
+ /**
7196
+ * an ambient light that will be added to the stage rendering
7197
+ * @public
7198
+ * @type {Color}
7199
+ * @name ambientLight
7200
+ * @memberof Stage
7201
+ * @default "#000000"
7202
+ * @see Light2d
7203
+ */
7204
+ public ambientLight: Color;
6349
7205
  /**
6350
7206
  * The given constructor options
6351
7207
  * @public
@@ -6582,6 +7438,8 @@ export class TMXLayer extends Renderable {
6582
7438
  name: any;
6583
7439
  cols: number;
6584
7440
  rows: number;
7441
+ width: number;
7442
+ height: number;
6585
7443
  preRender: boolean;
6586
7444
  onActivateEvent(): void;
6587
7445
  canvasRenderer: CanvasRenderer;
@@ -7231,8 +8089,7 @@ export class Text extends Renderable {
7231
8089
  * @default 10
7232
8090
  */
7233
8091
  public fontSize: number;
7234
- canvas: HTMLCanvasElement | OffscreenCanvas;
7235
- context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
8092
+ canvasTexture: any;
7236
8093
  metrics: TextMetrics;
7237
8094
  /** @ignore */
7238
8095
  onDeactivateEvent(): void;
@@ -7258,6 +8115,7 @@ export class Text extends Renderable {
7258
8115
  * font.setFont("Arial", "1.5em");
7259
8116
  */
7260
8117
  setFont(font: string, size?: number | string): Text;
8118
+ height: number;
7261
8119
  /**
7262
8120
  * change the text to be displayed
7263
8121
  * @param {number|string|string[]} value a string, or an array of strings
@@ -8795,7 +9653,7 @@ export class WebGLRenderer extends Renderer {
8795
9653
  /**
8796
9654
  * The WebGL version used by this renderer (1 or 2)
8797
9655
  * @name WebGLVersion
8798
- * @memberof WebGLRenderer
9656
+ * @memberof WebGLRenderer#
8799
9657
  * @type {number}
8800
9658
  * @default 1
8801
9659
  * @readonly
@@ -8804,7 +9662,7 @@ export class WebGLRenderer extends Renderer {
8804
9662
  /**
8805
9663
  * The vendor string of the underlying graphics driver.
8806
9664
  * @name GPUVendor
8807
- * @memberof WebGLRenderer
9665
+ * @memberof WebGLRenderer#
8808
9666
  * @type {string}
8809
9667
  * @default null
8810
9668
  * @readonly
@@ -8813,7 +9671,7 @@ export class WebGLRenderer extends Renderer {
8813
9671
  /**
8814
9672
  * The renderer string of the underlying graphics driver.
8815
9673
  * @name GPURenderer
8816
- * @memberof WebGLRenderer
9674
+ * @memberof WebGLRenderer#
8817
9675
  * @type {string}
8818
9676
  * @default null
8819
9677
  * @readonly
@@ -8823,14 +9681,14 @@ export class WebGLRenderer extends Renderer {
8823
9681
  * The WebGL context
8824
9682
  * @name gl
8825
9683
  * @memberof WebGLRenderer
8826
- * type {WebGLRenderingContext}
9684
+ * @type {WebGLRenderingContext}
8827
9685
  */
8828
9686
  context: WebGLRenderingContext;
8829
9687
  gl: WebGLRenderingContext;
8830
9688
  /**
8831
9689
  * Maximum number of texture unit supported under the current context
8832
9690
  * @name maxTextures
8833
- * @memberof WebGLRenderer
9691
+ * @memberof WebGLRenderer#
8834
9692
  * @type {number}
8835
9693
  * @readonly
8836
9694
  */
@@ -8851,10 +9709,6 @@ export class WebGLRenderer extends Renderer {
8851
9709
  * @ignore
8852
9710
  */
8853
9711
  _blendStack: any[];
8854
- /**
8855
- * @ignore
8856
- */
8857
- _glPoints: Vector2d[];
8858
9712
  /**
8859
9713
  * The current transformation matrix used for transformations on the overall scene
8860
9714
  * @name currentTransform
@@ -8872,24 +9726,24 @@ export class WebGLRenderer extends Renderer {
8872
9726
  /**
8873
9727
  * The list of active compositors
8874
9728
  * @name compositors
8875
- * @type {Map}
9729
+ * @type {Map<WebGLCompositor>}
8876
9730
  * @memberof WebGLRenderer#
8877
9731
  */
8878
- compositors: Map<any, any>;
9732
+ compositors: Map<WebGLCompositor, any>;
8879
9733
  cache: TextureCache;
8880
9734
  /**
8881
9735
  * set the active compositor for this renderer
8882
9736
  * @name setCompositor
8883
9737
  * @function
8884
9738
  * @param {WebGLCompositor|string} compositor a compositor name or instance
8885
- * @memberof WebGLRenderer.prototype
9739
+ * @memberof WebGLRenderer
8886
9740
  * @function
8887
9741
  */
8888
9742
  setCompositor(compositor?: WebGLCompositor | string): void;
8889
9743
  /**
8890
9744
  * Reset the gl transform to identity
8891
9745
  * @name resetTransform
8892
- * @memberof WebGLRenderer.prototype
9746
+ * @memberof WebGLRenderer
8893
9747
  * @function
8894
9748
  */
8895
9749
  resetTransform(): void;
@@ -8908,7 +9762,7 @@ export class WebGLRenderer extends Renderer {
8908
9762
  /**
8909
9763
  * Create a pattern with the specified repetition
8910
9764
  * @name createPattern
8911
- * @memberof WebGLRenderer.prototype
9765
+ * @memberof WebGLRenderer
8912
9766
  * @function
8913
9767
  * @param {Image} image Source image
8914
9768
  * @param {string} repeat Define how the pattern should be repeated
@@ -8924,14 +9778,14 @@ export class WebGLRenderer extends Renderer {
8924
9778
  /**
8925
9779
  * Flush the compositor to the frame buffer
8926
9780
  * @name flush
8927
- * @memberof WebGLRenderer.prototype
9781
+ * @memberof WebGLRenderer
8928
9782
  * @function
8929
9783
  */
8930
9784
  flush(): void;
8931
9785
  /**
8932
9786
  * Clears the gl context with the given color.
8933
9787
  * @name clearColor
8934
- * @memberof WebGLRenderer.prototype
9788
+ * @memberof WebGLRenderer
8935
9789
  * @function
8936
9790
  * @param {Color|string} [color="#000000"] CSS color.
8937
9791
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
@@ -8940,7 +9794,7 @@ export class WebGLRenderer extends Renderer {
8940
9794
  /**
8941
9795
  * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
8942
9796
  * @name clearRect
8943
- * @memberof WebGLRenderer.prototype
9797
+ * @memberof WebGLRenderer
8944
9798
  * @function
8945
9799
  * @param {number} x x axis of the coordinate for the rectangle starting point.
8946
9800
  * @param {number} y y axis of the coordinate for the rectangle starting point.
@@ -8955,7 +9809,7 @@ export class WebGLRenderer extends Renderer {
8955
9809
  /**
8956
9810
  * Draw an image to the gl context
8957
9811
  * @name drawImage
8958
- * @memberof WebGLRenderer.prototype
9812
+ * @memberof WebGLRenderer
8959
9813
  * @function
8960
9814
  * @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
8961
9815
  * @param {number} sx The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
@@ -8978,7 +9832,7 @@ export class WebGLRenderer extends Renderer {
8978
9832
  /**
8979
9833
  * Draw a pattern within the given rectangle.
8980
9834
  * @name drawPattern
8981
- * @memberof WebGLRenderer.prototype
9835
+ * @memberof WebGLRenderer
8982
9836
  * @function
8983
9837
  * @param {TextureAtlas} pattern Pattern object
8984
9838
  * @param {number} x
@@ -8991,7 +9845,7 @@ export class WebGLRenderer extends Renderer {
8991
9845
  /**
8992
9846
  * return a reference to the screen canvas corresponding WebGL Context
8993
9847
  * @name getScreenContext
8994
- * @memberof WebGLRenderer.prototype
9848
+ * @memberof WebGLRenderer
8995
9849
  * @function
8996
9850
  * @returns {WebGLRenderingContext}
8997
9851
  */
@@ -8999,7 +9853,7 @@ export class WebGLRenderer extends Renderer {
8999
9853
  /**
9000
9854
  * Returns the WebGL Context object of the given Canvas
9001
9855
  * @name getContextGL
9002
- * @memberof WebGLRenderer.prototype
9856
+ * @memberof WebGLRenderer
9003
9857
  * @function
9004
9858
  * @param {HTMLCanvasElement} canvas
9005
9859
  * @param {boolean} [transparent=true] use false to disable transparency
@@ -9010,7 +9864,7 @@ export class WebGLRenderer extends Renderer {
9010
9864
  * Returns the WebGLContext instance for the renderer
9011
9865
  * return a reference to the system 2d Context
9012
9866
  * @name getContext
9013
- * @memberof WebGLRenderer.prototype
9867
+ * @memberof WebGLRenderer
9014
9868
  * @function
9015
9869
  * @returns {WebGLRenderingContext}
9016
9870
  */
@@ -9028,7 +9882,7 @@ export class WebGLRenderer extends Renderer {
9028
9882
  * <img src="images/screen-blendmode.png" width="510"/> <br>
9029
9883
  * @name setBlendMode
9030
9884
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
9031
- * @memberof WebGLRenderer.prototype
9885
+ * @memberof WebGLRenderer
9032
9886
  * @function
9033
9887
  * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
9034
9888
  * @param {WebGLRenderingContext} [gl]
@@ -9043,21 +9897,21 @@ export class WebGLRenderer extends Renderer {
9043
9897
  /**
9044
9898
  * restores the canvas context
9045
9899
  * @name restore
9046
- * @memberof WebGLRenderer.prototype
9900
+ * @memberof WebGLRenderer
9047
9901
  * @function
9048
9902
  */
9049
9903
  restore(): void;
9050
9904
  /**
9051
9905
  * saves the canvas context
9052
9906
  * @name save
9053
- * @memberof WebGLRenderer.prototype
9907
+ * @memberof WebGLRenderer
9054
9908
  * @function
9055
9909
  */
9056
9910
  save(): void;
9057
9911
  /**
9058
9912
  * rotates the uniform matrix
9059
9913
  * @name rotate
9060
- * @memberof WebGLRenderer.prototype
9914
+ * @memberof WebGLRenderer
9061
9915
  * @function
9062
9916
  * @param {number} angle in radians
9063
9917
  */
@@ -9065,7 +9919,7 @@ export class WebGLRenderer extends Renderer {
9065
9919
  /**
9066
9920
  * scales the uniform matrix
9067
9921
  * @name scale
9068
- * @memberof WebGLRenderer.prototype
9922
+ * @memberof WebGLRenderer
9069
9923
  * @function
9070
9924
  * @param {number} x
9071
9925
  * @param {number} y
@@ -9079,16 +9933,24 @@ export class WebGLRenderer extends Renderer {
9079
9933
  /**
9080
9934
  * Set the global alpha
9081
9935
  * @name setGlobalAlpha
9082
- * @memberof WebGLRenderer.prototype
9936
+ * @memberof WebGLRenderer
9083
9937
  * @function
9084
9938
  * @param {number} alpha 0.0 to 1.0 values accepted.
9085
9939
  */
9086
9940
  setGlobalAlpha(alpha: number): void;
9941
+ /**
9942
+ * Return the global alpha
9943
+ * @name getGlobalAlpha
9944
+ * @memberof WebGLRenderer
9945
+ * @function
9946
+ * @returns {number} global alpha value
9947
+ */
9948
+ getGlobalAlpha(): number;
9087
9949
  /**
9088
9950
  * Set the current fill & stroke style color.
9089
9951
  * By default, or upon reset, the value is set to #000000.
9090
9952
  * @name setColor
9091
- * @memberof WebGLRenderer.prototype
9953
+ * @memberof WebGLRenderer
9092
9954
  * @function
9093
9955
  * @param {Color|string} color css color string.
9094
9956
  */
@@ -9096,7 +9958,7 @@ export class WebGLRenderer extends Renderer {
9096
9958
  /**
9097
9959
  * Set the line width
9098
9960
  * @name setLineWidth
9099
- * @memberof WebGLRenderer.prototype
9961
+ * @memberof WebGLRenderer
9100
9962
  * @function
9101
9963
  * @param {number} width Line width
9102
9964
  */
@@ -9104,7 +9966,7 @@ export class WebGLRenderer extends Renderer {
9104
9966
  /**
9105
9967
  * Stroke an arc at the specified coordinates with given radius, start and end points
9106
9968
  * @name strokeArc
9107
- * @memberof WebGLRenderer.prototype
9969
+ * @memberof WebGLRenderer
9108
9970
  * @function
9109
9971
  * @param {number} x arc center point x-axis
9110
9972
  * @param {number} y arc center point y-axis
@@ -9118,7 +9980,7 @@ export class WebGLRenderer extends Renderer {
9118
9980
  /**
9119
9981
  * Fill an arc at the specified coordinates with given radius, start and end points
9120
9982
  * @name fillArc
9121
- * @memberof WebGLRenderer.prototype
9983
+ * @memberof WebGLRenderer
9122
9984
  * @function
9123
9985
  * @param {number} x arc center point x-axis
9124
9986
  * @param {number} y arc center point y-axis
@@ -9127,11 +9989,11 @@ export class WebGLRenderer extends Renderer {
9127
9989
  * @param {number} end end angle in radians
9128
9990
  * @param {boolean} [antiClockwise=false] draw arc anti-clockwise
9129
9991
  */
9130
- fillArc(x: number, y: number, radius: number, start: number, end: number): void;
9992
+ fillArc(x: number, y: number, radius: number, start: number, end: number, antiClockwise?: boolean): void;
9131
9993
  /**
9132
9994
  * Stroke an ellipse at the specified coordinates with given radius
9133
9995
  * @name strokeEllipse
9134
- * @memberof WebGLRenderer.prototype
9996
+ * @memberof WebGLRenderer
9135
9997
  * @function
9136
9998
  * @param {number} x ellipse center point x-axis
9137
9999
  * @param {number} y ellipse center point y-axis
@@ -9143,7 +10005,7 @@ export class WebGLRenderer extends Renderer {
9143
10005
  /**
9144
10006
  * Fill an ellipse at the specified coordinates with given radius
9145
10007
  * @name fillEllipse
9146
- * @memberof WebGLRenderer.prototype
10008
+ * @memberof WebGLRenderer
9147
10009
  * @function
9148
10010
  * @param {number} x ellipse center point x-axis
9149
10011
  * @param {number} y ellipse center point y-axis
@@ -9154,7 +10016,7 @@ export class WebGLRenderer extends Renderer {
9154
10016
  /**
9155
10017
  * Stroke a line of the given two points
9156
10018
  * @name strokeLine
9157
- * @memberof WebGLRenderer.prototype
10019
+ * @memberof WebGLRenderer
9158
10020
  * @function
9159
10021
  * @param {number} startX the start x coordinate
9160
10022
  * @param {number} startY the start y coordinate
@@ -9165,7 +10027,7 @@ export class WebGLRenderer extends Renderer {
9165
10027
  /**
9166
10028
  * Fill a line of the given two points
9167
10029
  * @name fillLine
9168
- * @memberof WebGLRenderer.prototype
10030
+ * @memberof WebGLRenderer
9169
10031
  * @function
9170
10032
  * @param {number} startX the start x coordinate
9171
10033
  * @param {number} startY the start y coordinate
@@ -9176,7 +10038,7 @@ export class WebGLRenderer extends Renderer {
9176
10038
  /**
9177
10039
  * Stroke a me.Polygon on the screen with a specified color
9178
10040
  * @name strokePolygon
9179
- * @memberof WebGLRenderer.prototype
10041
+ * @memberof WebGLRenderer
9180
10042
  * @function
9181
10043
  * @param {Polygon} poly the shape to draw
9182
10044
  * @param {boolean} [fill=false] also fill the shape with the current color if true
@@ -9185,7 +10047,7 @@ export class WebGLRenderer extends Renderer {
9185
10047
  /**
9186
10048
  * Fill a me.Polygon on the screen
9187
10049
  * @name fillPolygon
9188
- * @memberof WebGLRenderer.prototype
10050
+ * @memberof WebGLRenderer
9189
10051
  * @function
9190
10052
  * @param {Polygon} poly the shape to draw
9191
10053
  */
@@ -9193,7 +10055,7 @@ export class WebGLRenderer extends Renderer {
9193
10055
  /**
9194
10056
  * Draw a stroke rectangle at the specified coordinates
9195
10057
  * @name strokeRect
9196
- * @memberof WebGLRenderer.prototype
10058
+ * @memberof WebGLRenderer
9197
10059
  * @function
9198
10060
  * @param {number} x
9199
10061
  * @param {number} y
@@ -9205,7 +10067,7 @@ export class WebGLRenderer extends Renderer {
9205
10067
  /**
9206
10068
  * Draw a filled rectangle at the specified coordinates
9207
10069
  * @name fillRect
9208
- * @memberof WebGLRenderer.prototype
10070
+ * @memberof WebGLRenderer
9209
10071
  * @function
9210
10072
  * @param {number} x
9211
10073
  * @param {number} y
@@ -9213,11 +10075,36 @@ export class WebGLRenderer extends Renderer {
9213
10075
  * @param {number} height
9214
10076
  */
9215
10077
  fillRect(x: number, y: number, width: number, height: number): void;
10078
+ /**
10079
+ * Stroke a rounded rectangle at the specified coordinates
10080
+ * @name strokeRoundRect
10081
+ * @memberof WebGLRenderer
10082
+ * @function
10083
+ * @param {number} x
10084
+ * @param {number} y
10085
+ * @param {number} width
10086
+ * @param {number} height
10087
+ * @param {number} radius
10088
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
10089
+ */
10090
+ strokeRoundRect(x: number, y: number, width: number, height: number, radius: number, fill?: boolean): void;
10091
+ /**
10092
+ * Draw a rounded filled rectangle at the specified coordinates
10093
+ * @name fillRoundRect
10094
+ * @memberof WebGLRenderer
10095
+ * @function
10096
+ * @param {number} x
10097
+ * @param {number} y
10098
+ * @param {number} width
10099
+ * @param {number} height
10100
+ * @param {number} radius
10101
+ */
10102
+ fillRoundRect(x: number, y: number, width: number, height: number, radius: number): void;
9216
10103
  /**
9217
10104
  * Reset (overrides) the renderer transformation matrix to the
9218
10105
  * identity one, and then apply the given transformation matrix.
9219
10106
  * @name setTransform
9220
- * @memberof WebGLRenderer.prototype
10107
+ * @memberof WebGLRenderer
9221
10108
  * @function
9222
10109
  * @param {Matrix2d} mat2d Matrix to transform by
9223
10110
  */
@@ -9225,7 +10112,7 @@ export class WebGLRenderer extends Renderer {
9225
10112
  /**
9226
10113
  * Multiply given matrix into the renderer tranformation matrix
9227
10114
  * @name transform
9228
- * @memberof WebGLRenderer.prototype
10115
+ * @memberof WebGLRenderer
9229
10116
  * @function
9230
10117
  * @param {Matrix2d} mat2d Matrix to transform by
9231
10118
  */
@@ -9233,7 +10120,7 @@ export class WebGLRenderer extends Renderer {
9233
10120
  /**
9234
10121
  * Translates the uniform matrix by the given coordinates
9235
10122
  * @name translate
9236
- * @memberof WebGLRenderer.prototype
10123
+ * @memberof WebGLRenderer
9237
10124
  * @function
9238
10125
  * @param {number} x
9239
10126
  * @param {number} y
@@ -9246,7 +10133,7 @@ export class WebGLRenderer extends Renderer {
9246
10133
  * and restore it (with the restore() method) any time in the future.
9247
10134
  * (<u>this is an experimental feature !</u>)
9248
10135
  * @name clipRect
9249
- * @memberof WebGLRenderer.prototype
10136
+ * @memberof WebGLRenderer
9250
10137
  * @function
9251
10138
  * @param {number} x
9252
10139
  * @param {number} y
@@ -9254,6 +10141,17 @@ export class WebGLRenderer extends Renderer {
9254
10141
  * @param {number} height
9255
10142
  */
9256
10143
  clipRect(x: number, y: number, width: number, height: number): void;
10144
+ /**
10145
+ * A mask limits rendering elements to the shape and position of the given mask object.
10146
+ * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
10147
+ * Mask are not preserved through renderer context save and restore.
10148
+ * @name setMask
10149
+ * @memberof WebGLRenderer
10150
+ * @function
10151
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
10152
+ * @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
10153
+ */
10154
+ setMask(mask?: Rect | RoundRect | Polygon | Line | Ellipse, invert?: boolean): void;
9257
10155
  }
9258
10156
  /**
9259
10157
  * @classdesc
@@ -9306,9 +10204,9 @@ export class World extends Container {
9306
10204
  * @name bodies
9307
10205
  * @memberof World
9308
10206
  * @public
9309
- * @type {Set}
10207
+ * @type {Set<Body>}
9310
10208
  */
9311
- public bodies: Set<any>;
10209
+ public bodies: Set<Body>;
9312
10210
  /**
9313
10211
  * the instance of the game world quadtree used for broadphase
9314
10212
  * @name broadphase
@@ -9340,7 +10238,7 @@ export class World extends Container {
9340
10238
  }
9341
10239
  export var audio: Readonly<{
9342
10240
  __proto__: any;
9343
- stopOnAudioError: boolean;
10241
+ stopOnAudioError: true;
9344
10242
  init: typeof init$1;
9345
10243
  hasFormat: typeof hasFormat;
9346
10244
  hasAudio: typeof hasAudio;
@@ -9386,8 +10284,26 @@ export function boot(): void;
9386
10284
  */
9387
10285
  export var collision: any;
9388
10286
  declare namespace device$1 {
9389
- namespace turnOnPointerLock { }
9390
- namespace turnOffPointerLock { }
10287
+ /**
10288
+ * @public
10289
+ * @name turnOnPointerLock
10290
+ * @function
10291
+ * @returns {boolean} return true if the request was successfully submitted
10292
+ * @memberof device#
10293
+ * @deprecated since 10.3.0
10294
+ * @see input.requestPointerLock
10295
+ */
10296
+ function turnOnPointerLock(): boolean;
10297
+ /**
10298
+ * @public
10299
+ * @name turnOffPointerLock
10300
+ * @function
10301
+ * @returns {boolean} return true if the request was successfully submitted
10302
+ * @memberof device#
10303
+ * @deprecated since 10.3.0
10304
+ * @see input.exitPointerLock
10305
+ */
10306
+ function turnOffPointerLock(): boolean;
9391
10307
  }
9392
10308
  declare var event$1: Readonly<{
9393
10309
  __proto__: any;
@@ -9433,7 +10349,7 @@ export var game: Readonly<{
9433
10349
  __proto__: any;
9434
10350
  readonly viewport: Camera2d;
9435
10351
  readonly world: World;
9436
- mergeGroup: boolean;
10352
+ mergeGroup: true;
9437
10353
  sortOn: string;
9438
10354
  readonly lastUpdate: number;
9439
10355
  onLevelLoaded: typeof onLevelLoaded;
@@ -9453,7 +10369,7 @@ export var game: Readonly<{
9453
10369
  export var initialized: boolean;
9454
10370
  export var input: Readonly<{
9455
10371
  __proto__: any;
9456
- preventDefault: boolean;
10372
+ preventDefault: true;
9457
10373
  readonly pointerEventTarget: EventTarget;
9458
10374
  pointer: Rect;
9459
10375
  readonly locked: boolean;
@@ -10396,16 +11312,12 @@ export var plugin: any;
10396
11312
  * @namespace plugins
10397
11313
  */
10398
11314
  export var plugins: {};
10399
- declare var pooling: Readonly<{
10400
- __proto__: any;
10401
- register: typeof register;
10402
- pull: typeof pull;
10403
- purge: typeof purge;
10404
- push: typeof push;
10405
- exists: typeof exists;
10406
- poolable: typeof poolable;
10407
- getInstanceCount: typeof getInstanceCount;
10408
- }>;
11315
+ /**
11316
+ * a default global object pool instance
11317
+ * @public
11318
+ * @type {ObjectPool}
11319
+ */
11320
+ declare var pool$1: ObjectPool;
10409
11321
  export namespace save {
10410
11322
  /**
10411
11323
  * Add new keys to localStorage and set them to the given default values if they do not exist
@@ -10984,9 +11896,9 @@ export namespace utils {
10984
11896
  export const version: string;
10985
11897
  export var video: Readonly<{
10986
11898
  __proto__: any;
10987
- CANVAS: number;
10988
- WEBGL: number;
10989
- AUTO: number;
11899
+ CANVAS: 0;
11900
+ WEBGL: 1;
11901
+ AUTO: 2;
10990
11902
  readonly parent: HTMLElement;
10991
11903
  scaleRatio: Vector2d;
10992
11904
  readonly renderer: CanvasRenderer | WebGLRenderer;
@@ -11060,6 +11972,7 @@ declare class Bounds {
11060
11972
  * @param {Vector2d[]} [vertices] an array of me.Vector2d points
11061
11973
  */
11062
11974
  constructor(vertices?: Vector2d[]);
11975
+ _center: Vector2d;
11063
11976
  /**
11064
11977
  * @ignore
11065
11978
  */
@@ -11072,7 +11985,6 @@ declare class Bounds {
11072
11985
  x: number;
11073
11986
  y: number;
11074
11987
  };
11075
- _center: Vector2d;
11076
11988
  /**
11077
11989
  * reset the bound
11078
11990
  * @name clear
@@ -12207,6 +13119,7 @@ declare function setGamepadDeadzone(value: number): void;
12207
13119
  */
12208
13120
  declare function addMapping(id: any, mapping: any): void;
12209
13121
  /**
13122
+ * @classdesc
12210
13123
  * This object is used for object pooling - a technique that might speed up your game if used properly.<br>
12211
13124
  * If some of your classes will be instantiated and removed a lot at a time, it is a
12212
13125
  * good idea to add the class to this object pool. A separate pool for that class
@@ -12217,96 +13130,93 @@ declare function addMapping(id: any, mapping: any): void;
12217
13130
  * which means, that on level loading the engine will try to instantiate every object
12218
13131
  * found in the map, based on the user defined name in each Object Properties<br>
12219
13132
  * <img src="images/object_properties.png"/><br>
12220
- * @namespace pool
12221
- */
12222
- /**
12223
- * register an object to the pool. <br>
12224
- * Pooling must be set to true if more than one such objects will be created. <br>
12225
- * (Note: for an object to be poolable, it must implements a `onResetEvent` method)
12226
- * @function pool.register
12227
- * @param {string} className as defined in the Name field of the Object Properties (in Tiled)
12228
- * @param {object} classObj corresponding Class to be instantiated
12229
- * @param {boolean} [recycling=false] enables object recycling for the specified class
12230
- * @example
12231
- * // implement CherryEntity
12232
- * class CherryEntity extends Spritesheet {
12233
- * onResetEvent() {
12234
- * // reset object mutable properties
12235
- * this.lifeBar = 100;
12236
- * }
12237
- * };
12238
- * // add our users defined entities in the object pool and enable object recycling
12239
- * me.pool.register("cherryentity", CherryEntity, true);
12240
- */
12241
- declare function register(className: string, classObj: object, recycling?: boolean): void;
12242
- /**
12243
- * Pull a new instance of the requested object (if added into the object pool)
12244
- * @function pool.pull
12245
- * @param {string} name as used in {@link pool.register}
12246
- * @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
12247
- * @returns {object} the instance of the requested object
12248
- * @example
12249
- * me.pool.register("bullet", BulletEntity, true);
12250
- * me.pool.register("enemy", EnemyEntity, true);
12251
- * // ...
12252
- * // when we need to manually create a new bullet:
12253
- * var bullet = me.pool.pull("bullet", x, y, direction);
12254
- * // ...
12255
- * // params aren't a fixed number
12256
- * // when we need new enemy we can add more params, that the object construct requires:
12257
- * var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
12258
- * // ...
12259
- * // when we want to destroy existing object, the remove
12260
- * // function will ensure the object can then be reallocated later
12261
- * me.game.world.removeChild(enemy);
12262
- * me.game.world.removeChild(bullet);
12263
- */
12264
- declare function pull(name: string, ...args: any[]): object;
12265
- /**
12266
- * purge the object pool from any inactive object <br>
12267
- * Object pooling must be enabled for this function to work<br>
12268
- * note: this will trigger the garbage collector
12269
- * @function pool.purge
12270
- */
12271
- declare function purge(): void;
12272
- /**
12273
- * Push back an object instance into the object pool <br>
12274
- * Object pooling for the object class must be enabled,
12275
- * and object must have been instantiated using {@link pool#pull},
12276
- * otherwise this function won't work
12277
- * @function pool.push
12278
- * @throws will throw an error if the object cannot be recycled
12279
- * @param {object} obj instance to be recycled
12280
- * @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
12281
- * @returns {boolean} true if the object was successfully recycled in the object pool
12282
- */
12283
- declare function push(obj: object, throwOnError?: boolean): boolean;
12284
- /**
12285
- * Check if an object with the provided name is registered
12286
- * @function pool.exists
12287
- * @param {string} name of the registered object class
12288
- * @returns {boolean} true if the classname is registered
12289
- */
12290
- declare function exists(name: string): boolean;
12291
- /**
12292
- * Check if an object is poolable
12293
- * (was properly registered with the recycling feature enable)
12294
- * @function pool.poolable
12295
- * @see pool.register
12296
- * @param {object} obj object to be checked
12297
- * @returns {boolean} true if the object is poolable
12298
- * @example
12299
- * if (!me.pool.poolable(myCherryEntity)) {
12300
- * // object was not properly registered
12301
- * }
12302
- */
12303
- declare function poolable(obj: object): boolean;
12304
- /**
12305
- * returns the amount of object instance currently in the pool
12306
- * @function pool.getInstanceCount
12307
- * @returns {number} amount of object instance
12308
- */
12309
- declare function getInstanceCount(): number;
13133
+ * @see {@link pool} a default global instance of ObjectPool
13134
+ */
13135
+ declare class ObjectPool {
13136
+ objectClass: {};
13137
+ instance_counter: number;
13138
+ /**
13139
+ * register an object to the pool. <br>
13140
+ * Pooling must be set to true if more than one such objects will be created. <br>
13141
+ * (Note: for an object to be poolable, it must implements a `onResetEvent` method)
13142
+ * @param {string} className as defined in the Name field of the Object Properties (in Tiled)
13143
+ * @param {object} classObj corresponding Class to be instantiated
13144
+ * @param {boolean} [recycling=false] enables object recycling for the specified class
13145
+ * @example
13146
+ * // implement CherryEntity
13147
+ * class CherryEntity extends Spritesheet {
13148
+ * onResetEvent() {
13149
+ * // reset object mutable properties
13150
+ * this.lifeBar = 100;
13151
+ * }
13152
+ * };
13153
+ * // add our users defined entities in the object pool and enable object recycling
13154
+ * me.pool.register("cherryentity", CherryEntity, true);
13155
+ */
13156
+ register(className: string, classObj: object, recycling?: boolean): void;
13157
+ /**
13158
+ * Pull a new instance of the requested object (if added into the object pool)
13159
+ * @param {string} name as used in {@link pool.register}
13160
+ * @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
13161
+ * @returns {object} the instance of the requested object
13162
+ * @example
13163
+ * me.pool.register("bullet", BulletEntity, true);
13164
+ * me.pool.register("enemy", EnemyEntity, true);
13165
+ * // ...
13166
+ * // when we need to manually create a new bullet:
13167
+ * var bullet = me.pool.pull("bullet", x, y, direction);
13168
+ * // ...
13169
+ * // params aren't a fixed number
13170
+ * // when we need new enemy we can add more params, that the object construct requires:
13171
+ * var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
13172
+ * // ...
13173
+ * // when we want to destroy existing object, the remove
13174
+ * // function will ensure the object can then be reallocated later
13175
+ * me.game.world.removeChild(enemy);
13176
+ * me.game.world.removeChild(bullet);
13177
+ */
13178
+ pull(name: string, ...args: any[]): object;
13179
+ /**
13180
+ * purge the object pool from any inactive object <br>
13181
+ * Object pooling must be enabled for this function to work<br>
13182
+ * note: this will trigger the garbage collector
13183
+ */
13184
+ purge(): void;
13185
+ /**
13186
+ * Push back an object instance into the object pool <br>
13187
+ * Object pooling for the object class must be enabled,
13188
+ * and object must have been instantiated using {@link pool#pull},
13189
+ * otherwise this function won't work
13190
+ * @throws will throw an error if the object cannot be recycled
13191
+ * @param {object} obj instance to be recycled
13192
+ * @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
13193
+ * @returns {boolean} true if the object was successfully recycled in the object pool
13194
+ */
13195
+ push(obj: object, throwOnError?: boolean): boolean;
13196
+ /**
13197
+ * Check if an object with the provided name is registered
13198
+ * @param {string} name of the registered object class
13199
+ * @returns {boolean} true if the classname is registered
13200
+ */
13201
+ exists(name: string): boolean;
13202
+ /**
13203
+ * Check if an object is poolable
13204
+ * (was properly registered with the recycling feature enable)
13205
+ * @see register
13206
+ * @param {object} obj object to be checked
13207
+ * @returns {boolean} true if the object is poolable
13208
+ * @example
13209
+ * if (!me.pool.poolable(myCherryEntity)) {
13210
+ * // object was not properly registered
13211
+ * }
13212
+ */
13213
+ poolable(obj: object): boolean;
13214
+ /**
13215
+ * returns the amount of object instance currently in the pool
13216
+ * @returns {number} amount of object instance
13217
+ */
13218
+ getInstanceCount(): number;
13219
+ }
12310
13220
  declare var agentUtils: Readonly<{
12311
13221
  __proto__: any;
12312
13222
  prefixed: typeof prefixed;
@@ -12599,4 +13509,4 @@ declare function defer(func: Function, thisArg: object, ...args: any[]): number;
12599
13509
  * @returns {Function} the function that will be throttled
12600
13510
  */
12601
13511
  declare function throttle(fn: Function, delay: number, no_trailing: any): Function;
12602
- export { Bounds$1 as Bounds, math as Math, device$1 as device, event$1 as event, pooling as pool, timer$1 as timer };
13512
+ export { Bounds$1 as Bounds, math as Math, Rect$1 as Rect, device$1 as device, event$1 as event, pool$1 as pool, timer$1 as timer };