melonjs 11.0.0 → 13.1.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 (58) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/melonjs.js +22854 -22604
  4. package/dist/melonjs.min.js +5 -6
  5. package/dist/melonjs.module.d.ts +289 -284
  6. package/dist/melonjs.module.js +22427 -22175
  7. package/package.json +16 -16
  8. package/src/application/application.js +231 -0
  9. package/src/audio/audio.js +13 -7
  10. package/src/camera/camera2d.js +6 -6
  11. package/src/game.js +9 -232
  12. package/src/index.js +3 -3
  13. package/src/input/keyboard.js +2 -2
  14. package/src/input/pointer.js +4 -5
  15. package/src/input/pointerevent.js +10 -10
  16. package/src/lang/deprecated.js +27 -30
  17. package/src/level/level.js +2 -2
  18. package/src/level/tiled/TMXGroup.js +10 -0
  19. package/src/level/tiled/TMXLayer.js +11 -2
  20. package/src/level/tiled/TMXObject.js +13 -2
  21. package/src/level/tiled/TMXTileMap.js +15 -3
  22. package/src/level/tiled/TMXTileset.js +8 -0
  23. package/src/loader/loader.js +64 -28
  24. package/src/loader/loadingscreen.js +28 -115
  25. package/src/loader/melonjs_logo.png +0 -0
  26. package/src/math/color.js +62 -42
  27. package/src/math/observable_vector2.js +26 -2
  28. package/src/math/observable_vector3.js +32 -4
  29. package/src/math/vector2.js +23 -0
  30. package/src/math/vector3.js +26 -0
  31. package/src/physics/body.js +27 -51
  32. package/src/physics/detector.js +3 -3
  33. package/src/physics/quadtree.js +58 -29
  34. package/src/physics/world.js +32 -3
  35. package/src/polyfill/index.js +4 -0
  36. package/src/renderable/container.js +2 -2
  37. package/src/renderable/imagelayer.js +8 -8
  38. package/src/renderable/nineslicesprite.js +27 -1
  39. package/src/renderable/trigger.js +4 -4
  40. package/src/state/stage.js +1 -1
  41. package/src/state/state.js +50 -3
  42. package/src/system/device.js +814 -981
  43. package/src/system/event.js +2 -1
  44. package/src/system/platform.js +32 -0
  45. package/src/system/save.js +23 -14
  46. package/src/system/timer.js +12 -35
  47. package/src/text/bitmaptext.js +1 -2
  48. package/src/text/text.js +10 -14
  49. package/src/text/textmetrics.js +1 -2
  50. package/src/tweens/tween.js +6 -6
  51. package/src/utils/string.js +13 -24
  52. package/src/video/canvas/canvas_renderer.js +30 -65
  53. package/src/video/renderer.js +23 -30
  54. package/src/video/texture/canvas_texture.js +39 -3
  55. package/src/video/video.js +27 -25
  56. package/src/video/webgl/glshader.js +1 -1
  57. package/src/video/webgl/webgl_compositor.js +2 -2
  58. package/src/video/webgl/webgl_renderer.js +8 -20
@@ -20,7 +20,6 @@ class WebGLRenderer extends Renderer {
20
20
  * @param {number} options.width The width of the canvas without scaling
21
21
  * @param {number} options.height The height of the canvas without scaling
22
22
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
23
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
24
23
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
25
24
  * @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.
26
25
  * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
@@ -72,7 +71,7 @@ class WebGLRenderer extends Renderer {
72
71
  * @memberof WebGLRenderer
73
72
  * @type {WebGLRenderingContext}
74
73
  */
75
- this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
74
+ this.context = this.gl = this.getContextGL(this.getCanvas(), options.transparent);
76
75
 
77
76
  /**
78
77
  * Maximum number of texture unit supported under the current context
@@ -154,13 +153,13 @@ class WebGLRenderer extends Renderer {
154
153
  // to simulate context lost and restore in WebGL:
155
154
  // var ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
156
155
  // ctx.loseContext()
157
- this.getScreenCanvas().addEventListener("webglcontextlost", (e) => {
156
+ this.getCanvas().addEventListener("webglcontextlost", (e) => {
158
157
  e.preventDefault();
159
158
  this.isContextValid = false;
160
159
  event.emit(event.ONCONTEXT_LOST, this);
161
160
  }, false );
162
161
  // ctx.restoreContext()
163
- this.getScreenCanvas().addEventListener("webglcontextrestored", () => {
162
+ this.getCanvas().addEventListener("webglcontextrestored", () => {
164
163
  this.reset();
165
164
  this.isContextValid = true;
166
165
  event.emit(event.ONCONTEXT_RESTORED, this);
@@ -231,7 +230,7 @@ class WebGLRenderer extends Renderer {
231
230
  */
232
231
  createFontTexture(cache) {
233
232
  if (typeof this.fontTexture === "undefined") {
234
- var canvas = this.backBufferCanvas;
233
+ var canvas = this.getCanvas();
235
234
  var width = canvas.width;
236
235
  var height = canvas.height;
237
236
 
@@ -459,17 +458,6 @@ class WebGLRenderer extends Renderer {
459
458
  this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
460
459
  }
461
460
 
462
-
463
- /**
464
- * return a reference to the screen canvas corresponding WebGL Context
465
- * @name getScreenContext
466
- * @memberof WebGLRenderer
467
- * @returns {WebGLRenderingContext}
468
- */
469
- getScreenContext() {
470
- return this.gl;
471
- }
472
-
473
461
  /**
474
462
  * Returns the WebGL Context object of the given Canvas
475
463
  * @name getContextGL
@@ -627,8 +615,8 @@ class WebGLRenderer extends Renderer {
627
615
  this.gl.disable(this.gl.SCISSOR_TEST);
628
616
  this.currentScissor[0] = 0;
629
617
  this.currentScissor[1] = 0;
630
- this.currentScissor[2] = this.backBufferCanvas.width;
631
- this.currentScissor[3] = this.backBufferCanvas.height;
618
+ this.currentScissor[2] = this.getCanvas().width;
619
+ this.currentScissor[3] = this.getCanvas().height;
632
620
  }
633
621
  }
634
622
 
@@ -719,7 +707,7 @@ class WebGLRenderer extends Renderer {
719
707
  * @param {number} width Line width
720
708
  */
721
709
  setLineWidth(width) {
722
- this.getScreenContext().lineWidth(width);
710
+ this.getContext().lineWidth(width);
723
711
  }
724
712
 
725
713
  /**
@@ -1015,7 +1003,7 @@ class WebGLRenderer extends Renderer {
1015
1003
  * @param {number} height
1016
1004
  */
1017
1005
  clipRect(x, y, width, height) {
1018
- var canvas = this.backBufferCanvas;
1006
+ var canvas = this.getCanvas();
1019
1007
  var gl = this.gl;
1020
1008
  // if requested box is different from the current canvas size
1021
1009
  if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {