melonjs 10.2.1 → 10.2.2

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 (90) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.js +2735 -2760
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +2186 -2162
  5. package/dist/melonjs.module.js +2323 -2362
  6. package/package.json +8 -9
  7. package/src/audio/audio.js +43 -43
  8. package/src/camera/camera2d.js +52 -74
  9. package/src/entity/draggable.js +18 -17
  10. package/src/entity/droptarget.js +19 -18
  11. package/src/entity/entity.js +22 -26
  12. package/src/game.js +2 -2
  13. package/src/index.js +11 -11
  14. package/src/input/gamepad.js +13 -13
  15. package/src/input/input.js +1 -1
  16. package/src/input/keyboard.js +14 -16
  17. package/src/input/pointer.js +42 -35
  18. package/src/input/pointerevent.js +18 -26
  19. package/src/lang/deprecated.js +3 -3
  20. package/src/level/level.js +24 -16
  21. package/src/level/tiled/TMXGroup.js +6 -6
  22. package/src/level/tiled/TMXLayer.js +31 -31
  23. package/src/level/tiled/TMXObject.js +19 -19
  24. package/src/level/tiled/TMXTile.js +11 -12
  25. package/src/level/tiled/TMXTileMap.js +23 -21
  26. package/src/level/tiled/TMXTileset.js +13 -13
  27. package/src/level/tiled/TMXTilesetGroup.js +4 -4
  28. package/src/level/tiled/TMXUtils.js +13 -11
  29. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  30. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  31. package/src/level/tiled/renderer/TMXRenderer.js +17 -17
  32. package/src/loader/loader.js +29 -25
  33. package/src/math/color.js +45 -64
  34. package/src/math/math.js +17 -17
  35. package/src/math/matrix2.js +46 -46
  36. package/src/math/matrix3.js +64 -64
  37. package/src/math/observable_vector2.js +45 -57
  38. package/src/math/observable_vector3.js +56 -70
  39. package/src/math/vector2.js +60 -59
  40. package/src/math/vector3.js +65 -64
  41. package/src/particles/emitter.js +53 -55
  42. package/src/particles/particle.js +1 -1
  43. package/src/physics/body.js +44 -44
  44. package/src/physics/bounds.js +34 -34
  45. package/src/physics/collision.js +15 -16
  46. package/src/physics/detector.js +10 -10
  47. package/src/physics/quadtree.js +19 -17
  48. package/src/physics/sat.js +17 -17
  49. package/src/physics/world.js +12 -10
  50. package/src/plugin/plugin.js +6 -6
  51. package/src/renderable/GUI.js +13 -18
  52. package/src/renderable/collectable.js +3 -3
  53. package/src/renderable/colorlayer.js +4 -4
  54. package/src/renderable/container.js +64 -46
  55. package/src/renderable/imagelayer.js +30 -31
  56. package/src/renderable/nineslicesprite.js +13 -13
  57. package/src/renderable/renderable.js +68 -66
  58. package/src/renderable/sprite.js +57 -43
  59. package/src/renderable/trigger.js +14 -15
  60. package/src/shapes/ellipse.js +27 -26
  61. package/src/shapes/line.js +8 -7
  62. package/src/shapes/poly.js +33 -31
  63. package/src/shapes/rectangle.js +50 -96
  64. package/src/state/stage.js +6 -6
  65. package/src/state/state.js +54 -54
  66. package/src/system/device.js +97 -84
  67. package/src/system/event.js +72 -72
  68. package/src/system/pooling.js +14 -14
  69. package/src/system/save.js +6 -3
  70. package/src/system/timer.js +20 -20
  71. package/src/text/bitmaptext.js +27 -33
  72. package/src/text/bitmaptextdata.js +9 -9
  73. package/src/text/text.js +39 -41
  74. package/src/tweens/easing.js +4 -4
  75. package/src/tweens/interpolation.js +4 -4
  76. package/src/tweens/tween.js +37 -27
  77. package/src/utils/agent.js +9 -8
  78. package/src/utils/array.js +4 -4
  79. package/src/utils/file.js +4 -4
  80. package/src/utils/function.js +5 -5
  81. package/src/utils/string.js +12 -12
  82. package/src/utils/utils.js +19 -19
  83. package/src/video/canvas/canvas_renderer.js +90 -90
  84. package/src/video/renderer.js +40 -39
  85. package/src/video/texture.js +74 -75
  86. package/src/video/video.js +30 -30
  87. package/src/video/webgl/buffer/vertex.js +9 -1
  88. package/src/video/webgl/glshader.js +20 -20
  89. package/src/video/webgl/webgl_compositor.js +33 -34
  90. package/src/video/webgl/webgl_renderer.js +104 -104
@@ -17,19 +17,19 @@ import Bounds from "./../physics/bounds.js";
17
17
  * @class Renderer
18
18
  * @memberOf me
19
19
  * @constructor
20
- * @param {Object} options The renderer parameters
21
- * @param {Number} options.width The width of the canvas without scaling
22
- * @param {Number} options.height The height of the canvas without scaling
20
+ * @param {object} options The renderer parameters
21
+ * @param {number} options.width The width of the canvas without scaling
22
+ * @param {number} options.height The height of the canvas without scaling
23
23
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
24
- * @param {Boolean} [options.doubleBuffering=false] Whether to enable double buffering
25
- * @param {Boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
26
- * @param {Boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
27
- * @param {Boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
28
- * @param {Boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
29
- * @param {Boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
30
- * @param {Boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
31
- * @param {Number} [options.zoomX=width] The actual width of the canvas with scaling applied
32
- * @param {Number} [options.zoomY=height] The actual height of the canvas with scaling applied
24
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
25
+ * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
26
+ * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
27
+ * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
28
+ * @param {boolean} [options.blendMode="normal"] the default blend mode to use ("normal", "multiply")
29
+ * @param {boolean} [options.subPixel=false] Whether to enable subpixel rendering (performance hit when enabled)
30
+ * @param {boolean} [options.verbose=false] Enable the verbose mode that provides additional details as to what the renderer is doing
31
+ * @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
32
+ * @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
33
33
  */
34
34
  class Renderer {
35
35
 
@@ -39,7 +39,7 @@ class Renderer {
39
39
  * @public
40
40
  * @name settings
41
41
  * @memberOf me.Renderer#
42
- * @enum {Object}
42
+ * @enum {object}
43
43
  */
44
44
  this.settings = options;
45
45
 
@@ -48,7 +48,7 @@ class Renderer {
48
48
  * @name isContextValid
49
49
  * @memberOf me.Renderer
50
50
  * @default true
51
- * type {Boolean}
51
+ * type {boolean}
52
52
  */
53
53
  this.isContextValid = true;
54
54
 
@@ -132,7 +132,7 @@ class Renderer {
132
132
  * @name getCanvas
133
133
  * @memberOf me.Renderer.prototype
134
134
  * @function
135
- * @return {HTMLCanvasElement}
135
+ * @returns {HTMLCanvasElement}
136
136
  */
137
137
  getCanvas() {
138
138
  return this.backBufferCanvas;
@@ -143,7 +143,7 @@ class Renderer {
143
143
  * @name getScreenCanvas
144
144
  * @memberOf me.Renderer.prototype
145
145
  * @function
146
- * @return {HTMLCanvasElement}
146
+ * @returns {HTMLCanvasElement}
147
147
  */
148
148
  getScreenCanvas() {
149
149
  return this.canvas;
@@ -155,7 +155,7 @@ class Renderer {
155
155
  * @name getScreenContext
156
156
  * @memberOf me.Renderer.prototype
157
157
  * @function
158
- * @return {Context2d}
158
+ * @returns {CanvasRenderingContext2D}
159
159
  */
160
160
  getScreenContext() {
161
161
  return this.context;
@@ -166,7 +166,7 @@ class Renderer {
166
166
  * @name getBlendMode
167
167
  * @memberOf me.Renderer.prototype
168
168
  * @function
169
- * @return {String} blend mode
169
+ * @returns {string} blend mode
170
170
  */
171
171
  getBlendMode() {
172
172
  return this.currentBlendMode;
@@ -179,18 +179,18 @@ class Renderer {
179
179
  * @memberOf me.Renderer.prototype
180
180
  * @function
181
181
  * @param {HTMLCanvasElement} canvas
182
- * @param {Boolean} [transparent=true] use false to disable transparency
183
- * @return {CanvasRenderingContext2D}
182
+ * @param {boolean} [transparent=true] use false to disable transparency
183
+ * @returns {CanvasRenderingContext2D}
184
184
  */
185
- getContext2d(c, transparent) {
186
- if (typeof c === "undefined" || c === null) {
185
+ getContext2d(canvas, transparent) {
186
+ if (typeof canvas === "undefined" || canvas === null) {
187
187
  throw new Error(
188
188
  "You must pass a canvas element in order to create " +
189
189
  "a 2d context"
190
190
  );
191
191
  }
192
192
 
193
- if (typeof c.getContext === "undefined") {
193
+ if (typeof canvas.getContext === "undefined") {
194
194
  throw new Error(
195
195
  "Your browser does not support HTML5 canvas."
196
196
  );
@@ -200,12 +200,12 @@ class Renderer {
200
200
  transparent = true;
201
201
  }
202
202
 
203
- var _context = c.getContext("2d", {
203
+ var _context = canvas.getContext("2d", {
204
204
  "alpha" : transparent
205
205
  });
206
206
 
207
207
  if (!_context.canvas) {
208
- _context.canvas = c;
208
+ _context.canvas = canvas;
209
209
  }
210
210
  this.setAntiAlias(_context, this.settings.antiAlias);
211
211
  return _context;
@@ -216,7 +216,7 @@ class Renderer {
216
216
  * @name getWidth
217
217
  * @memberOf me.Renderer.prototype
218
218
  * @function
219
- * @return {Number}
219
+ * @returns {number}
220
220
  */
221
221
  getWidth() {
222
222
  return this.backBufferCanvas.width;
@@ -227,7 +227,7 @@ class Renderer {
227
227
  * @name getHeight
228
228
  * @memberOf me.Renderer.prototype
229
229
  * @function
230
- * @return {Number}
230
+ * @returns {number} height of the system Canvas
231
231
  */
232
232
  getHeight() {
233
233
  return this.backBufferCanvas.height;
@@ -238,7 +238,7 @@ class Renderer {
238
238
  * @name getColor
239
239
  * @memberOf me.Renderer.prototype
240
240
  * @function
241
- * @param {me.Color} current global color
241
+ * @returns {me.Color} current global color
242
242
  */
243
243
  getColor() {
244
244
  return this.currentColor;
@@ -249,7 +249,7 @@ class Renderer {
249
249
  * @name globalAlpha
250
250
  * @memberOf me.Renderer.prototype
251
251
  * @function
252
- * @return {Number}
252
+ * @returns {number}
253
253
  */
254
254
  globalAlpha() {
255
255
  return this.currentColor.glArray[3];
@@ -261,7 +261,7 @@ class Renderer {
261
261
  * @memberOf me.Renderer.prototype
262
262
  * @function
263
263
  * @param {me.Rect|me.Bounds} bounds
264
- * @return {boolean} true if overlaps
264
+ * @returns {boolean} true if overlaps
265
265
  */
266
266
  overlaps(bounds) {
267
267
  return (
@@ -276,8 +276,8 @@ class Renderer {
276
276
  * @name resize
277
277
  * @memberOf me.Renderer.prototype
278
278
  * @function
279
- * @param {Number} width new width of the canvas
280
- * @param {Number} height new height of the canvas
279
+ * @param {number} width new width of the canvas
280
+ * @param {number} height new height of the canvas
281
281
  */
282
282
  resize(width, height) {
283
283
  if (width !== this.backBufferCanvas.width || height !== this.backBufferCanvas.height) {
@@ -297,8 +297,8 @@ class Renderer {
297
297
  * @name setAntiAlias
298
298
  * @memberOf me.Renderer.prototype
299
299
  * @function
300
- * @param {Context2d} context
301
- * @param {Boolean} [enable=false]
300
+ * @param {CanvasRenderingContext2D} context
301
+ * @param {boolean} [enable=false]
302
302
  */
303
303
  setAntiAlias(context, enable) {
304
304
  var canvas = context.canvas;
@@ -339,6 +339,7 @@ class Renderer {
339
339
  * @memberOf me.Renderer.prototype
340
340
  * @function
341
341
  * @param {me.Rect|me.Polygon|me.Line|me.Ellipse} shape a shape object to stroke
342
+ * @param {boolean} [fill=false] fill the shape with the current color if true
342
343
  */
343
344
  stroke(shape, fill) {
344
345
  if (shape instanceof Rect || shape instanceof Bounds) {
@@ -361,10 +362,10 @@ class Renderer {
361
362
  * @name tint
362
363
  * @memberOf me.Renderer.prototype
363
364
  * @function
364
- * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} image the source image to be tinted
365
- * @param {me.Color|String} color the color that will be used to tint the image
366
- * @param {String} [mode="multiply"] the composition mode used to tint the image
367
- * @return {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
365
+ * @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
366
+ * @param {me.Color|string} color the color that will be used to tint the image
367
+ * @param {string} [mode="multiply"] the composition mode used to tint the image
368
+ * @returns {HTMLCanvasElement|OffscreenCanvas} a new canvas element representing the tinted image
368
369
  */
369
370
  tint(src, color, mode) {
370
371
  var canvas = createCanvas(src.width, src.height, true);
@@ -423,7 +424,7 @@ class Renderer {
423
424
  * @memberOf me.Renderer.prototype
424
425
  * @function
425
426
  * @param {me.Color} tint the tint color
426
- * @param {Number} [alpha] an alpha value to be applied to the tint
427
+ * @param {number} [alpha] an alpha value to be applied to the tint
427
428
  */
428
429
  setTint(tint, alpha = tint.alpha) {
429
430
  // global tint color
@@ -8,62 +8,61 @@ import loader from "./../loader/loader.js";
8
8
  import { ETA } from "./../math/math.js";
9
9
 
10
10
  /**
11
- * @classdesc
12
- * A Texture atlas object, currently supports : <br>
13
- * - [TexturePacker]{@link http://www.codeandweb.com/texturepacker/} : through JSON export (standard and multipack texture atlas) <br>
14
- * - [ShoeBox]{@link http://renderhjs.net/shoebox/} : through JSON export using the
15
- * melonJS setting [file]{@link https://github.com/melonjs/melonJS/raw/master/media/shoebox_JSON_export.sbx} <br>
16
- * - [Free Texture Packer]{@link http://free-tex-packer.com/app/} : through JSON export (standard and multipack texture atlas) <br>
17
- * - Standard (fixed cell size) spritesheet : through a {framewidth:xx, frameheight:xx, anchorPoint:me.Vector2d} object
18
- * @class Texture
19
- * @memberOf me.Renderer
20
- * @constructor
21
- * @param {Object|Object[]} atlas atlas information. See {@link me.loader.getJSON}
22
- * @param {HTMLImageElement|HTMLCanvasElement|String|HTMLImageElement[]|HTMLCanvasElement[]|String[]} [source=atlas.meta.image] Image source
23
- * @param {Boolean} [cached=false] Use true to skip caching this Texture
24
- * @example
25
- * // create a texture atlas from a JSON Object
26
- * game.texture = new me.video.renderer.Texture(
27
- * me.loader.getJSON("texture")
28
- * );
29
- *
30
- * // create a texture atlas from a multipack JSON Object
31
- * game.texture = new me.video.renderer.Texture([
32
- * me.loader.getJSON("texture-0"),
33
- * me.loader.getJSON("texture-1"),
34
- * me.loader.getJSON("texture-2")
35
- * ]);
36
- *
37
- * // create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
38
- * game.texture = new me.video.renderer.Texture(
39
- * {
40
- * framewidth : 32,
41
- * frameheight : 32,
42
- * anchorPoint : new me.Vector2d(0.5, 0.5)
43
- * },
44
- * me.loader.getImage("spritesheet")
45
- * );
46
- */
47
-
48
- /**
49
- * create a simple 1 frame texture atlas based on the given parameters
50
- * @ignore
51
- */
11
+ * create a simple 1 frame texture atlas based on the given parameters
12
+ * @ignore
13
+ */
52
14
  export function createAtlas(width, height, name = "default", repeat = "no-repeat") {
53
- return {
54
- "meta" : {
55
- "app" : "melonJS",
56
- "size" : { "w" : width, "h" : height },
57
- "repeat" : repeat,
58
- "image" : "default"
59
- },
60
- "frames" : [{
61
- "filename" : name,
62
- "frame" : { "x" : 0, "y" : 0, "w" : width, "h" : height }
63
- }]
64
- };
15
+ return {
16
+ "meta" : {
17
+ "app" : "melonJS",
18
+ "size" : { "w" : width, "h" : height },
19
+ "repeat" : repeat,
20
+ "image" : "default"
21
+ },
22
+ "frames" : [{
23
+ "filename" : name,
24
+ "frame" : { "x" : 0, "y" : 0, "w" : width, "h" : height }
25
+ }]
26
+ };
65
27
  }
66
28
 
29
+ /**
30
+ * @classdesc
31
+ * A Texture atlas object, currently supports : <br>
32
+ * - [TexturePacker]{@link http://www.codeandweb.com/texturepacker/} : through JSON export (standard and multipack texture atlas) <br>
33
+ * - [ShoeBox]{@link http://renderhjs.net/shoebox/} : through JSON export using the
34
+ * melonJS setting [file]{@link https://github.com/melonjs/melonJS/raw/master/media/shoebox_JSON_export.sbx} <br>
35
+ * - [Free Texture Packer]{@link http://free-tex-packer.com/app/} : through JSON export (standard and multipack texture atlas) <br>
36
+ * - Standard (fixed cell size) spritesheet : through a {framewidth:xx, frameheight:xx, anchorPoint:me.Vector2d} object
37
+ * @class Texture
38
+ * @memberOf me.Renderer
39
+ * @constructor
40
+ * @param {object|object[]} atlases atlas information. See {@link me.loader.getJSON}
41
+ * @param {HTMLImageElement|HTMLCanvasElement|string|HTMLImageElement[]|HTMLCanvasElement[]|string[]} [src=atlas.meta.image] Image source
42
+ * @param {boolean} [cache=false] Use true to skip caching this Texture
43
+ * @example
44
+ * // create a texture atlas from a JSON Object
45
+ * game.texture = new me.video.renderer.Texture(
46
+ * me.loader.getJSON("texture")
47
+ * );
48
+ *
49
+ * // create a texture atlas from a multipack JSON Object
50
+ * game.texture = new me.video.renderer.Texture([
51
+ * me.loader.getJSON("texture-0"),
52
+ * me.loader.getJSON("texture-1"),
53
+ * me.loader.getJSON("texture-2")
54
+ * ]);
55
+ *
56
+ * // create a texture atlas for a spritesheet with an anchorPoint in the center of each frame
57
+ * game.texture = new me.video.renderer.Texture(
58
+ * {
59
+ * framewidth : 32,
60
+ * frameheight : 32,
61
+ * anchorPoint : new me.Vector2d(0.5, 0.5)
62
+ * },
63
+ * me.loader.getImage("spritesheet")
64
+ * );
65
+ */
67
66
  export class Texture {
68
67
 
69
68
  constructor (atlases, src, cache) {
@@ -75,14 +74,14 @@ export class Texture {
75
74
 
76
75
  /**
77
76
  * the texture source(s) itself
78
- * @type Map
77
+ * @type {Map}
79
78
  * @ignore
80
79
  */
81
80
  this.sources = new Map();
82
81
 
83
82
  /**
84
83
  * the atlas dictionnaries
85
- * @type Map
84
+ * @type {Map}
86
85
  * @ignore
87
86
  */
88
87
  this.atlases = new Map();
@@ -327,12 +326,12 @@ export class Texture {
327
326
  * @name getAtlas
328
327
  * @memberOf me.Renderer.Texture
329
328
  * @function
330
- * @param {String} [name] atlas name in case of multipack textures
331
- * @return {Object}
329
+ * @param {string} [name] atlas name in case of multipack textures
330
+ * @returns {object}
332
331
  */
333
- getAtlas(key) {
334
- if (typeof key === "string") {
335
- return this.atlases.get(key);
332
+ getAtlas(name) {
333
+ if (typeof name === "string") {
334
+ return this.atlases.get(name);
336
335
  } else {
337
336
  return this.atlases.values().next().value;
338
337
  }
@@ -343,7 +342,7 @@ export class Texture {
343
342
  * @name getFormat
344
343
  * @memberOf me.Renderer.Texture
345
344
  * @function
346
- * @return {String} will return "texturepacker", or "ShoeBox", or "melonJS", or "Spritesheet (fixed cell size)"
345
+ * @returns {string} will return "texturepacker", or "ShoeBox", or "melonJS", or "Spritesheet (fixed cell size)"
347
346
  */
348
347
  getFormat() {
349
348
  return this.format;
@@ -354,8 +353,8 @@ export class Texture {
354
353
  * @name getTexture
355
354
  * @memberOf me.Renderer.Texture
356
355
  * @function
357
- * @param {Object} [region] region name in case of multipack textures
358
- * @return {HTMLImageElement|HTMLCanvasElement}
356
+ * @param {object} [region] region name in case of multipack textures
357
+ * @returns {HTMLImageElement|HTMLCanvasElement}
359
358
  */
360
359
  getTexture(region) {
361
360
  if ((typeof region === "object") && (typeof region.texture === "string")) {
@@ -370,9 +369,9 @@ export class Texture {
370
369
  * @name getRegion
371
370
  * @memberOf me.Renderer.Texture
372
371
  * @function
373
- * @param {String} name name of the sprite
374
- * @param {String} [atlas] name of a specific atlas where to search for the region
375
- * @return {Object}
372
+ * @param {string} name name of the sprite
373
+ * @param {string} [atlas] name of a specific atlas where to search for the region
374
+ * @returns {object}
376
375
  */
377
376
  getRegion(name, atlas) {
378
377
  var region;
@@ -395,8 +394,8 @@ export class Texture {
395
394
  * @name getUVs
396
395
  * @memberOf me.Renderer.Texture
397
396
  * @function
398
- * @param {Object} region region (or frame) name
399
- * @return {Float32Array} region Uvs
397
+ * @param {object} name region (or frame) name
398
+ * @returns {Float32Array} region Uvs
400
399
  */
401
400
  getUVs(name) {
402
401
  // Get the source texture region
@@ -419,10 +418,10 @@ export class Texture {
419
418
  * @name createSpriteFromName
420
419
  * @memberOf me.Renderer.Texture
421
420
  * @function
422
- * @param {String} name name of the sprite
423
- * @param {Object} [settings] Additional settings passed to the {@link me.Sprite} contructor
424
- * @param {Boolean} [nineSlice=false] if true returns a 9-slice sprite
425
- * @return {me.Sprite|me.NineSliceSprite}
421
+ * @param {string} name name of the sprite
422
+ * @param {object} [settings] Additional settings passed to the {@link me.Sprite} contructor
423
+ * @param {boolean} [nineSlice=false] if true returns a 9-slice sprite
424
+ * @returns {me.Sprite|me.NineSliceSprite}
426
425
  * @example
427
426
  * // create a new texture object under the `game` namespace
428
427
  * game.texture = new me.video.renderer.Texture(
@@ -462,10 +461,10 @@ export class Texture {
462
461
  * @name createAnimationFromName
463
462
  * @memberOf me.Renderer.Texture
464
463
  * @function
465
- * @param {String[]|Number[]} names list of names for each sprite
464
+ * @param {string[]|number[]} names list of names for each sprite
466
465
  * (when manually creating a Texture out of a spritesheet, only numeric values are authorized)
467
- * @param {Object} [settings] Additional settings passed to the {@link me.Sprite} contructor
468
- * @return {me.Sprite}
466
+ * @param {object} [settings] Additional settings passed to the {@link me.Sprite} contructor
467
+ * @returns {me.Sprite}
469
468
  * @example
470
469
  * // create a new texture object under the `game` namespace
471
470
  * game.texture = new me.video.renderer.Texture(
@@ -192,20 +192,20 @@ export let renderer = null;
192
192
  * - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
193
193
  * <center><img src="images/scale-stretch.png"/></center><br>
194
194
  * @function me.video.init
195
- * @param {Number} width The width of the canvas viewport
196
- * @param {Number} height The height of the canvas viewport
197
- * @param {Object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
198
- * @param {String|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
199
- * @param {Number} [options.renderer=me.video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
200
- * @param {Boolean} [options.doubleBuffering=false] enable/disable double buffering
201
- * @param {Number|String} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
202
- * @param {String} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
203
- * @param {Boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
204
- * @param {String} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
205
- * @param {Boolean} [options.transparent=false] whether to allow transparent pixels in the front buffer (screen).
206
- * @param {Boolean} [options.antiAlias=false] whether to enable or not video scaling interpolation
207
- * @param {Boolean} [options.consoleHeader=true] whether to display melonJS version and basic device information in the console
208
- * @return {Boolean} false if initialization failed (canvas not supported)
195
+ * @param {number} width The width of the canvas viewport
196
+ * @param {number} height The height of the canvas viewport
197
+ * @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
198
+ * @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
199
+ * @param {number} [options.renderer=me.video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
200
+ * @param {boolean} [options.doubleBuffering=false] enable/disable double buffering
201
+ * @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
202
+ * @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
203
+ * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
204
+ * @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
205
+ * @param {boolean} [options.transparent=false] whether to allow transparent pixels in the front buffer (screen).
206
+ * @param {boolean} [options.antiAlias=false] whether to enable or not video scaling interpolation
207
+ * @param {boolean} [options.consoleHeader=true] whether to display melonJS version and basic device information in the console
208
+ * @returns {boolean} false if initialization failed (canvas not supported)
209
209
  * @example
210
210
  * // init the video with a 640x480 canvas
211
211
  * me.video.init(640, 480, {
@@ -216,7 +216,7 @@ export let renderer = null;
216
216
  * doubleBuffering : true
217
217
  * });
218
218
  */
219
- export function init(game_width, game_height, options) {
219
+ export function init(width, height, options) {
220
220
 
221
221
  // ensure melonjs has been properly initialized
222
222
  if (!initialized) {
@@ -227,8 +227,8 @@ export function init(game_width, game_height, options) {
227
227
  settings = Object.assign(settings, options || {});
228
228
 
229
229
  // sanitize potential given parameters
230
- settings.width = game_width;
231
- settings.height = game_height;
230
+ settings.width = width;
231
+ settings.height = height;
232
232
  settings.doubleBuffering = !!(settings.doubleBuffering);
233
233
  settings.transparent = !!(settings.transparent);
234
234
  settings.antiAlias = !!(settings.antiAlias);
@@ -268,13 +268,13 @@ export function init(game_width, game_height, options) {
268
268
  }
269
269
 
270
270
  // hold the requested video size ratio
271
- designRatio = game_width / game_height;
272
- designWidth = game_width;
273
- designHeight = game_height;
271
+ designRatio = width / height;
272
+ designWidth = width;
273
+ designHeight = height;
274
274
 
275
275
  // default scaled size value
276
- settings.zoomX = game_width * scaleRatio.x;
277
- settings.zoomY = game_height * scaleRatio.y;
276
+ settings.zoomX = width * scaleRatio.x;
277
+ settings.zoomY = width * scaleRatio.y;
278
278
 
279
279
  //add a channel for the onresize/onorientationchange event
280
280
  window.addEventListener(
@@ -367,7 +367,7 @@ export function init(game_width, game_height, options) {
367
367
  device.getScreenOrientation() + " | " +
368
368
  device.language
369
369
  );
370
- console.log( "resolution: " + "requested " + game_width + "x" + game_height +
370
+ console.log( "resolution: " + "requested " + width + "x" + height +
371
371
  ", got " + renderer.getWidth() + "x" + renderer.getHeight()
372
372
  );
373
373
  }
@@ -381,10 +381,10 @@ export function init(game_width, game_height, options) {
381
381
  /**
382
382
  * Create and return a new Canvas element
383
383
  * @function me.video.createCanvas
384
- * @param {Number} width width
385
- * @param {Number} height height
386
- * @param {Boolean} [offscreen=false] will returns an OffscreenCanvas if supported
387
- * @return {HTMLCanvasElement|OffscreenCanvas}
384
+ * @param {number} width width
385
+ * @param {number} height height
386
+ * @param {boolean} [offscreen=false] will returns an OffscreenCanvas if supported
387
+ * @returns {HTMLCanvasElement|OffscreenCanvas}
388
388
  */
389
389
  export function createCanvas(width, height, offscreen) {
390
390
  var _canvas;
@@ -413,7 +413,7 @@ export function createCanvas(width, height, offscreen) {
413
413
  /**
414
414
  * return a reference to the parent DOM element holding the main canvas
415
415
  * @function me.video.getParent
416
- * @return {HTMLElement}
416
+ * @returns {HTMLElement}
417
417
  */
418
418
  export function getParent() {
419
419
  return parent;
@@ -425,8 +425,8 @@ export function getParent() {
425
425
  * Only use this if you are not using the automatic scaling feature.
426
426
  * @function me.video.scale
427
427
  * @see me.video.init
428
- * @param {Number} x x scaling multiplier
429
- * @param {Number} y y scaling multiplier
428
+ * @param {number} x x scaling multiplier
429
+ * @param {number} y y scaling multiplier
430
430
  */
431
431
  export function scale(x, y) {
432
432
  var canvas = renderer.getScreenCanvas();
@@ -2,7 +2,7 @@
2
2
  * @classdesc
3
3
  * a Vertex Buffer object
4
4
  * @class VertexArrayBuffer
5
- * @private
5
+ * @ignore
6
6
  */
7
7
 
8
8
  class VertexArrayBuffer {
@@ -29,6 +29,7 @@ class VertexArrayBuffer {
29
29
 
30
30
  /**
31
31
  * clear the vertex array buffer
32
+ * @ignore
32
33
  */
33
34
  clear() {
34
35
  this.vertexCount = 0;
@@ -37,6 +38,7 @@ class VertexArrayBuffer {
37
38
 
38
39
  /**
39
40
  * return true if full
41
+ * @ignore
40
42
  */
41
43
  isFull(vertex = 0) {
42
44
  return (this.vertexCount + vertex >= this.maxVertex);
@@ -44,6 +46,7 @@ class VertexArrayBuffer {
44
46
 
45
47
  /**
46
48
  * resize the vertex buffer, retaining its original contents
49
+ * @ignore
47
50
  */
48
51
  resize() {
49
52
  // double the vertex size
@@ -64,6 +67,7 @@ class VertexArrayBuffer {
64
67
 
65
68
  /**
66
69
  * push a new vertex to the buffer
70
+ * @ignore
67
71
  */
68
72
  push(x, y, u, v, tint) {
69
73
  var offset = this.vertexCount * this.vertexSize;
@@ -91,6 +95,7 @@ class VertexArrayBuffer {
91
95
 
92
96
  /**
93
97
  * return a reference to the data in Float32 format
98
+ * @ignore
94
99
  */
95
100
  toFloat32(begin, end) {
96
101
  if (typeof end !== "undefined") {
@@ -102,6 +107,7 @@ class VertexArrayBuffer {
102
107
 
103
108
  /**
104
109
  * return a reference to the data in Uint32 format
110
+ * @ignore
105
111
  */
106
112
  toUint32(begin, end) {
107
113
  if (typeof end !== "undefined") {
@@ -113,6 +119,7 @@ class VertexArrayBuffer {
113
119
 
114
120
  /**
115
121
  * return the size of the vertex in vertex
122
+ * @ignore
116
123
  */
117
124
  length() {
118
125
  return this.vertexCount;
@@ -120,6 +127,7 @@ class VertexArrayBuffer {
120
127
 
121
128
  /**
122
129
  * return true if empty
130
+ * @ignore
123
131
  */
124
132
  isEmpty() {
125
133
  return this.vertexCount === 0;