melonjs 10.7.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 (62) hide show
  1. package/dist/melonjs.js +1131 -652
  2. package/dist/melonjs.min.js +4 -4
  3. package/dist/melonjs.module.d.ts +1038 -198
  4. package/dist/melonjs.module.js +1234 -763
  5. package/package.json +7 -7
  6. package/src/camera/camera2d.js +1 -1
  7. package/src/entity/entity.js +6 -7
  8. package/src/geometries/ellipse.js +10 -11
  9. package/src/geometries/line.js +3 -3
  10. package/src/geometries/path2d.js +319 -0
  11. package/src/geometries/poly.js +11 -11
  12. package/src/geometries/rectangle.js +15 -15
  13. package/src/geometries/roundrect.js +67 -0
  14. package/src/index.js +5 -1
  15. package/src/input/pointerevent.js +1 -1
  16. package/src/lang/deprecated.js +1 -1
  17. package/src/level/tiled/TMXLayer.js +1 -1
  18. package/src/level/tiled/TMXObject.js +9 -12
  19. package/src/level/tiled/TMXTileMap.js +23 -4
  20. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  21. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  22. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  23. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  24. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  25. package/src/loader/loader.js +4 -4
  26. package/src/loader/loadingscreen.js +1 -1
  27. package/src/math/color.js +1 -1
  28. package/src/math/matrix2.js +1 -1
  29. package/src/math/matrix3.js +1 -1
  30. package/src/math/observable_vector2.js +1 -1
  31. package/src/math/observable_vector3.js +1 -1
  32. package/src/math/vector2.js +1 -1
  33. package/src/math/vector3.js +1 -1
  34. package/src/particles/emitter.js +23 -14
  35. package/src/particles/particle.js +3 -2
  36. package/src/physics/body.js +67 -51
  37. package/src/physics/bounds.js +8 -9
  38. package/src/physics/world.js +1 -1
  39. package/src/renderable/collectable.js +9 -2
  40. package/src/renderable/colorlayer.js +1 -1
  41. package/src/renderable/container.js +1 -1
  42. package/src/renderable/imagelayer.js +1 -1
  43. package/src/renderable/renderable.js +1 -1
  44. package/src/renderable/sprite.js +2 -3
  45. package/src/renderable/trigger.js +10 -4
  46. package/src/state/stage.js +1 -1
  47. package/src/state/state.js +1 -1
  48. package/src/system/device.js +10 -8
  49. package/src/system/pooling.js +156 -149
  50. package/src/text/bitmaptext.js +1 -1
  51. package/src/text/text.js +1 -1
  52. package/src/video/canvas/canvas_renderer.js +89 -34
  53. package/src/video/renderer.js +26 -14
  54. package/src/video/texture.js +1 -1
  55. package/src/video/webgl/glshader.js +29 -193
  56. package/src/video/webgl/utils/attributes.js +16 -0
  57. package/src/video/webgl/utils/precision.js +11 -0
  58. package/src/video/webgl/utils/program.js +58 -0
  59. package/src/video/webgl/utils/string.js +16 -0
  60. package/src/video/webgl/utils/uniforms.js +87 -0
  61. package/src/video/webgl/webgl_compositor.js +1 -14
  62. package/src/video/webgl/webgl_renderer.js +123 -181
@@ -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
@@ -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
@@ -4064,7 +4149,7 @@ export class Particle extends Renderable {
4064
4149
  * @ignore
4065
4150
  */
4066
4151
  onResetEvent(emitter: any, newInstance?: boolean): void;
4067
- vel: Vector2d;
4152
+ vel: any;
4068
4153
  image: any;
4069
4154
  life: any;
4070
4155
  startLife: any;
@@ -4088,33 +4173,607 @@ export class Particle extends Renderable {
4088
4173
  */
4089
4174
  export class ParticleEmitter extends Container {
4090
4175
  /**
4091
- * @param {number} x x position of the particle emitter
4092
- * @param {number} y y position of the particle emitter
4093
- * @param {ParticleEmitterSettings} [settings=ParticleEmitterSettings] the settings for the particle emitter.
4094
- * @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;
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);
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);
4204
+ */
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
+ };
4762
+ /** @ignore */
4763
+ _stream: boolean;
4764
+ /** @ignore */
4765
+ _frequencyTimer: number;
4766
+ /** @ignore */
4767
+ _durationTimer: number;
4768
+ /** @ignore */
4769
+ _enabled: boolean;
4770
+ _updateCount: number;
4771
+ _dt: number;
4772
+ /**
4773
+ * Reset the emitter with particle emitter settings.
4774
+ * @param {ParticleEmitterSettings} settings [optional] object with emitter settings. See {@link ParticleEmitterSettings}
4116
4775
  */
4117
- constructor(x: number, y: number, settings?: {
4776
+ reset(settings?: {
4118
4777
  /**
4119
4778
  * Width of the particle spawn area.
4120
4779
  * @type {number}
@@ -4388,23 +5047,7 @@ export class ParticleEmitter extends Container {
4388
5047
  * @memberof ParticleEmitterSettings
4389
5048
  */
4390
5049
  framesToSkip: number;
4391
- });
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;
5050
+ }): void;
4408
5051
  /**
4409
5052
  * returns a random point on the x axis within the bounds of this emitter
4410
5053
  * @returns {number}
@@ -4762,7 +5405,7 @@ export class Polygon {
4762
5405
  * @public
4763
5406
  * @type {Vector2d}
4764
5407
  * @name pos
4765
- * @memberof Polygon#
5408
+ * @memberof Polygon.prototype
4766
5409
  */
4767
5410
  public pos: Vector2d;
4768
5411
  /**
@@ -4770,7 +5413,7 @@ export class Polygon {
4770
5413
  * @ignore
4771
5414
  * @type {Bounds}
4772
5415
  * @name _bounds
4773
- * @memberof Polygon#
5416
+ * @memberof Polygon.prototype
4774
5417
  */
4775
5418
  _bounds: Bounds;
4776
5419
  /**
@@ -4779,7 +5422,7 @@ export class Polygon {
4779
5422
  * @public
4780
5423
  * @type {Vector2d[]}
4781
5424
  * @name points
4782
- * @memberof Polygon#
5425
+ * @memberof Polygon.prototype
4783
5426
  */
4784
5427
  public points: Vector2d[];
4785
5428
  /**
@@ -4924,14 +5567,14 @@ export class Polygon {
4924
5567
  /**
4925
5568
  * Shifts the Polygon to the given position vector.
4926
5569
  * @name shift
4927
- * @memberof Polygon
5570
+ * @memberof Polygon.prototype
4928
5571
  * @function
4929
5572
  * @param {Vector2d} position
4930
5573
  */
4931
5574
  /**
4932
5575
  * Shifts the Polygon to the given x, y position.
4933
5576
  * @name shift
4934
- * @memberof Polygon
5577
+ * @memberof Polygon.prototype
4935
5578
  * @function
4936
5579
  * @param {number} x
4937
5580
  * @param {number} y
@@ -5101,7 +5744,7 @@ export class Rect extends Polygon {
5101
5744
  * @public
5102
5745
  * @type {number}
5103
5746
  * @name left
5104
- * @memberof Rect
5747
+ * @memberof Rect.prototype
5105
5748
  */
5106
5749
  public get left(): number;
5107
5750
  /**
@@ -5109,7 +5752,7 @@ export class Rect extends Polygon {
5109
5752
  * @public
5110
5753
  * @type {number}
5111
5754
  * @name right
5112
- * @memberof Rect
5755
+ * @memberof Rect.prototype
5113
5756
  */
5114
5757
  public get right(): number;
5115
5758
  /**
@@ -5117,7 +5760,7 @@ export class Rect extends Polygon {
5117
5760
  * @public
5118
5761
  * @type {number}
5119
5762
  * @name top
5120
- * @memberof Rect
5763
+ * @memberof Rect.prototype
5121
5764
  */
5122
5765
  public get top(): number;
5123
5766
  /**
@@ -5125,7 +5768,7 @@ export class Rect extends Polygon {
5125
5768
  * @public
5126
5769
  * @type {number}
5127
5770
  * @name bottom
5128
- * @memberof Rect
5771
+ * @memberof Rect.prototype
5129
5772
  */
5130
5773
  public get bottom(): number;
5131
5774
  public set width(arg: number);
@@ -5134,7 +5777,7 @@ export class Rect extends Polygon {
5134
5777
  * @public
5135
5778
  * @type {number}
5136
5779
  * @name width
5137
- * @memberof Rect
5780
+ * @memberof Rect.prototype
5138
5781
  */
5139
5782
  public get width(): number;
5140
5783
  public set height(arg: number);
@@ -5143,7 +5786,7 @@ export class Rect extends Polygon {
5143
5786
  * @public
5144
5787
  * @type {number}
5145
5788
  * @name height
5146
- * @memberof Rect
5789
+ * @memberof Rect.prototype
5147
5790
  */
5148
5791
  public get height(): number;
5149
5792
  public set centerX(arg: number);
@@ -5152,7 +5795,7 @@ export class Rect extends Polygon {
5152
5795
  * @public
5153
5796
  * @type {number}
5154
5797
  * @name centerX
5155
- * @memberof Rect
5798
+ * @memberof Rect.prototype
5156
5799
  */
5157
5800
  public get centerX(): number;
5158
5801
  public set centerY(arg: number);
@@ -5161,7 +5804,7 @@ export class Rect extends Polygon {
5161
5804
  * @public
5162
5805
  * @type {number}
5163
5806
  * @name centerY
5164
- * @memberof Rect
5807
+ * @memberof Rect.prototype
5165
5808
  */
5166
5809
  public get centerY(): number;
5167
5810
  /**
@@ -5828,11 +6471,18 @@ export class Renderer {
5828
6471
  /**
5829
6472
  * true if the current rendering context is valid
5830
6473
  * @name isContextValid
5831
- * @memberof Renderer
6474
+ * @memberof Renderer#
5832
6475
  * @default true
5833
6476
  * type {boolean}
5834
6477
  */
5835
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;
5836
6486
  /**
5837
6487
  * @ignore
5838
6488
  */
@@ -5978,10 +6628,18 @@ export class Renderer {
5978
6628
  * @name stroke
5979
6629
  * @memberof Renderer.prototype
5980
6630
  * @function
5981
- * @param {Rect|Polygon|Line|Ellipse} shape a shape object to stroke
6631
+ * @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
5982
6632
  * @param {boolean} [fill=false] fill the shape with the current color if true
5983
6633
  */
5984
- 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;
5985
6643
  /**
5986
6644
  * tint the given image or canvas using the given color
5987
6645
  * @name tint
@@ -5993,14 +6651,6 @@ export class Renderer {
5993
6651
  * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
5994
6652
  */
5995
6653
  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
6654
  /**
6005
6655
  * A mask limits rendering elements to the shape and position of the given mask object.
6006
6656
  * So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
@@ -6042,6 +6692,42 @@ export class Renderer {
6042
6692
  drawFont(): void;
6043
6693
  get Texture(): typeof TextureAtlas;
6044
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
+ }
6045
6731
  /**
6046
6732
  * @classdesc
6047
6733
  * An object to display a fixed or animated sprite on screen.
@@ -6129,7 +6815,7 @@ export class Sprite extends Renderable {
6129
6815
  current: {
6130
6816
  name: string;
6131
6817
  length: number;
6132
- offset: Vector2d;
6818
+ offset: any;
6133
6819
  width: number;
6134
6820
  height: number;
6135
6821
  angle: number;
@@ -6341,11 +7027,11 @@ export class Stage {
6341
7027
  * Cameras will be renderered based on this order defined in this list.
6342
7028
  * Only the "default" camera will be resized when the window or canvas is resized.
6343
7029
  * @public
6344
- * @type {Map}
7030
+ * @type {Map<Camera2d>}
6345
7031
  * @name cameras
6346
7032
  * @memberof Stage
6347
7033
  */
6348
- public cameras: Map<any, any>;
7034
+ public cameras: Map<Camera2d, any>;
6349
7035
  /**
6350
7036
  * The given constructor options
6351
7037
  * @public
@@ -8795,7 +9481,7 @@ export class WebGLRenderer extends Renderer {
8795
9481
  /**
8796
9482
  * The WebGL version used by this renderer (1 or 2)
8797
9483
  * @name WebGLVersion
8798
- * @memberof WebGLRenderer
9484
+ * @memberof WebGLRenderer#
8799
9485
  * @type {number}
8800
9486
  * @default 1
8801
9487
  * @readonly
@@ -8804,7 +9490,7 @@ export class WebGLRenderer extends Renderer {
8804
9490
  /**
8805
9491
  * The vendor string of the underlying graphics driver.
8806
9492
  * @name GPUVendor
8807
- * @memberof WebGLRenderer
9493
+ * @memberof WebGLRenderer#
8808
9494
  * @type {string}
8809
9495
  * @default null
8810
9496
  * @readonly
@@ -8813,7 +9499,7 @@ export class WebGLRenderer extends Renderer {
8813
9499
  /**
8814
9500
  * The renderer string of the underlying graphics driver.
8815
9501
  * @name GPURenderer
8816
- * @memberof WebGLRenderer
9502
+ * @memberof WebGLRenderer#
8817
9503
  * @type {string}
8818
9504
  * @default null
8819
9505
  * @readonly
@@ -8822,7 +9508,7 @@ export class WebGLRenderer extends Renderer {
8822
9508
  /**
8823
9509
  * The WebGL context
8824
9510
  * @name gl
8825
- * @memberof WebGLRenderer
9511
+ * @memberof WebGLRenderer#
8826
9512
  * type {WebGLRenderingContext}
8827
9513
  */
8828
9514
  context: WebGLRenderingContext;
@@ -8830,7 +9516,7 @@ export class WebGLRenderer extends Renderer {
8830
9516
  /**
8831
9517
  * Maximum number of texture unit supported under the current context
8832
9518
  * @name maxTextures
8833
- * @memberof WebGLRenderer
9519
+ * @memberof WebGLRenderer#
8834
9520
  * @type {number}
8835
9521
  * @readonly
8836
9522
  */
@@ -8851,10 +9537,6 @@ export class WebGLRenderer extends Renderer {
8851
9537
  * @ignore
8852
9538
  */
8853
9539
  _blendStack: any[];
8854
- /**
8855
- * @ignore
8856
- */
8857
- _glPoints: Vector2d[];
8858
9540
  /**
8859
9541
  * The current transformation matrix used for transformations on the overall scene
8860
9542
  * @name currentTransform
@@ -8872,10 +9554,10 @@ export class WebGLRenderer extends Renderer {
8872
9554
  /**
8873
9555
  * The list of active compositors
8874
9556
  * @name compositors
8875
- * @type {Map}
9557
+ * @type {Map<WebGLCompositor>}
8876
9558
  * @memberof WebGLRenderer#
8877
9559
  */
8878
- compositors: Map<any, any>;
9560
+ compositors: Map<WebGLCompositor, any>;
8879
9561
  cache: TextureCache;
8880
9562
  /**
8881
9563
  * set the active compositor for this renderer
@@ -9084,6 +9766,14 @@ export class WebGLRenderer extends Renderer {
9084
9766
  * @param {number} alpha 0.0 to 1.0 values accepted.
9085
9767
  */
9086
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;
9087
9777
  /**
9088
9778
  * Set the current fill & stroke style color.
9089
9779
  * By default, or upon reset, the value is set to #000000.
@@ -9127,7 +9817,7 @@ export class WebGLRenderer extends Renderer {
9127
9817
  * @param {number} end end angle in radians
9128
9818
  * @param {boolean} [antiClockwise=false] draw arc anti-clockwise
9129
9819
  */
9130
- 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;
9131
9821
  /**
9132
9822
  * Stroke an ellipse at the specified coordinates with given radius
9133
9823
  * @name strokeEllipse
@@ -9213,6 +9903,31 @@ export class WebGLRenderer extends Renderer {
9213
9903
  * @param {number} height
9214
9904
  */
9215
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;
9216
9931
  /**
9217
9932
  * Reset (overrides) the renderer transformation matrix to the
9218
9933
  * identity one, and then apply the given transformation matrix.
@@ -9306,9 +10021,9 @@ export class World extends Container {
9306
10021
  * @name bodies
9307
10022
  * @memberof World
9308
10023
  * @public
9309
- * @type {Set}
10024
+ * @type {Set<Body>}
9310
10025
  */
9311
- public bodies: Set<any>;
10026
+ public bodies: Set<Body>;
9312
10027
  /**
9313
10028
  * the instance of the game world quadtree used for broadphase
9314
10029
  * @name broadphase
@@ -10396,16 +11111,12 @@ export var plugin: any;
10396
11111
  * @namespace plugins
10397
11112
  */
10398
11113
  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
- }>;
11114
+ /**
11115
+ * a default global object pool instance
11116
+ * @public
11117
+ * @type {ObjectPool}
11118
+ */
11119
+ declare var pool$1: ObjectPool;
10409
11120
  export namespace save {
10410
11121
  /**
10411
11122
  * Add new keys to localStorage and set them to the given default values if they do not exist
@@ -11060,6 +11771,7 @@ declare class Bounds {
11060
11771
  * @param {Vector2d[]} [vertices] an array of me.Vector2d points
11061
11772
  */
11062
11773
  constructor(vertices?: Vector2d[]);
11774
+ _center: Vector2d;
11063
11775
  /**
11064
11776
  * @ignore
11065
11777
  */
@@ -11072,7 +11784,6 @@ declare class Bounds {
11072
11784
  x: number;
11073
11785
  y: number;
11074
11786
  };
11075
- _center: Vector2d;
11076
11787
  /**
11077
11788
  * reset the bound
11078
11789
  * @name clear
@@ -11488,6 +12199,137 @@ declare function round(num: number, dec?: number): number;
11488
12199
  * }
11489
12200
  */
11490
12201
  declare function toBeCloseTo(expected: number, actual: number, precision?: number): boolean;
12202
+ /**
12203
+ * @classdesc
12204
+ * a simplified path2d implementation, supporting only one path
12205
+ */
12206
+ declare class Path2D {
12207
+ /**
12208
+ * the points defining the current path
12209
+ * @public
12210
+ * @type {Vector2d[]}
12211
+ * @name points
12212
+ * @memberof Path2D#
12213
+ */
12214
+ public points: Vector2d[];
12215
+ /**
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#
12222
+ */
12223
+ public arcResolution: number;
12224
+ vertices: any[];
12225
+ /**
12226
+ * begin a new path
12227
+ * @name beginPath
12228
+ * @memberof Path2D.prototype
12229
+ * @function
12230
+ */
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;
12332
+ }
11491
12333
  /**
11492
12334
  * @classdesc
11493
12335
  * a Vertex Buffer object
@@ -12207,6 +13049,7 @@ declare function setGamepadDeadzone(value: number): void;
12207
13049
  */
12208
13050
  declare function addMapping(id: any, mapping: any): void;
12209
13051
  /**
13052
+ * @classdesc
12210
13053
  * This object is used for object pooling - a technique that might speed up your game if used properly.<br>
12211
13054
  * If some of your classes will be instantiated and removed a lot at a time, it is a
12212
13055
  * good idea to add the class to this object pool. A separate pool for that class
@@ -12217,96 +13060,93 @@ declare function addMapping(id: any, mapping: any): void;
12217
13060
  * which means, that on level loading the engine will try to instantiate every object
12218
13061
  * found in the map, based on the user defined name in each Object Properties<br>
12219
13062
  * <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;
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
+ }
12310
13150
  declare var agentUtils: Readonly<{
12311
13151
  __proto__: any;
12312
13152
  prefixed: typeof prefixed;
@@ -12599,4 +13439,4 @@ declare function defer(func: Function, thisArg: object, ...args: any[]): number;
12599
13439
  * @returns {Function} the function that will be throttled
12600
13440
  */
12601
13441
  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 };
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 };