melonjs 10.12.0 → 13.0.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 (50) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/melonjs.js +22651 -22529
  4. package/dist/melonjs.min.js +5 -6
  5. package/dist/melonjs.module.d.ts +195 -195
  6. package/dist/melonjs.module.js +22107 -21977
  7. package/package.json +14 -14
  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 +8 -8
  16. package/src/lang/deprecated.js +0 -29
  17. package/src/level/level.js +2 -2
  18. package/src/level/tiled/TMXLayer.js +2 -2
  19. package/src/level/tiled/TMXTileMap.js +3 -3
  20. package/src/loader/loader.js +64 -28
  21. package/src/loader/loadingscreen.js +28 -115
  22. package/src/loader/melonjs_logo.png +0 -0
  23. package/src/physics/body.js +27 -51
  24. package/src/physics/detector.js +3 -3
  25. package/src/physics/quadtree.js +58 -29
  26. package/src/physics/world.js +32 -3
  27. package/src/polyfill/index.js +4 -0
  28. package/src/renderable/container.js +2 -2
  29. package/src/renderable/imagelayer.js +8 -8
  30. package/src/renderable/light2d.js +40 -11
  31. package/src/renderable/trigger.js +4 -4
  32. package/src/state/stage.js +1 -1
  33. package/src/state/state.js +50 -3
  34. package/src/system/device.js +808 -1039
  35. package/src/system/dom.js +69 -0
  36. package/src/system/event.js +13 -1
  37. package/src/system/platform.js +32 -0
  38. package/src/system/save.js +23 -14
  39. package/src/system/timer.js +12 -35
  40. package/src/text/bitmaptext.js +1 -2
  41. package/src/text/text.js +10 -14
  42. package/src/text/textmetrics.js +1 -2
  43. package/src/tweens/tween.js +6 -6
  44. package/src/utils/string.js +13 -24
  45. package/src/video/canvas/canvas_renderer.js +3 -2
  46. package/src/video/renderer.js +2 -2
  47. package/src/video/texture/canvas_texture.js +36 -2
  48. package/src/video/video.js +15 -9
  49. package/src/video/webgl/glshader.js +1 -1
  50. package/src/video/webgl/webgl_renderer.js +1 -1
@@ -3,8 +3,8 @@ import WebGLRenderer from "./webgl/webgl_renderer.js";
3
3
  import CanvasRenderer from "./canvas/canvas_renderer.js";
4
4
  import utils from "./../utils/utils.js";
5
5
  import * as event from "./../system/event.js";
6
- import { repaint } from "./../game.js";
7
- import device from "./../system/device.js";
6
+ import game from "./../game.js";
7
+ import * as device from "./../system/device.js";
8
8
  import { initialized, version } from "./../index.js";
9
9
 
10
10
  /**
@@ -302,7 +302,7 @@ export function init(width, height, options) {
302
302
  false
303
303
  );
304
304
 
305
- if (device.ScreenOrientation === true) {
305
+ if (device.screenOrientation === true) {
306
306
  globalThis.screen.orientation.onchange = function (e) {
307
307
  event.emit(event.WINDOW_ONORIENTATION_CHANGE, e);
308
308
  };
@@ -339,6 +339,12 @@ export function init(width, height, options) {
339
339
  parent = device.getElement(typeof settings.parent !== "undefined" ? settings.parent : document.body);
340
340
  parent.appendChild(renderer.getScreenCanvas());
341
341
 
342
+ // Mobile browser hacks
343
+ if (device.platform.isMobile) {
344
+ // Prevent the webview from moving on a swipe
345
+ device.enableSwipe(false);
346
+ }
347
+
342
348
  // trigger an initial resize();
343
349
  onresize();
344
350
 
@@ -362,7 +368,7 @@ export function init(width, height, options) {
362
368
  renderType + " renderer" + gpu_renderer + " | " +
363
369
  audioType + " | " +
364
370
  "pixel ratio " + device.devicePixelRatio + " | " +
365
- (device.nodeJS ? "node.js" : device.isMobile ? "mobile" : "desktop") + " | " +
371
+ (device.platform.nodeJS ? "node.js" : device.platform.isMobile ? "mobile" : "desktop") + " | " +
366
372
  device.getScreenOrientation() + " | " +
367
373
  device.language
368
374
  );
@@ -382,18 +388,18 @@ export function init(width, height, options) {
382
388
  * @function video.createCanvas
383
389
  * @param {number} width width
384
390
  * @param {number} height height
385
- * @param {boolean} [offscreenCanvas=false] will return an OffscreenCanvas if supported
391
+ * @param {boolean} [returnOffscreenCanvas=false] will return an OffscreenCanvas if supported
386
392
  * @returns {HTMLCanvasElement|OffscreenCanvas}
387
393
  */
388
- export function createCanvas(width, height, offscreenCanvas = false) {
394
+ export function createCanvas(width, height, returnOffscreenCanvas = false) {
389
395
  var _canvas;
390
396
 
391
397
  if (width === 0 || height === 0) {
392
398
  throw new Error("width or height was zero, Canvas could not be initialized !");
393
399
  }
394
400
 
395
- if (device.OffscreenCanvas === true && offscreenCanvas === true) {
396
- _canvas = new OffscreenCanvas(0, 0);
401
+ if (device.offscreenCanvas === true && returnOffscreenCanvas === true) {
402
+ _canvas = new globalThis.OffscreenCanvas(0, 0);
397
403
  // stubbing style for compatibility,
398
404
  // as OffscreenCanvas is detached from the DOM
399
405
  if (typeof _canvas.style === "undefined") {
@@ -448,5 +454,5 @@ export function scale(x, y) {
448
454
  renderer.setBlendMode(settings.blendMode, context);
449
455
 
450
456
  // force repaint
451
- repaint();
457
+ game.repaint();
452
458
  };
@@ -1,5 +1,5 @@
1
1
  import * as event from "./../../system/event.js";
2
- import device from "./../../system/device.js";
2
+ import * as device from "./../../system/device.js";
3
3
  import { extractUniforms } from "./utils/uniforms.js";
4
4
  import { extractAttributes } from "./utils/attributes.js";
5
5
  import { compileProgram } from "./utils/program.js";
@@ -20,7 +20,7 @@ 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
23
+ * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
24
24
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
25
25
  * @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
26
  * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)