melonjs 10.6.1 → 10.8.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 (79) hide show
  1. package/dist/melonjs.js +37947 -36530
  2. package/dist/melonjs.min.js +22 -22
  3. package/dist/melonjs.module.d.ts +1352 -307
  4. package/dist/melonjs.module.js +2929 -1501
  5. package/package.json +14 -12
  6. package/src/camera/camera2d.js +1 -1
  7. package/src/entity/entity.js +6 -7
  8. package/src/game.js +5 -5
  9. package/src/geometries/ellipse.js +10 -11
  10. package/src/geometries/line.js +3 -3
  11. package/src/geometries/path2d.js +319 -0
  12. package/src/geometries/poly.js +11 -11
  13. package/src/geometries/rectangle.js +30 -15
  14. package/src/geometries/roundrect.js +67 -0
  15. package/src/index.js +9 -5
  16. package/src/input/gamepad.js +12 -10
  17. package/src/input/keyboard.js +5 -3
  18. package/src/input/pointer.js +1 -1
  19. package/src/input/pointerevent.js +3 -4
  20. package/src/lang/deprecated.js +1 -1
  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 +5 -5
  31. package/src/loader/loadingscreen.js +1 -1
  32. package/src/math/color.js +1 -1
  33. package/src/math/matrix2.js +1 -1
  34. package/src/math/matrix3.js +67 -66
  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 +130 -430
  40. package/src/particles/particle.js +53 -53
  41. package/src/particles/settings.js +310 -0
  42. package/src/physics/body.js +67 -51
  43. package/src/physics/bounds.js +8 -9
  44. package/src/physics/world.js +1 -1
  45. package/src/polyfill/console.js +7 -7
  46. package/src/polyfill/index.js +7 -0
  47. package/src/polyfill/performance.js +20 -0
  48. package/src/polyfill/requestAnimationFrame.js +10 -10
  49. package/src/renderable/collectable.js +9 -2
  50. package/src/renderable/colorlayer.js +1 -1
  51. package/src/renderable/container.js +1 -1
  52. package/src/renderable/imagelayer.js +3 -3
  53. package/src/renderable/renderable.js +1 -1
  54. package/src/renderable/sprite.js +2 -3
  55. package/src/renderable/trigger.js +10 -4
  56. package/src/state/stage.js +1 -1
  57. package/src/state/state.js +8 -8
  58. package/src/system/device.js +148 -133
  59. package/src/system/event.js +10 -10
  60. package/src/system/pooling.js +156 -149
  61. package/src/system/timer.js +1 -1
  62. package/src/text/bitmaptext.js +1 -1
  63. package/src/text/text.js +1 -1
  64. package/src/utils/agent.js +4 -4
  65. package/src/utils/function.js +2 -2
  66. package/src/utils/utils.js +10 -5
  67. package/src/video/canvas/canvas_renderer.js +104 -36
  68. package/src/video/renderer.js +28 -16
  69. package/src/video/texture.js +1 -1
  70. package/src/video/video.js +11 -11
  71. package/src/video/webgl/glshader.js +30 -194
  72. package/src/video/webgl/utils/attributes.js +16 -0
  73. package/src/video/webgl/utils/precision.js +11 -0
  74. package/src/video/webgl/utils/program.js +58 -0
  75. package/src/video/webgl/utils/string.js +16 -0
  76. package/src/video/webgl/utils/uniforms.js +87 -0
  77. package/src/video/webgl/webgl_compositor.js +1 -14
  78. package/src/video/webgl/webgl_renderer.js +129 -186
  79. package/src/particles/particlecontainer.js +0 -95
@@ -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
@@ -1085,7 +1127,7 @@ export class CanvasRenderer extends Renderer {
1085
1127
  * <img src="images/normal-blendmode.png" width="510"/> <br>
1086
1128
  * - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
1087
1129
  * <img src="images/multiply-blendmode.png" width="510"/> <br>
1088
- * - "lighter" : where both content overlap the color is determined by adding color values. <br>
1130
+ * - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
1089
1131
  * <img src="images/lighter-blendmode.png" width="510"/> <br>
1090
1132
  * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
1091
1133
  * <img src="images/screen-blendmode.png" width="510"/> <br>
@@ -1093,7 +1135,7 @@ export class CanvasRenderer extends Renderer {
1093
1135
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
1094
1136
  * @memberof CanvasRenderer.prototype
1095
1137
  * @function
1096
- * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "screen"
1138
+ * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter, "additive", "screen"
1097
1139
  * @param {CanvasRenderingContext2D} [context]
1098
1140
  */
1099
1141
  setBlendMode(mode?: string, context?: CanvasRenderingContext2D): void;
@@ -1288,6 +1330,31 @@ 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.prototype
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.prototype
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
@@ -1342,13 +1409,21 @@ export class CanvasRenderer extends Renderer {
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
1414
  * @memberof CanvasRenderer.prototype
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.prototype
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
@@ -2246,7 +2321,7 @@ export class Ellipse {
2246
2321
  * @public
2247
2322
  * @type {Vector2d}
2248
2323
  * @name pos
2249
- * @memberof Ellipse#
2324
+ * @memberof Ellipse.prototype
2250
2325
  */
2251
2326
  public pos: Vector2d;
2252
2327
  /**
@@ -2259,7 +2334,7 @@ export class Ellipse {
2259
2334
  * @public
2260
2335
  * @type {number}
2261
2336
  * @name radius
2262
- * @memberof Ellipse
2337
+ * @memberof Ellipse.prototype
2263
2338
  */
2264
2339
  public radius: number;
2265
2340
  /**
@@ -2267,7 +2342,7 @@ export class Ellipse {
2267
2342
  * @public
2268
2343
  * @type {Vector2d}
2269
2344
  * @name radiusV
2270
- * @memberof Ellipse#
2345
+ * @memberof Ellipse.prototype
2271
2346
  */
2272
2347
  public radiusV: Vector2d;
2273
2348
  /**
@@ -2275,7 +2350,7 @@ export class Ellipse {
2275
2350
  * @public
2276
2351
  * @type {Vector2d}
2277
2352
  * @name radiusSq
2278
- * @memberof Ellipse#
2353
+ * @memberof Ellipse.prototype
2279
2354
  */
2280
2355
  public radiusSq: Vector2d;
2281
2356
  /**
@@ -2283,7 +2358,7 @@ export class Ellipse {
2283
2358
  * @public
2284
2359
  * @type {Vector2d}
2285
2360
  * @name ratio
2286
- * @memberof Ellipse#
2361
+ * @memberof Ellipse.prototype
2287
2362
  */
2288
2363
  public ratio: Vector2d;
2289
2364
  shapeType: string;
@@ -2610,6 +2685,16 @@ export class GLShader {
2610
2685
  * myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
2611
2686
  */
2612
2687
  setUniform(name: string, value: object | Float32Array): void;
2688
+ /**
2689
+ * activate the given vertex attribute for this shader
2690
+ * @name setVertexAttributes
2691
+ * @memberof GLShader
2692
+ * @function
2693
+ * @param {WebGLRenderingContext} gl the current WebGL rendering context
2694
+ * @param {object[]} attributes an array of vertex attributes
2695
+ * @param {number} vertexByteSize the size of a single vertex in bytes
2696
+ */
2697
+ setVertexAttributes(gl: WebGLRenderingContext, attributes: object[], vertexByteSize: number): void;
2613
2698
  /**
2614
2699
  * destroy this shader objects resources (program, attributes, uniforms)
2615
2700
  * @name destroy
@@ -4053,17 +4138,18 @@ export class ObservableVector3d extends Vector3d {
4053
4138
  /**
4054
4139
  * @classdesc
4055
4140
  * Single Particle Object.
4056
- * @class Particle
4057
4141
  * @augments Renderable
4058
- * @param {ParticleEmitter} particle emitter
4059
4142
  */
4060
4143
  export class Particle extends Renderable {
4144
+ /**
4145
+ * @param {ParticleEmitter} emitter the particle emitter
4146
+ */
4147
+ constructor(emitter: ParticleEmitter);
4061
4148
  /**
4062
4149
  * @ignore
4063
4150
  */
4064
- constructor(emitter: any);
4065
- vel: Vector2d;
4066
4151
  onResetEvent(emitter: any, newInstance?: boolean): void;
4152
+ vel: any;
4067
4153
  image: any;
4068
4154
  life: any;
4069
4155
  startLife: any;
@@ -4075,50 +4161,604 @@ export class Particle extends Renderable {
4075
4161
  onlyInViewport: any;
4076
4162
  _deltaInv: number;
4077
4163
  angle: number;
4078
- /**
4079
- * @ignore
4080
- */
4081
- preDraw(renderer: any): void;
4082
4164
  /**
4083
4165
  * @ignore
4084
4166
  */
4085
4167
  draw(renderer: any): void;
4086
4168
  }
4087
4169
  /**
4170
+ * @classdesc
4088
4171
  * Particle Emitter Object.
4089
- * @class
4090
- * @augments Rect
4091
- * @param {number} x x-position of the particle emitter
4092
- * @param {number} y y-position of the particle emitter
4093
- * @param {object} settings An object containing the settings for the particle emitter. See {@link ParticleEmitterSettings}
4094
- * @example
4095
- * // Create a basic emitter at position 100, 100
4096
- * var emitter = new me.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;
4103
- *
4104
- * // Add the emitter to the game world
4105
- * me.game.world.addChild(emitter);
4106
- *
4107
- * // Launch all particles one time and stop, like a explosion
4108
- * emitter.burstParticles();
4109
- *
4110
- * // Launch constantly the particles, like a fountain
4111
- * emitter.streamParticles();
4112
- *
4113
- * // At the end, remove emitter from the game world
4114
- * // call this in onDestroyEvent function
4115
- * me.game.world.removeChild(emitter);
4172
+ * @augments Container
4116
4173
  */
4117
- export class ParticleEmitter extends Rect {
4174
+ export class ParticleEmitter extends Container {
4118
4175
  /**
4119
- * @ignore
4176
+ * @param {number} x x position of the particle emitter
4177
+ * @param {number} y y position of the particle emitter
4178
+ * @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
4179
+ * @example
4180
+ * // Create a particle emitter at position 100, 100
4181
+ * var emitter = new ParticleEmitter(100, 100, {
4182
+ * width: 16,
4183
+ * height : 16,
4184
+ * tint: "#f00",
4185
+ * totalParticles: 32,
4186
+ * angle: 0,
4187
+ * angleVariation: 6.283185307179586,
4188
+ * maxLife: 5,
4189
+ * speed: 3
4190
+ * });
4191
+ *
4192
+ * // Add the emitter to the game world
4193
+ * me.game.world.addChild(emitter);
4194
+ *
4195
+ * // Launch all particles one time and stop, like a explosion
4196
+ * emitter.burstParticles();
4197
+ *
4198
+ * // Launch constantly the particles, like a fountain
4199
+ * emitter.streamParticles();
4200
+ *
4201
+ * // At the end, remove emitter from the game world
4202
+ * // call this in onDestroyEvent function
4203
+ * me.game.world.removeChild(emitter);
4120
4204
  */
4121
- constructor(x: any, y: any, settings: any);
4205
+ constructor(x: number, y: number, settings?: {
4206
+ /**
4207
+ * Width of the particle spawn area.
4208
+ * @type {number}
4209
+ * @name width
4210
+ * @memberof ParticleEmitterSettings
4211
+ * @default 1
4212
+ */
4213
+ width: number;
4214
+ /**
4215
+ * Height of the particle spawn area
4216
+ * @public
4217
+ * @type {number}
4218
+ * @name height
4219
+ * @memberof ParticleEmitterSettings
4220
+ * @default 1
4221
+ */
4222
+ height: number;
4223
+ /**
4224
+ * image used for particles texture
4225
+ * (by default melonJS will create an white 8x8 texture image)
4226
+ * @public
4227
+ * @type {HTMLCanvasElement}
4228
+ * @name image
4229
+ * @memberof ParticleEmitterSettings
4230
+ * @default undefined
4231
+ * @see ParticleEmitterSettings.textureSize
4232
+ */
4233
+ image: HTMLCanvasElement;
4234
+ /**
4235
+ * default texture size used for particles if no image is specified
4236
+ * (by default melonJS will create an white 8x8 texture image)
4237
+ * @public
4238
+ * @type {number}
4239
+ * @name textureSize
4240
+ * @memberof ParticleEmitterSettings
4241
+ * @default 8
4242
+ * @see ParticleEmitterSettings.image
4243
+ */
4244
+ textureSize: number;
4245
+ /**
4246
+ * tint to be applied to particles
4247
+ * @public
4248
+ * @type {string}
4249
+ * @name tint
4250
+ * @memberof ParticleEmitterSettings
4251
+ * @default "#fff"
4252
+ */
4253
+ tint: string;
4254
+ /**
4255
+ * Total number of particles in the emitter
4256
+ * @public
4257
+ * @type {number}
4258
+ * @name totalParticles
4259
+ * @default 50
4260
+ * @memberof ParticleEmitterSettings
4261
+ */
4262
+ totalParticles: number;
4263
+ /**
4264
+ * Start angle for particle launch in Radians
4265
+ * @public
4266
+ * @type {number}
4267
+ * @name angle
4268
+ * @default Math.PI / 2
4269
+ * @memberof ParticleEmitterSettings
4270
+ */
4271
+ angle: number;
4272
+ /**
4273
+ * Variation in the start angle for particle launch in Radians.
4274
+ * @public
4275
+ * @type {number}
4276
+ * @name angleVariation
4277
+ * @default 0
4278
+ * @memberof ParticleEmitterSettings
4279
+ */
4280
+ angleVariation: number;
4281
+ /**
4282
+ * Minimum time each particle lives once it is emitted in ms.
4283
+ * @public
4284
+ * @type {number}
4285
+ * @name minLife
4286
+ * @default 1000
4287
+ * @memberof ParticleEmitterSettings
4288
+ */
4289
+ minLife: number;
4290
+ /**
4291
+ * Maximum time each particle lives once it is emitted in ms.
4292
+ * @public
4293
+ * @type {number}
4294
+ * @name maxLife
4295
+ * @default 3000
4296
+ * @memberof ParticleEmitterSettings
4297
+ */
4298
+ maxLife: number;
4299
+ /**
4300
+ * Start speed of particles.<br>
4301
+ * @public
4302
+ * @type {number}
4303
+ * @name speed
4304
+ * @default 2
4305
+ * @memberof ParticleEmitterSettings
4306
+ */
4307
+ speed: number;
4308
+ /**
4309
+ * Variation in the start speed of particles
4310
+ * @public
4311
+ * @type {number}
4312
+ * @name speedVariation
4313
+ * @default 1
4314
+ * @memberof ParticleEmitterSettings
4315
+ */
4316
+ speedVariation: number;
4317
+ /**
4318
+ * Minimum start rotation for particles sprites in Radians
4319
+ * @public
4320
+ * @type {number}
4321
+ * @name minRotation
4322
+ * @default 0
4323
+ * @memberof ParticleEmitterSettings
4324
+ */
4325
+ minRotation: number;
4326
+ /**
4327
+ * Maximum start rotation for particles sprites in Radians
4328
+ * @public
4329
+ * @type {number}
4330
+ * @name maxRotation
4331
+ * @default 0
4332
+ * @memberof ParticleEmitterSettings
4333
+ */
4334
+ maxRotation: number;
4335
+ /**
4336
+ * Minimum start scale ratio for particles (1 = no scaling)
4337
+ * @public
4338
+ * @type {number}
4339
+ * @name minStartScale
4340
+ * @default 1
4341
+ * @memberof ParticleEmitterSettings
4342
+ */
4343
+ minStartScale: number;
4344
+ /**
4345
+ * Maximum start scale ratio for particles (1 = no scaling)
4346
+ * @public
4347
+ * @type {number}
4348
+ * @name maxStartScale
4349
+ * @default 1
4350
+ * @memberof ParticleEmitterSettings
4351
+ */
4352
+ maxStartScale: number;
4353
+ /**
4354
+ * Minimum end scale ratio for particles
4355
+ * @public
4356
+ * @type {number}
4357
+ * @name minEndScale
4358
+ * @default 0
4359
+ * @memberof ParticleEmitterSettings
4360
+ */
4361
+ minEndScale: number;
4362
+ /**
4363
+ * Maximum end scale ratio for particles
4364
+ * @public
4365
+ * @type {number}
4366
+ * @name maxEndScale
4367
+ * @default 0
4368
+ * @memberof ParticleEmitterSettings
4369
+ */
4370
+ maxEndScale: number;
4371
+ /**
4372
+ * Vertical force (Gravity) for each particle
4373
+ * @public
4374
+ * @type {number}
4375
+ * @name gravity
4376
+ * @default 0
4377
+ * @memberof ParticleEmitterSettings
4378
+ * @see game.world.gravity
4379
+ */
4380
+ gravity: number;
4381
+ /**
4382
+ * Horizontal force (like a Wind) for each particle
4383
+ * @public
4384
+ * @type {number}
4385
+ * @name wind
4386
+ * @default 0
4387
+ * @memberof ParticleEmitterSettings
4388
+ */
4389
+ wind: number;
4390
+ /**
4391
+ * Update the rotation of particle in accordance the particle trajectory.<br>
4392
+ * The particle sprite should aim at zero angle (draw from left to right).<br>
4393
+ * Override the particle minRotation and maxRotation.<br>
4394
+ * @public
4395
+ * @type {boolean}
4396
+ * @name followTrajectory
4397
+ * @default false
4398
+ * @memberof ParticleEmitterSettings
4399
+ */
4400
+ followTrajectory: boolean;
4401
+ /**
4402
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
4403
+ * @public
4404
+ * @type {boolean}
4405
+ * @name textureAdditive
4406
+ * @default false
4407
+ * @memberof ParticleEmitterSettings
4408
+ * @see ParticleEmitterSettings.blendMode
4409
+ */
4410
+ textureAdditive: boolean;
4411
+ /**
4412
+ * the blend mode to be applied when rendering particles.
4413
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
4414
+ * @public
4415
+ * @type {string}
4416
+ * @name blendMode
4417
+ * @default normal
4418
+ * @memberof ParticleEmitterSettings
4419
+ * @see CanvasRenderer#setBlendMode
4420
+ * @see WebGLRenderer#setBlendMode
4421
+ */
4422
+ blendMode: string;
4423
+ /**
4424
+ * Update particles only in the viewport, remove it when out of viewport.
4425
+ * @public
4426
+ * @type {boolean}
4427
+ * @name onlyInViewport
4428
+ * @default true
4429
+ * @memberof ParticleEmitterSettings
4430
+ */
4431
+ onlyInViewport: boolean;
4432
+ /**
4433
+ * Render particles in screen space.
4434
+ * @public
4435
+ * @type {boolean}
4436
+ * @name floating
4437
+ * @default false
4438
+ * @memberof ParticleEmitterSettings
4439
+ */
4440
+ floating: boolean;
4441
+ /**
4442
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
4443
+ * @public
4444
+ * @type {number}
4445
+ * @name maxParticles
4446
+ * @default 10
4447
+ * @memberof ParticleEmitterSettings
4448
+ */
4449
+ maxParticles: number;
4450
+ /**
4451
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
4452
+ * @public
4453
+ * @type {number}
4454
+ * @name frequency
4455
+ * @default 100
4456
+ * @memberof ParticleEmitterSettings
4457
+ */
4458
+ frequency: number;
4459
+ /**
4460
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
4461
+ * After this period, the emitter stop the launch of particles.
4462
+ * @public
4463
+ * @type {number}
4464
+ * @name duration
4465
+ * @default Infinity
4466
+ * @memberof ParticleEmitterSettings
4467
+ */
4468
+ duration: number;
4469
+ /**
4470
+ * Skip n frames after updating the particle system once.
4471
+ * This can be used to reduce the performance impact of emitters with many particles.
4472
+ * @public
4473
+ * @type {number}
4474
+ * @name framesToSkip
4475
+ * @default 0
4476
+ * @memberof ParticleEmitterSettings
4477
+ */
4478
+ framesToSkip: number;
4479
+ });
4480
+ /**
4481
+ * the current (active) emitter settings
4482
+ * @public
4483
+ * @type {ParticleEmitterSettings}
4484
+ * @name settings
4485
+ * @memberof ParticleEmitter
4486
+ */
4487
+ public settings: {
4488
+ /**
4489
+ * Width of the particle spawn area.
4490
+ * @type {number}
4491
+ * @name width
4492
+ * @memberof ParticleEmitterSettings
4493
+ * @default 1
4494
+ */
4495
+ width: number;
4496
+ /**
4497
+ * Height of the particle spawn area
4498
+ * @public
4499
+ * @type {number}
4500
+ * @name height
4501
+ * @memberof ParticleEmitterSettings
4502
+ * @default 1
4503
+ */
4504
+ height: number;
4505
+ /**
4506
+ * image used for particles texture
4507
+ * (by default melonJS will create an white 8x8 texture image)
4508
+ * @public
4509
+ * @type {HTMLCanvasElement}
4510
+ * @name image
4511
+ * @memberof ParticleEmitterSettings
4512
+ * @default undefined
4513
+ * @see ParticleEmitterSettings.textureSize
4514
+ */
4515
+ image: HTMLCanvasElement;
4516
+ /**
4517
+ * default texture size used for particles if no image is specified
4518
+ * (by default melonJS will create an white 8x8 texture image)
4519
+ * @public
4520
+ * @type {number}
4521
+ * @name textureSize
4522
+ * @memberof ParticleEmitterSettings
4523
+ * @default 8
4524
+ * @see ParticleEmitterSettings.image
4525
+ */
4526
+ textureSize: number;
4527
+ /**
4528
+ * tint to be applied to particles
4529
+ * @public
4530
+ * @type {string}
4531
+ * @name tint
4532
+ * @memberof ParticleEmitterSettings
4533
+ * @default "#fff"
4534
+ */
4535
+ tint: string;
4536
+ /**
4537
+ * Total number of particles in the emitter
4538
+ * @public
4539
+ * @type {number}
4540
+ * @name totalParticles
4541
+ * @default 50
4542
+ * @memberof ParticleEmitterSettings
4543
+ */
4544
+ totalParticles: number;
4545
+ /**
4546
+ * Start angle for particle launch in Radians
4547
+ * @public
4548
+ * @type {number}
4549
+ * @name angle
4550
+ * @default Math.PI / 2
4551
+ * @memberof ParticleEmitterSettings
4552
+ */
4553
+ angle: number;
4554
+ /**
4555
+ * Variation in the start angle for particle launch in Radians.
4556
+ * @public
4557
+ * @type {number}
4558
+ * @name angleVariation
4559
+ * @default 0
4560
+ * @memberof ParticleEmitterSettings
4561
+ */
4562
+ angleVariation: number;
4563
+ /**
4564
+ * Minimum time each particle lives once it is emitted in ms.
4565
+ * @public
4566
+ * @type {number}
4567
+ * @name minLife
4568
+ * @default 1000
4569
+ * @memberof ParticleEmitterSettings
4570
+ */
4571
+ minLife: number;
4572
+ /**
4573
+ * Maximum time each particle lives once it is emitted in ms.
4574
+ * @public
4575
+ * @type {number}
4576
+ * @name maxLife
4577
+ * @default 3000
4578
+ * @memberof ParticleEmitterSettings
4579
+ */
4580
+ maxLife: number;
4581
+ /**
4582
+ * Start speed of particles.<br>
4583
+ * @public
4584
+ * @type {number}
4585
+ * @name speed
4586
+ * @default 2
4587
+ * @memberof ParticleEmitterSettings
4588
+ */
4589
+ speed: number;
4590
+ /**
4591
+ * Variation in the start speed of particles
4592
+ * @public
4593
+ * @type {number}
4594
+ * @name speedVariation
4595
+ * @default 1
4596
+ * @memberof ParticleEmitterSettings
4597
+ */
4598
+ speedVariation: number;
4599
+ /**
4600
+ * Minimum start rotation for particles sprites in Radians
4601
+ * @public
4602
+ * @type {number}
4603
+ * @name minRotation
4604
+ * @default 0
4605
+ * @memberof ParticleEmitterSettings
4606
+ */
4607
+ minRotation: number;
4608
+ /**
4609
+ * Maximum start rotation for particles sprites in Radians
4610
+ * @public
4611
+ * @type {number}
4612
+ * @name maxRotation
4613
+ * @default 0
4614
+ * @memberof ParticleEmitterSettings
4615
+ */
4616
+ maxRotation: number;
4617
+ /**
4618
+ * Minimum start scale ratio for particles (1 = no scaling)
4619
+ * @public
4620
+ * @type {number}
4621
+ * @name minStartScale
4622
+ * @default 1
4623
+ * @memberof ParticleEmitterSettings
4624
+ */
4625
+ minStartScale: number;
4626
+ /**
4627
+ * Maximum start scale ratio for particles (1 = no scaling)
4628
+ * @public
4629
+ * @type {number}
4630
+ * @name maxStartScale
4631
+ * @default 1
4632
+ * @memberof ParticleEmitterSettings
4633
+ */
4634
+ maxStartScale: number;
4635
+ /**
4636
+ * Minimum end scale ratio for particles
4637
+ * @public
4638
+ * @type {number}
4639
+ * @name minEndScale
4640
+ * @default 0
4641
+ * @memberof ParticleEmitterSettings
4642
+ */
4643
+ minEndScale: number;
4644
+ /**
4645
+ * Maximum end scale ratio for particles
4646
+ * @public
4647
+ * @type {number}
4648
+ * @name maxEndScale
4649
+ * @default 0
4650
+ * @memberof ParticleEmitterSettings
4651
+ */
4652
+ maxEndScale: number;
4653
+ /**
4654
+ * Vertical force (Gravity) for each particle
4655
+ * @public
4656
+ * @type {number}
4657
+ * @name gravity
4658
+ * @default 0
4659
+ * @memberof ParticleEmitterSettings
4660
+ * @see game.world.gravity
4661
+ */
4662
+ gravity: number;
4663
+ /**
4664
+ * Horizontal force (like a Wind) for each particle
4665
+ * @public
4666
+ * @type {number}
4667
+ * @name wind
4668
+ * @default 0
4669
+ * @memberof ParticleEmitterSettings
4670
+ */
4671
+ wind: number;
4672
+ /**
4673
+ * Update the rotation of particle in accordance the particle trajectory.<br>
4674
+ * The particle sprite should aim at zero angle (draw from left to right).<br>
4675
+ * Override the particle minRotation and maxRotation.<br>
4676
+ * @public
4677
+ * @type {boolean}
4678
+ * @name followTrajectory
4679
+ * @default false
4680
+ * @memberof ParticleEmitterSettings
4681
+ */
4682
+ followTrajectory: boolean;
4683
+ /**
4684
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
4685
+ * @public
4686
+ * @type {boolean}
4687
+ * @name textureAdditive
4688
+ * @default false
4689
+ * @memberof ParticleEmitterSettings
4690
+ * @see ParticleEmitterSettings.blendMode
4691
+ */
4692
+ textureAdditive: boolean;
4693
+ /**
4694
+ * the blend mode to be applied when rendering particles.
4695
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
4696
+ * @public
4697
+ * @type {string}
4698
+ * @name blendMode
4699
+ * @default normal
4700
+ * @memberof ParticleEmitterSettings
4701
+ * @see CanvasRenderer#setBlendMode
4702
+ * @see WebGLRenderer#setBlendMode
4703
+ */
4704
+ blendMode: string;
4705
+ /**
4706
+ * Update particles only in the viewport, remove it when out of viewport.
4707
+ * @public
4708
+ * @type {boolean}
4709
+ * @name onlyInViewport
4710
+ * @default true
4711
+ * @memberof ParticleEmitterSettings
4712
+ */
4713
+ onlyInViewport: boolean;
4714
+ /**
4715
+ * Render particles in screen space.
4716
+ * @public
4717
+ * @type {boolean}
4718
+ * @name floating
4719
+ * @default false
4720
+ * @memberof ParticleEmitterSettings
4721
+ */
4722
+ floating: boolean;
4723
+ /**
4724
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
4725
+ * @public
4726
+ * @type {number}
4727
+ * @name maxParticles
4728
+ * @default 10
4729
+ * @memberof ParticleEmitterSettings
4730
+ */
4731
+ maxParticles: number;
4732
+ /**
4733
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
4734
+ * @public
4735
+ * @type {number}
4736
+ * @name frequency
4737
+ * @default 100
4738
+ * @memberof ParticleEmitterSettings
4739
+ */
4740
+ frequency: number;
4741
+ /**
4742
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
4743
+ * After this period, the emitter stop the launch of particles.
4744
+ * @public
4745
+ * @type {number}
4746
+ * @name duration
4747
+ * @default Infinity
4748
+ * @memberof ParticleEmitterSettings
4749
+ */
4750
+ duration: number;
4751
+ /**
4752
+ * Skip n frames after updating the particle system once.
4753
+ * This can be used to reduce the performance impact of emitters with many particles.
4754
+ * @public
4755
+ * @type {number}
4756
+ * @name framesToSkip
4757
+ * @default 0
4758
+ * @memberof ParticleEmitterSettings
4759
+ */
4760
+ framesToSkip: number;
4761
+ };
4122
4762
  /** @ignore */
4123
4763
  _stream: boolean;
4124
4764
  /** @ignore */
@@ -4127,95 +4767,316 @@ export class ParticleEmitter extends Rect {
4127
4767
  _durationTimer: number;
4128
4768
  /** @ignore */
4129
4769
  _enabled: boolean;
4130
- alwaysUpdate: boolean;
4131
- autoSort: boolean;
4132
- container: ParticleContainer;
4133
- /**
4134
- * @ignore
4135
- */
4136
- set z(arg: number);
4137
- /**
4138
- * @ignore
4139
- */
4140
- get z(): number;
4141
- set floating(arg: boolean);
4142
- /**
4143
- * Floating property for particles, value is forwarded to the particle container <br>
4144
- * @type {boolean}
4145
- * @name floating
4146
- * @memberof ParticleEmitter
4147
- */
4148
- get floating(): boolean;
4149
- /**
4150
- * @ignore
4151
- */
4152
- onActivateEvent(): void;
4153
- /**
4154
- * @ignore
4155
- */
4156
- onDeactivateEvent(): void;
4770
+ _updateCount: number;
4771
+ _dt: number;
4157
4772
  /**
4158
- * @ignore
4773
+ * Reset the emitter with particle emitter settings.
4774
+ * @param {ParticleEmitterSettings} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
4159
4775
  */
4160
- destroy(): void;
4776
+ reset(settings?: {
4777
+ /**
4778
+ * Width of the particle spawn area.
4779
+ * @type {number}
4780
+ * @name width
4781
+ * @memberof ParticleEmitterSettings
4782
+ * @default 1
4783
+ */
4784
+ width: number;
4785
+ /**
4786
+ * Height of the particle spawn area
4787
+ * @public
4788
+ * @type {number}
4789
+ * @name height
4790
+ * @memberof ParticleEmitterSettings
4791
+ * @default 1
4792
+ */
4793
+ height: number;
4794
+ /**
4795
+ * image used for particles texture
4796
+ * (by default melonJS will create an white 8x8 texture image)
4797
+ * @public
4798
+ * @type {HTMLCanvasElement}
4799
+ * @name image
4800
+ * @memberof ParticleEmitterSettings
4801
+ * @default undefined
4802
+ * @see ParticleEmitterSettings.textureSize
4803
+ */
4804
+ image: HTMLCanvasElement;
4805
+ /**
4806
+ * default texture size used for particles if no image is specified
4807
+ * (by default melonJS will create an white 8x8 texture image)
4808
+ * @public
4809
+ * @type {number}
4810
+ * @name textureSize
4811
+ * @memberof ParticleEmitterSettings
4812
+ * @default 8
4813
+ * @see ParticleEmitterSettings.image
4814
+ */
4815
+ textureSize: number;
4816
+ /**
4817
+ * tint to be applied to particles
4818
+ * @public
4819
+ * @type {string}
4820
+ * @name tint
4821
+ * @memberof ParticleEmitterSettings
4822
+ * @default "#fff"
4823
+ */
4824
+ tint: string;
4825
+ /**
4826
+ * Total number of particles in the emitter
4827
+ * @public
4828
+ * @type {number}
4829
+ * @name totalParticles
4830
+ * @default 50
4831
+ * @memberof ParticleEmitterSettings
4832
+ */
4833
+ totalParticles: number;
4834
+ /**
4835
+ * Start angle for particle launch in Radians
4836
+ * @public
4837
+ * @type {number}
4838
+ * @name angle
4839
+ * @default Math.PI / 2
4840
+ * @memberof ParticleEmitterSettings
4841
+ */
4842
+ angle: number;
4843
+ /**
4844
+ * Variation in the start angle for particle launch in Radians.
4845
+ * @public
4846
+ * @type {number}
4847
+ * @name angleVariation
4848
+ * @default 0
4849
+ * @memberof ParticleEmitterSettings
4850
+ */
4851
+ angleVariation: number;
4852
+ /**
4853
+ * Minimum time each particle lives once it is emitted in ms.
4854
+ * @public
4855
+ * @type {number}
4856
+ * @name minLife
4857
+ * @default 1000
4858
+ * @memberof ParticleEmitterSettings
4859
+ */
4860
+ minLife: number;
4861
+ /**
4862
+ * Maximum time each particle lives once it is emitted in ms.
4863
+ * @public
4864
+ * @type {number}
4865
+ * @name maxLife
4866
+ * @default 3000
4867
+ * @memberof ParticleEmitterSettings
4868
+ */
4869
+ maxLife: number;
4870
+ /**
4871
+ * Start speed of particles.<br>
4872
+ * @public
4873
+ * @type {number}
4874
+ * @name speed
4875
+ * @default 2
4876
+ * @memberof ParticleEmitterSettings
4877
+ */
4878
+ speed: number;
4879
+ /**
4880
+ * Variation in the start speed of particles
4881
+ * @public
4882
+ * @type {number}
4883
+ * @name speedVariation
4884
+ * @default 1
4885
+ * @memberof ParticleEmitterSettings
4886
+ */
4887
+ speedVariation: number;
4888
+ /**
4889
+ * Minimum start rotation for particles sprites in Radians
4890
+ * @public
4891
+ * @type {number}
4892
+ * @name minRotation
4893
+ * @default 0
4894
+ * @memberof ParticleEmitterSettings
4895
+ */
4896
+ minRotation: number;
4897
+ /**
4898
+ * Maximum start rotation for particles sprites in Radians
4899
+ * @public
4900
+ * @type {number}
4901
+ * @name maxRotation
4902
+ * @default 0
4903
+ * @memberof ParticleEmitterSettings
4904
+ */
4905
+ maxRotation: number;
4906
+ /**
4907
+ * Minimum start scale ratio for particles (1 = no scaling)
4908
+ * @public
4909
+ * @type {number}
4910
+ * @name minStartScale
4911
+ * @default 1
4912
+ * @memberof ParticleEmitterSettings
4913
+ */
4914
+ minStartScale: number;
4915
+ /**
4916
+ * Maximum start scale ratio for particles (1 = no scaling)
4917
+ * @public
4918
+ * @type {number}
4919
+ * @name maxStartScale
4920
+ * @default 1
4921
+ * @memberof ParticleEmitterSettings
4922
+ */
4923
+ maxStartScale: number;
4924
+ /**
4925
+ * Minimum end scale ratio for particles
4926
+ * @public
4927
+ * @type {number}
4928
+ * @name minEndScale
4929
+ * @default 0
4930
+ * @memberof ParticleEmitterSettings
4931
+ */
4932
+ minEndScale: number;
4933
+ /**
4934
+ * Maximum end scale ratio for particles
4935
+ * @public
4936
+ * @type {number}
4937
+ * @name maxEndScale
4938
+ * @default 0
4939
+ * @memberof ParticleEmitterSettings
4940
+ */
4941
+ maxEndScale: number;
4942
+ /**
4943
+ * Vertical force (Gravity) for each particle
4944
+ * @public
4945
+ * @type {number}
4946
+ * @name gravity
4947
+ * @default 0
4948
+ * @memberof ParticleEmitterSettings
4949
+ * @see game.world.gravity
4950
+ */
4951
+ gravity: number;
4952
+ /**
4953
+ * Horizontal force (like a Wind) for each particle
4954
+ * @public
4955
+ * @type {number}
4956
+ * @name wind
4957
+ * @default 0
4958
+ * @memberof ParticleEmitterSettings
4959
+ */
4960
+ wind: number;
4961
+ /**
4962
+ * Update the rotation of particle in accordance the particle trajectory.<br>
4963
+ * The particle sprite should aim at zero angle (draw from left to right).<br>
4964
+ * Override the particle minRotation and maxRotation.<br>
4965
+ * @public
4966
+ * @type {boolean}
4967
+ * @name followTrajectory
4968
+ * @default false
4969
+ * @memberof ParticleEmitterSettings
4970
+ */
4971
+ followTrajectory: boolean;
4972
+ /**
4973
+ * Enable the Texture Additive by composite operation ("additive" blendMode)
4974
+ * @public
4975
+ * @type {boolean}
4976
+ * @name textureAdditive
4977
+ * @default false
4978
+ * @memberof ParticleEmitterSettings
4979
+ * @see ParticleEmitterSettings.blendMode
4980
+ */
4981
+ textureAdditive: boolean;
4982
+ /**
4983
+ * the blend mode to be applied when rendering particles.
4984
+ * (note: this will superseed the `textureAdditive` setting if different than "normal")
4985
+ * @public
4986
+ * @type {string}
4987
+ * @name blendMode
4988
+ * @default normal
4989
+ * @memberof ParticleEmitterSettings
4990
+ * @see CanvasRenderer#setBlendMode
4991
+ * @see WebGLRenderer#setBlendMode
4992
+ */
4993
+ blendMode: string;
4994
+ /**
4995
+ * Update particles only in the viewport, remove it when out of viewport.
4996
+ * @public
4997
+ * @type {boolean}
4998
+ * @name onlyInViewport
4999
+ * @default true
5000
+ * @memberof ParticleEmitterSettings
5001
+ */
5002
+ onlyInViewport: boolean;
5003
+ /**
5004
+ * Render particles in screen space.
5005
+ * @public
5006
+ * @type {boolean}
5007
+ * @name floating
5008
+ * @default false
5009
+ * @memberof ParticleEmitterSettings
5010
+ */
5011
+ floating: boolean;
5012
+ /**
5013
+ * Maximum number of particles launched each time in this emitter (used only if emitter is Stream).
5014
+ * @public
5015
+ * @type {number}
5016
+ * @name maxParticles
5017
+ * @default 10
5018
+ * @memberof ParticleEmitterSettings
5019
+ */
5020
+ maxParticles: number;
5021
+ /**
5022
+ * How often a particle is emitted in ms (used only if emitter is a Stream).
5023
+ * @public
5024
+ * @type {number}
5025
+ * @name frequency
5026
+ * @default 100
5027
+ * @memberof ParticleEmitterSettings
5028
+ */
5029
+ frequency: number;
5030
+ /**
5031
+ * Duration that the emitter releases particles in ms (used only if emitter is Stream).
5032
+ * After this period, the emitter stop the launch of particles.
5033
+ * @public
5034
+ * @type {number}
5035
+ * @name duration
5036
+ * @default Infinity
5037
+ * @memberof ParticleEmitterSettings
5038
+ */
5039
+ duration: number;
5040
+ /**
5041
+ * Skip n frames after updating the particle system once.
5042
+ * This can be used to reduce the performance impact of emitters with many particles.
5043
+ * @public
5044
+ * @type {number}
5045
+ * @name framesToSkip
5046
+ * @default 0
5047
+ * @memberof ParticleEmitterSettings
5048
+ */
5049
+ framesToSkip: number;
5050
+ }): void;
4161
5051
  /**
4162
- * returns a random point inside the bounds x axis of this emitter
4163
- * @name getRandomPointX
4164
- * @memberof ParticleEmitter
4165
- * @function
5052
+ * returns a random point on the x axis within the bounds of this emitter
4166
5053
  * @returns {number}
4167
5054
  */
4168
5055
  getRandomPointX(): number;
4169
5056
  /**
4170
- * returns a random point inside the bounds y axis of this emitter
4171
- * @name getRandomPointY
4172
- * @memberof ParticleEmitter
4173
- * @function
5057
+ * returns a random point on the y axis within the bounds this emitter
4174
5058
  * @returns {number}
4175
5059
  */
4176
5060
  getRandomPointY(): number;
4177
- /**
4178
- * Reset the emitter with default values.<br>
4179
- * @function
4180
- * @param {object} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
4181
- * @name reset
4182
- * @memberof ParticleEmitter
4183
- */
4184
- reset(settings: object): void;
4185
5061
  /** @ignore */
4186
5062
  addParticles(count: any): void;
4187
5063
  /**
4188
- * Emitter is of type stream and is launching particles <br>
4189
- * @function
5064
+ * Emitter is of type stream and is launching particles
4190
5065
  * @returns {boolean} Emitter is Stream and is launching particles
4191
- * @name isRunning
4192
- * @memberof ParticleEmitter
4193
5066
  */
4194
5067
  isRunning(): boolean;
4195
5068
  /**
4196
- * Launch particles from emitter constantly <br>
4197
- * Particles example: Fountains
5069
+ * Launch particles from emitter constantly (e.g. for stream)
4198
5070
  * @param {number} duration [optional] time that the emitter releases particles in ms
4199
- * @function
4200
- * @name streamParticles
4201
- * @memberof ParticleEmitter
4202
5071
  */
4203
5072
  streamParticles(duration: number): void;
4204
- frequency: any;
4205
5073
  /**
4206
- * Stop the emitter from generating new particles (used only if emitter is Stream) <br>
4207
- * @function
4208
- * @name stopStream
4209
- * @memberof ParticleEmitter
5074
+ * Stop the emitter from generating new particles (used only if emitter is Stream)
4210
5075
  */
4211
5076
  stopStream(): void;
4212
5077
  /**
4213
- * Launch all particles from emitter and stop <br>
4214
- * Particles example: Explosions <br>
5078
+ * Launch all particles from emitter and stop (e.g. for explosion)
4215
5079
  * @param {number} total [optional] number of particles to launch
4216
- * @function
4217
- * @name burstParticles
4218
- * @memberof ParticleEmitter
4219
5080
  */
4220
5081
  burstParticles(total: number): void;
4221
5082
  /**
@@ -4224,32 +5085,35 @@ export class ParticleEmitter extends Rect {
4224
5085
  update(dt: any): boolean;
4225
5086
  }
4226
5087
  export namespace ParticleEmitterSettings {
4227
- export const width: number;
4228
- export const height: number;
4229
- export { pixel as image };
4230
- export const totalParticles: number;
4231
- export const angle: number;
4232
- export const angleVariation: number;
4233
- export const minLife: number;
4234
- export const maxLife: number;
4235
- export const speed: number;
4236
- export const speedVariation: number;
4237
- export const minRotation: number;
4238
- export const maxRotation: number;
4239
- export const minStartScale: number;
4240
- export const maxStartScale: number;
4241
- export const minEndScale: number;
4242
- export const maxEndScale: number;
4243
- export const gravity: number;
4244
- export const wind: number;
4245
- export const followTrajectory: boolean;
4246
- export const textureAdditive: boolean;
4247
- export const onlyInViewport: boolean;
4248
- export const floating: boolean;
4249
- export const maxParticles: number;
4250
- export const frequency: number;
4251
- export const duration: number;
4252
- export const framesToSkip: number;
5088
+ const width: number;
5089
+ const height: number;
5090
+ const image: HTMLCanvasElement;
5091
+ const textureSize: number;
5092
+ const tint: string;
5093
+ const totalParticles: number;
5094
+ const angle: number;
5095
+ const angleVariation: number;
5096
+ const minLife: number;
5097
+ const maxLife: number;
5098
+ const speed: number;
5099
+ const speedVariation: number;
5100
+ const minRotation: number;
5101
+ const maxRotation: number;
5102
+ const minStartScale: number;
5103
+ const maxStartScale: number;
5104
+ const minEndScale: number;
5105
+ const maxEndScale: number;
5106
+ const gravity: number;
5107
+ const wind: number;
5108
+ const followTrajectory: boolean;
5109
+ const textureAdditive: boolean;
5110
+ const blendMode: string;
5111
+ const onlyInViewport: boolean;
5112
+ const floating: boolean;
5113
+ const maxParticles: number;
5114
+ const frequency: number;
5115
+ const duration: number;
5116
+ const framesToSkip: number;
4253
5117
  }
4254
5118
  /**
4255
5119
  * @classdesc
@@ -4541,7 +5405,7 @@ export class Polygon {
4541
5405
  * @public
4542
5406
  * @type {Vector2d}
4543
5407
  * @name pos
4544
- * @memberof Polygon#
5408
+ * @memberof Polygon.prototype
4545
5409
  */
4546
5410
  public pos: Vector2d;
4547
5411
  /**
@@ -4549,7 +5413,7 @@ export class Polygon {
4549
5413
  * @ignore
4550
5414
  * @type {Bounds}
4551
5415
  * @name _bounds
4552
- * @memberof Polygon#
5416
+ * @memberof Polygon.prototype
4553
5417
  */
4554
5418
  _bounds: Bounds;
4555
5419
  /**
@@ -4558,7 +5422,7 @@ export class Polygon {
4558
5422
  * @public
4559
5423
  * @type {Vector2d[]}
4560
5424
  * @name points
4561
- * @memberof Polygon#
5425
+ * @memberof Polygon.prototype
4562
5426
  */
4563
5427
  public points: Vector2d[];
4564
5428
  /**
@@ -4703,14 +5567,14 @@ export class Polygon {
4703
5567
  /**
4704
5568
  * Shifts the Polygon to the given position vector.
4705
5569
  * @name shift
4706
- * @memberof Polygon
5570
+ * @memberof Polygon.prototype
4707
5571
  * @function
4708
5572
  * @param {Vector2d} position
4709
5573
  */
4710
5574
  /**
4711
5575
  * Shifts the Polygon to the given x, y position.
4712
5576
  * @name shift
4713
- * @memberof Polygon
5577
+ * @memberof Polygon.prototype
4714
5578
  * @function
4715
5579
  * @param {number} x
4716
5580
  * @param {number} y
@@ -4880,7 +5744,7 @@ export class Rect extends Polygon {
4880
5744
  * @public
4881
5745
  * @type {number}
4882
5746
  * @name left
4883
- * @memberof Rect
5747
+ * @memberof Rect.prototype
4884
5748
  */
4885
5749
  public get left(): number;
4886
5750
  /**
@@ -4888,7 +5752,7 @@ export class Rect extends Polygon {
4888
5752
  * @public
4889
5753
  * @type {number}
4890
5754
  * @name right
4891
- * @memberof Rect
5755
+ * @memberof Rect.prototype
4892
5756
  */
4893
5757
  public get right(): number;
4894
5758
  /**
@@ -4896,7 +5760,7 @@ export class Rect extends Polygon {
4896
5760
  * @public
4897
5761
  * @type {number}
4898
5762
  * @name top
4899
- * @memberof Rect
5763
+ * @memberof Rect.prototype
4900
5764
  */
4901
5765
  public get top(): number;
4902
5766
  /**
@@ -4904,7 +5768,7 @@ export class Rect extends Polygon {
4904
5768
  * @public
4905
5769
  * @type {number}
4906
5770
  * @name bottom
4907
- * @memberof Rect
5771
+ * @memberof Rect.prototype
4908
5772
  */
4909
5773
  public get bottom(): number;
4910
5774
  public set width(arg: number);
@@ -4913,7 +5777,7 @@ export class Rect extends Polygon {
4913
5777
  * @public
4914
5778
  * @type {number}
4915
5779
  * @name width
4916
- * @memberof Rect
5780
+ * @memberof Rect.prototype
4917
5781
  */
4918
5782
  public get width(): number;
4919
5783
  public set height(arg: number);
@@ -4922,7 +5786,7 @@ export class Rect extends Polygon {
4922
5786
  * @public
4923
5787
  * @type {number}
4924
5788
  * @name height
4925
- * @memberof Rect
5789
+ * @memberof Rect.prototype
4926
5790
  */
4927
5791
  public get height(): number;
4928
5792
  public set centerX(arg: number);
@@ -4931,7 +5795,7 @@ export class Rect extends Polygon {
4931
5795
  * @public
4932
5796
  * @type {number}
4933
5797
  * @name centerX
4934
- * @memberof Rect
5798
+ * @memberof Rect.prototype
4935
5799
  */
4936
5800
  public get centerX(): number;
4937
5801
  public set centerY(arg: number);
@@ -4940,9 +5804,19 @@ export class Rect extends Polygon {
4940
5804
  * @public
4941
5805
  * @type {number}
4942
5806
  * @name centerY
4943
- * @memberof Rect
5807
+ * @memberof Rect.prototype
4944
5808
  */
4945
5809
  public get centerY(): number;
5810
+ /**
5811
+ * center the rectangle position around the given coordinates
5812
+ * @name centerOn
5813
+ * @memberof Rect.prototype
5814
+ * @function
5815
+ * @param {number} x the x coordinate around which to center this rectangle
5816
+ * @param {number} x the y coordinate around which to center this rectangle
5817
+ * @returns {Rect} this rectangle
5818
+ */
5819
+ centerOn(x: number, y: any): Rect;
4946
5820
  /**
4947
5821
  * resize the rectangle
4948
5822
  * @name resize
@@ -5597,11 +6471,18 @@ export class Renderer {
5597
6471
  /**
5598
6472
  * true if the current rendering context is valid
5599
6473
  * @name isContextValid
5600
- * @memberof Renderer
6474
+ * @memberof Renderer#
5601
6475
  * @default true
5602
6476
  * type {boolean}
5603
6477
  */
5604
6478
  isContextValid: boolean;
6479
+ /**
6480
+ * The Path2D instance used by the renderer to draw primitives
6481
+ * @name path2D
6482
+ * @type {Path2D}
6483
+ * @memberof Renderer#
6484
+ */
6485
+ path2D: Path2D;
5605
6486
  /**
5606
6487
  * @ignore
5607
6488
  */
@@ -5747,10 +6628,18 @@ export class Renderer {
5747
6628
  * @name stroke
5748
6629
  * @memberof Renderer.prototype
5749
6630
  * @function
5750
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
6631
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
5751
6632
  * @param {boolean} [fill=false] fill the shape with the current color if true
5752
6633
  */
5753
- stroke(shape: Rect | Polygon | Line | Ellipse, fill?: boolean): void;
6634
+ stroke(shape: Rect | RoundRect | Polygon | Line | Ellipse, fill?: boolean): void;
6635
+ /**
6636
+ * fill the given shape
6637
+ * @name fill
6638
+ * @memberof Renderer.prototype
6639
+ * @function
6640
+ * @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
6641
+ */
6642
+ fill(shape: Rect | Polygon | Line | Ellipse): void;
5754
6643
  /**
5755
6644
  * tint the given image or canvas using the given color
5756
6645
  * @name tint
@@ -5762,14 +6651,6 @@ export class Renderer {
5762
6651
  * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
5763
6652
  */
5764
6653
  tint(src: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas, color: Color | string, mode?: string): HTMLCanvasElement | OffscreenCanvas;
5765
- /**
5766
- * fill the given shape
5767
- * @name fill
5768
- * @memberof Renderer.prototype
5769
- * @function
5770
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to fill
5771
- */
5772
- fill(shape: Rect | Polygon | Line | Ellipse): void;
5773
6654
  /**
5774
6655
  * A mask limits rendering elements to the shape and position of the given mask object.
5775
6656
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
@@ -5811,6 +6692,42 @@ export class Renderer {
5811
6692
  drawFont(): void;
5812
6693
  get Texture(): typeof TextureAtlas;
5813
6694
  }
6695
+ /**
6696
+ * @classdesc
6697
+ * a rectangle object with rounded corners
6698
+ * @augments Rect
6699
+ */
6700
+ export class RoundRect extends Rect {
6701
+ /**
6702
+ * @param {number} x position of the rounded rectangle
6703
+ * @param {number} y position of the rounded rectangle
6704
+ * @param {number} width the rectangle width
6705
+ * @param {number} height the rectangle height
6706
+ * @param {number} [radius=20] the radius of the rounded corner
6707
+ */
6708
+ constructor(x: number, y: number, width: number, height: number, radius?: number);
6709
+ public set radius(arg: number);
6710
+ /**
6711
+ * the radius of the rounded corner
6712
+ * @public
6713
+ * @type {number}
6714
+ * @default 20
6715
+ * @name radius
6716
+ * @memberof RoundRect.prototype
6717
+ */
6718
+ public get radius(): number;
6719
+ /** @ignore */
6720
+ onResetEvent(x: any, y: any, w: any, h: any, radius: any): void;
6721
+ _radius: number;
6722
+ /**
6723
+ * clone this RoundRect
6724
+ * @name clone
6725
+ * @memberof RoundRect.prototype
6726
+ * @function
6727
+ * @returns {RoundRect} new RoundRect
6728
+ */
6729
+ clone(): RoundRect;
6730
+ }
5814
6731
  /**
5815
6732
  * @classdesc
5816
6733
  * An object to display a fixed or animated sprite on screen.
@@ -5898,7 +6815,7 @@ export class Sprite extends Renderable {
5898
6815
  current: {
5899
6816
  name: string;
5900
6817
  length: number;
5901
- offset: Vector2d;
6818
+ offset: any;
5902
6819
  width: number;
5903
6820
  height: number;
5904
6821
  angle: number;
@@ -6110,11 +7027,11 @@ export class Stage {
6110
7027
  * Cameras will be renderered based on this order defined in this list.
6111
7028
  * Only the "default" camera will be resized when the window or canvas is resized.
6112
7029
  * @public
6113
- * @type {Map}
7030
+ * @type {Map<Camera2d>}
6114
7031
  * @name cameras
6115
7032
  * @memberof Stage
6116
7033
  */
6117
- public cameras: Map<any, any>;
7034
+ public cameras: Map<Camera2d, any>;
6118
7035
  /**
6119
7036
  * The given constructor options
6120
7037
  * @public
@@ -8564,7 +9481,7 @@ export class WebGLRenderer extends Renderer {
8564
9481
  /**
8565
9482
  * The WebGL version used by this renderer (1 or 2)
8566
9483
  * @name WebGLVersion
8567
- * @memberof WebGLRenderer
9484
+ * @memberof WebGLRenderer#
8568
9485
  * @type {number}
8569
9486
  * @default 1
8570
9487
  * @readonly
@@ -8573,7 +9490,7 @@ export class WebGLRenderer extends Renderer {
8573
9490
  /**
8574
9491
  * The vendor string of the underlying graphics driver.
8575
9492
  * @name GPUVendor
8576
- * @memberof WebGLRenderer
9493
+ * @memberof WebGLRenderer#
8577
9494
  * @type {string}
8578
9495
  * @default null
8579
9496
  * @readonly
@@ -8582,7 +9499,7 @@ export class WebGLRenderer extends Renderer {
8582
9499
  /**
8583
9500
  * The renderer string of the underlying graphics driver.
8584
9501
  * @name GPURenderer
8585
- * @memberof WebGLRenderer
9502
+ * @memberof WebGLRenderer#
8586
9503
  * @type {string}
8587
9504
  * @default null
8588
9505
  * @readonly
@@ -8591,7 +9508,7 @@ export class WebGLRenderer extends Renderer {
8591
9508
  /**
8592
9509
  * The WebGL context
8593
9510
  * @name gl
8594
- * @memberof WebGLRenderer
9511
+ * @memberof WebGLRenderer#
8595
9512
  * type {WebGLRenderingContext}
8596
9513
  */
8597
9514
  context: WebGLRenderingContext;
@@ -8599,7 +9516,7 @@ export class WebGLRenderer extends Renderer {
8599
9516
  /**
8600
9517
  * Maximum number of texture unit supported under the current context
8601
9518
  * @name maxTextures
8602
- * @memberof WebGLRenderer
9519
+ * @memberof WebGLRenderer#
8603
9520
  * @type {number}
8604
9521
  * @readonly
8605
9522
  */
@@ -8620,10 +9537,6 @@ export class WebGLRenderer extends Renderer {
8620
9537
  * @ignore
8621
9538
  */
8622
9539
  _blendStack: any[];
8623
- /**
8624
- * @ignore
8625
- */
8626
- _glPoints: Vector2d[];
8627
9540
  /**
8628
9541
  * The current transformation matrix used for transformations on the overall scene
8629
9542
  * @name currentTransform
@@ -8641,10 +9554,10 @@ export class WebGLRenderer extends Renderer {
8641
9554
  /**
8642
9555
  * The list of active compositors
8643
9556
  * @name compositors
8644
- * @type {Map}
9557
+ * @type {Map<WebGLCompositor>}
8645
9558
  * @memberof WebGLRenderer#
8646
9559
  */
8647
- compositors: Map<any, any>;
9560
+ compositors: Map<WebGLCompositor, any>;
8648
9561
  cache: TextureCache;
8649
9562
  /**
8650
9563
  * set the active compositor for this renderer
@@ -8791,7 +9704,7 @@ export class WebGLRenderer extends Renderer {
8791
9704
  * <img src="images/normal-blendmode.png" width="510"/> <br>
8792
9705
  * - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
8793
9706
  * <img src="images/multiply-blendmode.png" width="510"/> <br>
8794
- * - "lighter" : where both content overlap the color is determined by adding color values. <br>
9707
+ * - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
8795
9708
  * <img src="images/lighter-blendmode.png" width="510"/> <br>
8796
9709
  * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
8797
9710
  * <img src="images/screen-blendmode.png" width="510"/> <br>
@@ -8799,7 +9712,7 @@ export class WebGLRenderer extends Renderer {
8799
9712
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
8800
9713
  * @memberof WebGLRenderer.prototype
8801
9714
  * @function
8802
- * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "screen"
9715
+ * @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
8803
9716
  * @param {WebGLRenderingContext} [gl]
8804
9717
  */
8805
9718
  setBlendMode(mode?: string, gl?: WebGLRenderingContext): void;
@@ -8853,6 +9766,14 @@ export class WebGLRenderer extends Renderer {
8853
9766
  * @param {number} alpha 0.0 to 1.0 values accepted.
8854
9767
  */
8855
9768
  setGlobalAlpha(alpha: number): void;
9769
+ /**
9770
+ * Return the global alpha
9771
+ * @name getGlobalAlpha
9772
+ * @memberof WebGLRenderer.prototype
9773
+ * @function
9774
+ * @returns {number} global alpha value
9775
+ */
9776
+ getGlobalAlpha(): number;
8856
9777
  /**
8857
9778
  * Set the current fill & stroke style color.
8858
9779
  * By default, or upon reset, the value is set to #000000.
@@ -8896,7 +9817,7 @@ export class WebGLRenderer extends Renderer {
8896
9817
  * @param {number} end end angle in radians
8897
9818
  * @param {boolean} [antiClockwise=false] draw arc anti-clockwise
8898
9819
  */
8899
- fillArc(x: number, y: number, radius: number, start: number, end: number): void;
9820
+ fillArc(x: number, y: number, radius: number, start: number, end: number, antiClockwise?: boolean): void;
8900
9821
  /**
8901
9822
  * Stroke an ellipse at the specified coordinates with given radius
8902
9823
  * @name strokeEllipse
@@ -8982,6 +9903,31 @@ export class WebGLRenderer extends Renderer {
8982
9903
  * @param {number} height
8983
9904
  */
8984
9905
  fillRect(x: number, y: number, width: number, height: number): void;
9906
+ /**
9907
+ * Stroke a rounded rectangle at the specified coordinates
9908
+ * @name strokeRoundRect
9909
+ * @memberof WebGLRenderer.prototype
9910
+ * @function
9911
+ * @param {number} x
9912
+ * @param {number} y
9913
+ * @param {number} width
9914
+ * @param {number} height
9915
+ * @param {number} radius
9916
+ * @param {boolean} [fill=false] also fill the shape with the current color if true
9917
+ */
9918
+ strokeRoundRect(x: number, y: number, width: number, height: number, radius: number, fill?: boolean): void;
9919
+ /**
9920
+ * Draw a rounded filled rectangle at the specified coordinates
9921
+ * @name fillRoundRect
9922
+ * @memberof WebGLRenderer.prototype
9923
+ * @function
9924
+ * @param {number} x
9925
+ * @param {number} y
9926
+ * @param {number} width
9927
+ * @param {number} height
9928
+ * @param {number} radius
9929
+ */
9930
+ fillRoundRect(x: number, y: number, width: number, height: number, radius: number): void;
8985
9931
  /**
8986
9932
  * Reset (overrides) the renderer transformation matrix to the
8987
9933
  * identity one, and then apply the given transformation matrix.
@@ -9075,9 +10021,9 @@ export class World extends Container {
9075
10021
  * @name bodies
9076
10022
  * @memberof World
9077
10023
  * @public
9078
- * @type {Set}
10024
+ * @type {Set<Body>}
9079
10025
  */
9080
- public bodies: Set<any>;
10026
+ public bodies: Set<Body>;
9081
10027
  /**
9082
10028
  * the instance of the game world quadtree used for broadphase
9083
10029
  * @name broadphase
@@ -9158,7 +10104,7 @@ declare namespace device$1 {
9158
10104
  namespace turnOnPointerLock { }
9159
10105
  namespace turnOffPointerLock { }
9160
10106
  }
9161
- export var event: Readonly<{
10107
+ declare var event$1: Readonly<{
9162
10108
  __proto__: any;
9163
10109
  BOOT: string;
9164
10110
  STATE_PAUSE: string;
@@ -9191,8 +10137,8 @@ export var event: Readonly<{
9191
10137
  WINDOW_ONORIENTATION_CHANGE: string;
9192
10138
  WINDOW_ONSCROLL: string;
9193
10139
  VIEWPORT_ONCHANGE: string;
9194
- WEBGL_ONCONTEXT_LOST: string;
9195
- WEBGL_ONCONTEXT_RESTORED: string;
10140
+ ONCONTEXT_LOST: string;
10141
+ ONCONTEXT_RESTORED: string;
9196
10142
  emit: typeof emit;
9197
10143
  on: typeof on;
9198
10144
  once: typeof once;
@@ -10165,16 +11111,12 @@ export var plugin: any;
10165
11111
  * @namespace plugins
10166
11112
  */
10167
11113
  export var plugins: {};
10168
- declare var pooling: Readonly<{
10169
- __proto__: any;
10170
- register: typeof register;
10171
- pull: typeof pull;
10172
- purge: typeof purge;
10173
- push: typeof push;
10174
- exists: typeof exists;
10175
- poolable: typeof poolable;
10176
- getInstanceCount: typeof getInstanceCount;
10177
- }>;
11114
+ /**
11115
+ * a default global object pool instance
11116
+ * @public
11117
+ * @type {ObjectPool}
11118
+ */
11119
+ declare var pool$1: ObjectPool;
10178
11120
  export namespace save {
10179
11121
  /**
10180
11122
  * Add new keys to localStorage and set them to the given default values if they do not exist
@@ -10829,6 +11771,7 @@ declare class Bounds {
10829
11771
  * @param {Vector2d[]} [vertices] an array of me.Vector2d points
10830
11772
  */
10831
11773
  constructor(vertices?: Vector2d[]);
11774
+ _center: Vector2d;
10832
11775
  /**
10833
11776
  * @ignore
10834
11777
  */
@@ -10841,7 +11784,6 @@ declare class Bounds {
10841
11784
  x: number;
10842
11785
  y: number;
10843
11786
  };
10844
- _center: Vector2d;
10845
11787
  /**
10846
11788
  * reset the bound
10847
11789
  * @name clear
@@ -11259,29 +12201,135 @@ declare function round(num: number, dec?: number): number;
11259
12201
  declare function toBeCloseTo(expected: number, actual: number, precision?: number): boolean;
11260
12202
  /**
11261
12203
  * @classdesc
11262
- * Particle Container Object.
11263
- * @class ParticleContainer
11264
- * @augments Container
11265
- * @param {ParticleEmitter} emitter the emitter which owns this container
12204
+ * a simplified path2d implementation, supporting only one path
11266
12205
  */
11267
- declare class ParticleContainer extends Container {
12206
+ declare class Path2D {
11268
12207
  /**
11269
- * @ignore
12208
+ * the points defining the current path
12209
+ * @public
12210
+ * @type {Vector2d[]}
12211
+ * @name points
12212
+ * @memberof Path2D#
11270
12213
  */
11271
- constructor(emitter: any);
11272
- _updateCount: number;
11273
- _dt: number;
11274
- _emitter: any;
12214
+ public points: Vector2d[];
11275
12215
  /**
11276
- * @ignore
12216
+ * space between interpolated points for quadratic and bezier curve approx. in pixels.
12217
+ * @public
12218
+ * @type {number}
12219
+ * @name arcResolution
12220
+ * @default 5
12221
+ * @memberof Path2D#
11277
12222
  */
11278
- update(dt: any): boolean;
12223
+ public arcResolution: number;
12224
+ vertices: any[];
11279
12225
  /**
11280
- * @ignore
12226
+ * begin a new path
12227
+ * @name beginPath
12228
+ * @memberof Path2D.prototype
12229
+ * @function
11281
12230
  */
11282
- draw(renderer: any, rect: any): void;
12231
+ beginPath(): void;
12232
+ /**
12233
+ * causes the point of the pen to move back to the start of the current path.
12234
+ * It tries to draw a straight line from the current point to the start.
12235
+ * If the shape has already been closed or has only one point, this function does nothing.
12236
+ * @name closePath
12237
+ * @memberof Path2D.prototype
12238
+ * @function
12239
+ */
12240
+ closePath(): void;
12241
+ /**
12242
+ * triangulate the shape defined by this path into an array of triangles
12243
+ * @name triangulatePath
12244
+ * @memberof Path2D.prototype
12245
+ * @function
12246
+ * @returns {Vector2d[]}
12247
+ */
12248
+ triangulatePath(): Vector2d[];
12249
+ /**
12250
+ * moves the starting point of the current path to the (x, y) coordinates.
12251
+ * @name moveTo
12252
+ * @memberof Path2D.prototype
12253
+ * @function
12254
+ * @param {number} x the x-axis (horizontal) coordinate of the point.
12255
+ * @param {number} y the y-axis (vertical) coordinate of the point.
12256
+ */
12257
+ moveTo(x: number, y: number): void;
12258
+ /**
12259
+ * connects the last point in the current patch to the (x, y) coordinates with a straight line.
12260
+ * @name lineTo
12261
+ * @memberof Path2D.prototype
12262
+ * @function
12263
+ * @param {number} x the x-axis coordinate of the line's end point.
12264
+ * @param {number} y the y-axis coordinate of the line's end point.
12265
+ */
12266
+ lineTo(x: number, y: number): void;
12267
+ /**
12268
+ * adds an arc to the current path which is centered at (x, y) position with the given radius,
12269
+ * starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
12270
+ * @name arc
12271
+ * @memberof Path2D.prototype
12272
+ * @function
12273
+ * @param {number} x the horizontal coordinate of the arc's center.
12274
+ * @param {number} y the vertical coordinate of the arc's center.
12275
+ * @param {number} radius the arc's radius. Must be positive.
12276
+ * @param {number} startAngle the angle at which the arc starts in radians, measured from the positive x-axis.
12277
+ * @param {number} endAngle the angle at which the arc ends in radians, measured from the positive x-axis.
12278
+ * @param {boolean} [anticlockwise=false] an optional boolean value. If true, draws the arc counter-clockwise between the start and end angles.
12279
+ */
12280
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;
12281
+ /**
12282
+ * adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
12283
+ * @name arcTo
12284
+ * @memberof Path2D.prototype
12285
+ * @function
12286
+ * @param {number} x the x-axis coordinate of the first control point.
12287
+ * @param {number} y the y-axis coordinate of the first control point.
12288
+ * @param {number} x the x-axis coordinate of the second control point.
12289
+ * @param {number} y the y-axis coordinate of the second control point.
12290
+ * @param {number} radius the arc's radius. Must be positive.
12291
+ */
12292
+ arcTo(x1: any, y1: any, x2: any, y2: any, radius: number): void;
12293
+ /**
12294
+ * adds an elliptical arc to the path which is centered at (x, y) position with the radii radiusX and radiusY
12295
+ * starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
12296
+ * @name ellipse
12297
+ * @memberof Path2D.prototype
12298
+ * @function
12299
+ * @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
12300
+ * @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
12301
+ * @param {number} radiusX the ellipse's major-axis radius. Must be non-negative.
12302
+ * @param {number} radiusY the ellipse's minor-axis radius. Must be non-negative.
12303
+ * @param {number} rotation the rotation of the ellipse, expressed in radians.
12304
+ * @param {number} startAngle the angle at which the ellipse starts, measured clockwise from the positive x-axis and expressed in radians.
12305
+ * @param {number} endAngle the angle at which the ellipse ends, measured clockwise from the positive x-axis and expressed in radians.
12306
+ * @param {boolean} [anticlockwise=false] an optional boolean value which, if true, draws the ellipse counterclockwise (anticlockwise).
12307
+ */
12308
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void;
12309
+ /**
12310
+ * creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
12311
+ * @name rect
12312
+ * @memberof Path2D.prototype
12313
+ * @function
12314
+ * @param {number} x the x-axis coordinate of the rectangle's starting point.
12315
+ * @param {number} y the y-axis coordinate of the rectangle's starting point.
12316
+ * @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
12317
+ * @param {number} height the rectangle's height. Positive values are down, and negative are up.
12318
+ */
12319
+ rect(x: number, y: number, width: number, height: number): void;
12320
+ /**
12321
+ * adds an rounded rectangle to the current path.
12322
+ * @name roundRect
12323
+ * @memberof Path2D.prototype
12324
+ * @function
12325
+ * @param {number} x the x-axis coordinate of the rectangle's starting point.
12326
+ * @param {number} y the y-axis coordinate of the rectangle's starting point.
12327
+ * @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
12328
+ * @param {number} height the rectangle's height. Positive values are down, and negative are up.
12329
+ * @param {number} radius the arc's radius to draw the borders. Must be positive.
12330
+ */
12331
+ roundRect(x: number, y: number, width: number, height: number, radius: number): void;
11283
12332
  }
11284
- declare var pixel: HTMLCanvasElement | OffscreenCanvas;
11285
12333
  /**
11286
12334
  * @classdesc
11287
12335
  * a Vertex Buffer object
@@ -11825,7 +12873,6 @@ declare function releaseAllPointerEvents(region: Rect | Polygon | Line | Ellipse
11825
12873
  * @memberof input
11826
12874
  * @public
11827
12875
  * @function
11828
- * @param {Function} [success] callback if the request is successful
11829
12876
  * @returns {boolean} return true if the request was successfully submitted
11830
12877
  * @example
11831
12878
  * // register on the pointer lock change event
@@ -12002,6 +13049,7 @@ declare function setGamepadDeadzone(value: number): void;
12002
13049
  */
12003
13050
  declare function addMapping(id: any, mapping: any): void;
12004
13051
  /**
13052
+ * @classdesc
12005
13053
  * This object is used for object pooling - a technique that might speed up your game if used properly.<br>
12006
13054
  * If some of your classes will be instantiated and removed a lot at a time, it is a
12007
13055
  * good idea to add the class to this object pool. A separate pool for that class
@@ -12012,96 +13060,93 @@ declare function addMapping(id: any, mapping: any): void;
12012
13060
  * which means, that on level loading the engine will try to instantiate every object
12013
13061
  * found in the map, based on the user defined name in each Object Properties<br>
12014
13062
  * <img src="images/object_properties.png"/><br>
12015
- * @namespace pool
12016
- */
12017
- /**
12018
- * register an object to the pool. <br>
12019
- * Pooling must be set to true if more than one such objects will be created. <br>
12020
- * (Note: for an object to be poolable, it must implements a `onResetEvent` method)
12021
- * @function pool.register
12022
- * @param {string} className as defined in the Name field of the Object Properties (in Tiled)
12023
- * @param {object} classObj corresponding Class to be instantiated
12024
- * @param {boolean} [recycling=false] enables object recycling for the specified class
12025
- * @example
12026
- * // implement CherryEntity
12027
- * class CherryEntity extends Spritesheet {
12028
- * onResetEvent() {
12029
- * // reset object mutable properties
12030
- * this.lifeBar = 100;
12031
- * }
12032
- * };
12033
- * // add our users defined entities in the object pool and enable object recycling
12034
- * me.pool.register("cherryentity", CherryEntity, true);
12035
- */
12036
- declare function register(className: string, classObj: object, recycling?: boolean): void;
12037
- /**
12038
- * Pull a new instance of the requested object (if added into the object pool)
12039
- * @function pool.pull
12040
- * @param {string} name as used in {@link pool.register}
12041
- * @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
12042
- * @returns {object} the instance of the requested object
12043
- * @example
12044
- * me.pool.register("bullet", BulletEntity, true);
12045
- * me.pool.register("enemy", EnemyEntity, true);
12046
- * // ...
12047
- * // when we need to manually create a new bullet:
12048
- * var bullet = me.pool.pull("bullet", x, y, direction);
12049
- * // ...
12050
- * // params aren't a fixed number
12051
- * // when we need new enemy we can add more params, that the object construct requires:
12052
- * var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
12053
- * // ...
12054
- * // when we want to destroy existing object, the remove
12055
- * // function will ensure the object can then be reallocated later
12056
- * me.game.world.removeChild(enemy);
12057
- * me.game.world.removeChild(bullet);
12058
- */
12059
- declare function pull(name: string, ...args: any[]): object;
12060
- /**
12061
- * purge the object pool from any inactive object <br>
12062
- * Object pooling must be enabled for this function to work<br>
12063
- * note: this will trigger the garbage collector
12064
- * @function pool.purge
12065
- */
12066
- declare function purge(): void;
12067
- /**
12068
- * Push back an object instance into the object pool <br>
12069
- * Object pooling for the object class must be enabled,
12070
- * and object must have been instantiated using {@link pool#pull},
12071
- * otherwise this function won't work
12072
- * @function pool.push
12073
- * @throws will throw an error if the object cannot be recycled
12074
- * @param {object} obj instance to be recycled
12075
- * @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
12076
- * @returns {boolean} true if the object was successfully recycled in the object pool
12077
- */
12078
- declare function push(obj: object, throwOnError?: boolean): boolean;
12079
- /**
12080
- * Check if an object with the provided name is registered
12081
- * @function pool.exists
12082
- * @param {string} name of the registered object class
12083
- * @returns {boolean} true if the classname is registered
12084
- */
12085
- declare function exists(name: string): boolean;
12086
- /**
12087
- * Check if an object is poolable
12088
- * (was properly registered with the recycling feature enable)
12089
- * @function pool.poolable
12090
- * @see pool.register
12091
- * @param {object} obj object to be checked
12092
- * @returns {boolean} true if the object is poolable
12093
- * @example
12094
- * if (!me.pool.poolable(myCherryEntity)) {
12095
- * // object was not properly registered
12096
- * }
12097
- */
12098
- declare function poolable(obj: object): boolean;
12099
- /**
12100
- * returns the amount of object instance currently in the pool
12101
- * @function pool.getInstanceCount
12102
- * @returns {number} amount of object instance
12103
- */
12104
- declare function getInstanceCount(): number;
13063
+ * @see {@link pool} a default global instance of ObjectPool
13064
+ */
13065
+ declare class ObjectPool {
13066
+ objectClass: {};
13067
+ instance_counter: number;
13068
+ /**
13069
+ * register an object to the pool. <br>
13070
+ * Pooling must be set to true if more than one such objects will be created. <br>
13071
+ * (Note: for an object to be poolable, it must implements a `onResetEvent` method)
13072
+ * @param {string} className as defined in the Name field of the Object Properties (in Tiled)
13073
+ * @param {object} classObj corresponding Class to be instantiated
13074
+ * @param {boolean} [recycling=false] enables object recycling for the specified class
13075
+ * @example
13076
+ * // implement CherryEntity
13077
+ * class CherryEntity extends Spritesheet {
13078
+ * onResetEvent() {
13079
+ * // reset object mutable properties
13080
+ * this.lifeBar = 100;
13081
+ * }
13082
+ * };
13083
+ * // add our users defined entities in the object pool and enable object recycling
13084
+ * me.pool.register("cherryentity", CherryEntity, true);
13085
+ */
13086
+ register(className: string, classObj: object, recycling?: boolean): void;
13087
+ /**
13088
+ * Pull a new instance of the requested object (if added into the object pool)
13089
+ * @param {string} name as used in {@link pool.register}
13090
+ * @param {object} [...arguments] arguments to be passed when instantiating/reinitializing the object
13091
+ * @returns {object} the instance of the requested object
13092
+ * @example
13093
+ * me.pool.register("bullet", BulletEntity, true);
13094
+ * me.pool.register("enemy", EnemyEntity, true);
13095
+ * // ...
13096
+ * // when we need to manually create a new bullet:
13097
+ * var bullet = me.pool.pull("bullet", x, y, direction);
13098
+ * // ...
13099
+ * // params aren't a fixed number
13100
+ * // when we need new enemy we can add more params, that the object construct requires:
13101
+ * var enemy = me.pool.pull("enemy", x, y, direction, speed, power, life);
13102
+ * // ...
13103
+ * // when we want to destroy existing object, the remove
13104
+ * // function will ensure the object can then be reallocated later
13105
+ * me.game.world.removeChild(enemy);
13106
+ * me.game.world.removeChild(bullet);
13107
+ */
13108
+ pull(name: string, ...args: any[]): object;
13109
+ /**
13110
+ * purge the object pool from any inactive object <br>
13111
+ * Object pooling must be enabled for this function to work<br>
13112
+ * note: this will trigger the garbage collector
13113
+ */
13114
+ purge(): void;
13115
+ /**
13116
+ * Push back an object instance into the object pool <br>
13117
+ * Object pooling for the object class must be enabled,
13118
+ * and object must have been instantiated using {@link pool#pull},
13119
+ * otherwise this function won't work
13120
+ * @throws will throw an error if the object cannot be recycled
13121
+ * @param {object} obj instance to be recycled
13122
+ * @param {boolean} [throwOnError=true] throw an exception if the object cannot be recycled
13123
+ * @returns {boolean} true if the object was successfully recycled in the object pool
13124
+ */
13125
+ push(obj: object, throwOnError?: boolean): boolean;
13126
+ /**
13127
+ * Check if an object with the provided name is registered
13128
+ * @param {string} name of the registered object class
13129
+ * @returns {boolean} true if the classname is registered
13130
+ */
13131
+ exists(name: string): boolean;
13132
+ /**
13133
+ * Check if an object is poolable
13134
+ * (was properly registered with the recycling feature enable)
13135
+ * @see register
13136
+ * @param {object} obj object to be checked
13137
+ * @returns {boolean} true if the object is poolable
13138
+ * @example
13139
+ * if (!me.pool.poolable(myCherryEntity)) {
13140
+ * // object was not properly registered
13141
+ * }
13142
+ */
13143
+ poolable(obj: object): boolean;
13144
+ /**
13145
+ * returns the amount of object instance currently in the pool
13146
+ * @returns {number} amount of object instance
13147
+ */
13148
+ getInstanceCount(): number;
13149
+ }
12105
13150
  declare var agentUtils: Readonly<{
12106
13151
  __proto__: any;
12107
13152
  prefixed: typeof prefixed;
@@ -12217,7 +13262,7 @@ declare function scale(x: number, y: number): void;
12217
13262
  * @name prefixed
12218
13263
  * @function
12219
13264
  * @param {string} name Property name
12220
- * @param {object} [obj=window] Object or element reference to access
13265
+ * @param {object} [obj=globalThis] Object or element reference to access
12221
13266
  * @returns {string} Value of property
12222
13267
  * @memberof utils.agent
12223
13268
  */
@@ -12229,7 +13274,7 @@ declare function prefixed(name: string, obj?: object): string;
12229
13274
  * @function
12230
13275
  * @param {string} name Property name
12231
13276
  * @param {string} value Property value
12232
- * @param {object} [obj=window] Object or element reference to access
13277
+ * @param {object} [obj=globalThis] Object or element reference to access
12233
13278
  * @returns {boolean} true if one of the vendor-prefixed property was found
12234
13279
  * @memberof utils.agent
12235
13280
  */
@@ -12394,4 +13439,4 @@ declare function defer(func: Function, thisArg: object, ...args: any[]): number;
12394
13439
  * @returns {Function} the function that will be throttled
12395
13440
  */
12396
13441
  declare function throttle(fn: Function, delay: number, no_trailing: any): Function;
12397
- export { Bounds$1 as Bounds, math as Math, device$1 as device, pooling as pool, timer$1 as timer };
13442
+ export { Bounds$1 as Bounds, math as Math, device$1 as device, event$1 as event, pool$1 as pool, timer$1 as timer };