melonjs 10.2.3 → 10.5.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 (96) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +3620 -3582
  3. package/dist/melonjs.min.js +5 -5
  4. package/dist/melonjs.module.d.ts +3646 -4545
  5. package/dist/melonjs.module.js +3912 -3521
  6. package/package.json +21 -20
  7. package/src/audio/audio.js +30 -31
  8. package/src/camera/camera2d.js +47 -58
  9. package/src/entity/entity.js +32 -38
  10. package/src/game.js +21 -22
  11. package/src/{shapes → geometries}/ellipse.js +40 -47
  12. package/src/{shapes → geometries}/line.js +9 -12
  13. package/src/{shapes → geometries}/poly.js +100 -53
  14. package/src/{shapes → geometries}/rectangle.js +42 -45
  15. package/src/index.js +14 -32
  16. package/src/input/gamepad.js +11 -10
  17. package/src/input/input.js +2 -3
  18. package/src/input/keyboard.js +113 -113
  19. package/src/input/pointer.js +61 -29
  20. package/src/input/pointerevent.js +92 -29
  21. package/src/lang/deprecated.js +83 -13
  22. package/src/level/level.js +23 -24
  23. package/src/level/tiled/TMXGroup.js +7 -9
  24. package/src/level/tiled/TMXLayer.js +30 -33
  25. package/src/level/tiled/TMXObject.js +59 -53
  26. package/src/level/tiled/TMXTile.js +18 -19
  27. package/src/level/tiled/TMXTileMap.js +40 -46
  28. package/src/level/tiled/TMXTileset.js +12 -16
  29. package/src/level/tiled/TMXTilesetGroup.js +9 -10
  30. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
  31. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
  32. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
  33. package/src/level/tiled/renderer/TMXRenderer.js +24 -26
  34. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
  35. package/src/loader/loader.js +17 -16
  36. package/src/loader/loadingscreen.js +2 -5
  37. package/src/math/color.js +47 -67
  38. package/src/math/math.js +15 -16
  39. package/src/math/matrix2.js +53 -59
  40. package/src/math/matrix3.js +56 -63
  41. package/src/math/observable_vector2.js +87 -77
  42. package/src/math/observable_vector3.js +97 -80
  43. package/src/math/vector2.js +107 -97
  44. package/src/math/vector3.js +116 -100
  45. package/src/particles/emitter.js +66 -76
  46. package/src/particles/particle.js +4 -6
  47. package/src/particles/particlecontainer.js +2 -4
  48. package/src/physics/body.js +49 -147
  49. package/src/physics/bounds.js +48 -50
  50. package/src/physics/collision.js +13 -14
  51. package/src/physics/detector.js +18 -17
  52. package/src/physics/quadtree.js +17 -20
  53. package/src/physics/sat.js +30 -30
  54. package/src/physics/world.js +24 -29
  55. package/src/plugin/plugin.js +11 -15
  56. package/src/renderable/GUI.js +41 -47
  57. package/src/renderable/collectable.js +5 -10
  58. package/src/renderable/colorlayer.js +10 -15
  59. package/src/renderable/container.js +87 -73
  60. package/src/renderable/dragndrop.js +224 -0
  61. package/src/renderable/imagelayer.js +25 -32
  62. package/src/renderable/nineslicesprite.js +41 -42
  63. package/src/renderable/renderable.js +113 -124
  64. package/src/renderable/sprite.js +62 -69
  65. package/src/renderable/trigger.js +26 -32
  66. package/src/state/stage.js +13 -18
  67. package/src/state/state.js +26 -27
  68. package/src/system/device.js +76 -133
  69. package/src/system/event.js +81 -70
  70. package/src/system/pooling.js +11 -12
  71. package/src/system/save.js +3 -4
  72. package/src/system/timer.js +19 -20
  73. package/src/text/bitmaptext.js +57 -55
  74. package/src/text/bitmaptextdata.js +10 -11
  75. package/src/text/glyph.js +3 -0
  76. package/src/text/text.js +49 -55
  77. package/src/tweens/easing.js +1 -1
  78. package/src/tweens/interpolation.js +1 -1
  79. package/src/tweens/tween.js +44 -46
  80. package/src/utils/agent.js +3 -4
  81. package/src/utils/array.js +4 -5
  82. package/src/utils/file.js +3 -4
  83. package/src/utils/function.js +4 -5
  84. package/src/utils/string.js +7 -9
  85. package/src/utils/utils.js +4 -5
  86. package/src/video/canvas/canvas_renderer.js +60 -62
  87. package/src/video/renderer.js +53 -58
  88. package/src/video/texture.js +98 -112
  89. package/src/video/texture_cache.js +26 -10
  90. package/src/video/video.js +15 -16
  91. package/src/video/webgl/buffer/vertex.js +2 -2
  92. package/src/video/webgl/glshader.js +37 -39
  93. package/src/video/webgl/webgl_compositor.js +128 -101
  94. package/src/video/webgl/webgl_renderer.js +126 -106
  95. package/src/entity/draggable.js +0 -139
  96. package/src/entity/droptarget.js +0 -109
@@ -1,139 +0,0 @@
1
- import Vector2d from "./../math/vector2.js";
2
- import * as input from "./../input/input.js";
3
- import * as event from "./../system/event.js";
4
- import Entity from "./entity.js";
5
-
6
- /**
7
- * Used to make a game entity draggable
8
- * @class
9
- * @extends me.Entity
10
- * @memberOf me
11
- * @constructor
12
- * @param {number} x the x coordinates of the entity object
13
- * @param {number} y the y coordinates of the entity object
14
- * @param {object} settings Entity properties (see {@link me.Entity})
15
- */
16
- class DraggableEntity extends Entity {
17
-
18
- /**
19
- * Constructor
20
- * @name init
21
- * @memberOf me.DraggableEntity
22
- * @function
23
- * @param {number} x the x postion of the entity
24
- * @param {number} y the y postion of the entity
25
- * @param {object} settings the additional entity settings
26
- */
27
- constructor(x, y, settings) {
28
- super(x, y, settings);
29
- this.dragging = false;
30
- this.dragId = null;
31
- this.grabOffset = new Vector2d(0, 0);
32
- this.onPointerEvent = input.registerPointerEvent;
33
- this.removePointerEvent = input.releasePointerEvent;
34
- this.initEvents();
35
- }
36
-
37
- /**
38
- * Initializes the events the modules needs to listen to
39
- * It translates the pointer events to me.events
40
- * in order to make them pass through the system and to make
41
- * this module testable. Then we subscribe this module to the
42
- * transformed events.
43
- * @name initEvents
44
- * @memberOf me.DraggableEntity
45
- * @function
46
- */
47
- initEvents() {
48
- /**
49
- * @ignore
50
- */
51
- this.mouseDown = function (e) {
52
- this.translatePointerEvent(e, event.DRAGSTART);
53
- };
54
- /**
55
- * @ignore
56
- */
57
- this.mouseUp = function (e) {
58
- this.translatePointerEvent(e, event.DRAGEND);
59
- };
60
- this.onPointerEvent("pointerdown", this, this.mouseDown.bind(this));
61
- this.onPointerEvent("pointerup", this, this.mouseUp.bind(this));
62
- this.onPointerEvent("pointercancel", this, this.mouseUp.bind(this));
63
- event.on(event.POINTERMOVE, this.dragMove, this);
64
- event.on(event.DRAGSTART, this.dragStart, this);
65
- event.on(event.DRAGEND, this.dragEnd, this);
66
- }
67
-
68
- /**
69
- * Translates a pointer event to a me.event
70
- * @name translatePointerEvent
71
- * @memberOf me.DraggableEntity
72
- * @function
73
- * @param {object} e the pointer event you want to translate
74
- * @param {string} translation the me.event you want to translate the event to
75
- */
76
- translatePointerEvent(e, translation) {
77
- event.emit(translation, e);
78
- }
79
-
80
- /**
81
- * Gets called when the user starts dragging the entity
82
- * @name dragStart
83
- * @memberOf me.DraggableEntity
84
- * @function
85
- * @param {object} e the pointer event
86
- * @returns {boolean} false if the object is being dragged
87
- */
88
- dragStart(e) {
89
- if (this.dragging === false) {
90
- this.dragging = true;
91
- this.grabOffset.set(e.gameX, e.gameY);
92
- this.grabOffset.sub(this.pos);
93
- return false;
94
- }
95
- }
96
-
97
- /**
98
- * Gets called when the user drags this entity around
99
- * @name dragMove
100
- * @memberOf me.DraggableEntity
101
- * @function
102
- * @param {object} e the pointer event
103
- */
104
- dragMove(e) {
105
- if (this.dragging === true) {
106
- this.pos.set(e.gameX, e.gameY, this.pos.z); //TODO : z ?
107
- this.pos.sub(this.grabOffset);
108
- }
109
- }
110
-
111
- /**
112
- * Gets called when the user stops dragging the entity
113
- * @name dragEnd
114
- * @memberOf me.DraggableEntity
115
- * @function
116
- * @returns {boolean} false if the object stopped being dragged
117
- */
118
- dragEnd() {
119
- if (this.dragging === true) {
120
- this.dragging = false;
121
- return false;
122
- }
123
- }
124
-
125
- /**
126
- * Destructor
127
- * @name destroy
128
- * @memberOf me.DraggableEntity
129
- * @function
130
- */
131
- destroy() {
132
- event.off(event.POINTERMOVE, this.dragMove);
133
- event.off(event.DRAGSTART, this.dragStart);
134
- event.off(event.DRAGEND, this.dragEnd);
135
- this.removePointerEvent("pointerdown", this);
136
- this.removePointerEvent("pointerup", this);
137
- }
138
- };
139
- export default DraggableEntity;
@@ -1,109 +0,0 @@
1
- import * as event from "./../system/event.js";
2
- import Entity from "./entity.js";
3
-
4
- /**
5
- * Used to make a game entity a droptarget
6
- * @class
7
- * @extends me.Entity
8
- * @memberOf me
9
- * @constructor
10
- * @param {number} x the x coordinates of the entity object
11
- * @param {number} y the y coordinates of the entity object
12
- * @param {object} settings Entity properties (see {@link me.Entity})
13
- */
14
-
15
- class DroptargetEntity extends Entity {
16
- /**
17
- * Constructor
18
- * @name init
19
- * @memberOf me.DroptargetEntity
20
- * @function
21
- * @param {number} x the x postion of the entity
22
- * @param {number} y the y postion of the entity
23
- * @param {object} settings the additional entity settings
24
- */
25
- constructor(x, y, settings) {
26
- super(x, y, settings);
27
- /**
28
- * constant for the overlaps method
29
- * @public
30
- * @constant
31
- * @type {string}
32
- * @name CHECKMETHOD_OVERLAP
33
- * @memberOf me.DroptargetEntity
34
- */
35
- this.CHECKMETHOD_OVERLAP = "overlaps";
36
- /**
37
- * constant for the contains method
38
- * @public
39
- * @constant
40
- * @type {string}
41
- * @name CHECKMETHOD_CONTAINS
42
- * @memberOf me.DroptargetEntity
43
- */
44
- this.CHECKMETHOD_CONTAINS = "contains";
45
- /**
46
- * the checkmethod we want to use
47
- * @public
48
- * @constant
49
- * @type {string}
50
- * @name checkMethod
51
- * @memberOf me.DroptargetEntity
52
- */
53
- this.checkMethod = null;
54
- event.on(event.DRAGEND, this.checkOnMe, this);
55
- this.checkMethod = this[this.CHECKMETHOD_OVERLAP];
56
- }
57
-
58
- /**
59
- * Sets the collision method which is going to be used to check a valid drop
60
- * @name setCheckMethod
61
- * @memberOf me.DroptargetEntity
62
- * @function
63
- * @param {string} checkMethod the checkmethod (defaults to CHECKMETHOD_OVERLAP)
64
- */
65
- setCheckMethod(checkMethod) {
66
- // We can improve this check,
67
- // because now you can use every method in theory
68
- if (typeof(this[checkMethod]) !== "undefined") {
69
- this.checkMethod = this[checkMethod];
70
- }
71
- }
72
-
73
- /**
74
- * Checks if a dropped entity is dropped on the current entity
75
- * @name checkOnMe
76
- * @memberOf me.DroptargetEntity
77
- * @function
78
- * @param {object} e the triggering event
79
- * @param {object} draggableEntity the draggable entity that is dropped
80
- */
81
- checkOnMe(e, draggableEntity) {
82
- if (draggableEntity && this.checkMethod(draggableEntity.getBounds())) {
83
- // call the drop method on the current entity
84
- this.drop(draggableEntity);
85
- }
86
- }
87
-
88
- /**
89
- * Gets called when a draggable entity is dropped on the current entity
90
- * @name drop
91
- * @memberOf me.DroptargetEntity
92
- * @function
93
- * @param {object} draggableEntity the draggable entity that is dropped
94
- */
95
- drop() {
96
-
97
- }
98
-
99
- /**
100
- * Destructor
101
- * @name destroy
102
- * @memberOf me.DroptargetEntity
103
- * @function
104
- */
105
- destroy() {
106
- event.off(event.DRAGEND, this.checkOnMe);
107
- }
108
- };
109
- export default DroptargetEntity;