melonjs 10.2.2 → 10.4.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 (95) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +2907 -3383
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3620 -4528
  5. package/dist/melonjs.module.js +3210 -3331
  6. package/package.json +19 -19
  7. package/src/audio/audio.js +30 -31
  8. package/src/camera/camera2d.js +47 -58
  9. package/src/entity/draggable.js +11 -21
  10. package/src/entity/droptarget.js +12 -22
  11. package/src/entity/entity.js +32 -38
  12. package/src/game.js +21 -22
  13. package/src/{shapes → geometries}/ellipse.js +40 -47
  14. package/src/{shapes → geometries}/line.js +9 -12
  15. package/src/{shapes → geometries}/poly.js +100 -53
  16. package/src/{shapes → geometries}/rectangle.js +42 -45
  17. package/src/index.js +9 -20
  18. package/src/input/gamepad.js +11 -10
  19. package/src/input/input.js +2 -3
  20. package/src/input/keyboard.js +113 -113
  21. package/src/input/pointer.js +61 -29
  22. package/src/input/pointerevent.js +92 -29
  23. package/src/lang/deprecated.js +44 -14
  24. package/src/level/level.js +23 -24
  25. package/src/level/tiled/TMXGroup.js +7 -9
  26. package/src/level/tiled/TMXLayer.js +30 -33
  27. package/src/level/tiled/TMXObject.js +59 -53
  28. package/src/level/tiled/TMXTile.js +18 -19
  29. package/src/level/tiled/TMXTileMap.js +38 -46
  30. package/src/level/tiled/TMXTileset.js +12 -16
  31. package/src/level/tiled/TMXTilesetGroup.js +9 -10
  32. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
  33. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
  34. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
  35. package/src/level/tiled/renderer/TMXRenderer.js +24 -26
  36. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
  37. package/src/loader/loader.js +17 -16
  38. package/src/loader/loadingscreen.js +8 -10
  39. package/src/math/color.js +47 -67
  40. package/src/math/math.js +15 -16
  41. package/src/math/matrix2.js +53 -59
  42. package/src/math/matrix3.js +56 -63
  43. package/src/math/observable_vector2.js +87 -77
  44. package/src/math/observable_vector3.js +97 -80
  45. package/src/math/vector2.js +107 -97
  46. package/src/math/vector3.js +116 -100
  47. package/src/particles/emitter.js +66 -76
  48. package/src/particles/particle.js +4 -6
  49. package/src/particles/particlecontainer.js +2 -4
  50. package/src/physics/body.js +47 -146
  51. package/src/physics/bounds.js +48 -50
  52. package/src/physics/collision.js +13 -14
  53. package/src/physics/detector.js +14 -14
  54. package/src/physics/quadtree.js +18 -21
  55. package/src/physics/sat.js +30 -30
  56. package/src/physics/world.js +24 -29
  57. package/src/plugin/plugin.js +11 -15
  58. package/src/renderable/GUI.js +41 -47
  59. package/src/renderable/collectable.js +5 -10
  60. package/src/renderable/colorlayer.js +10 -15
  61. package/src/renderable/container.js +87 -73
  62. package/src/renderable/imagelayer.js +25 -32
  63. package/src/renderable/nineslicesprite.js +41 -42
  64. package/src/renderable/renderable.js +113 -124
  65. package/src/renderable/sprite.js +62 -69
  66. package/src/renderable/trigger.js +26 -32
  67. package/src/state/stage.js +13 -18
  68. package/src/state/state.js +26 -27
  69. package/src/system/device.js +76 -133
  70. package/src/system/event.js +81 -70
  71. package/src/system/pooling.js +11 -12
  72. package/src/system/save.js +3 -4
  73. package/src/system/timer.js +19 -20
  74. package/src/text/bitmaptext.js +57 -55
  75. package/src/text/bitmaptextdata.js +10 -11
  76. package/src/text/glyph.js +3 -0
  77. package/src/text/text.js +49 -55
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +1 -1
  80. package/src/tweens/tween.js +44 -46
  81. package/src/utils/agent.js +3 -4
  82. package/src/utils/array.js +4 -5
  83. package/src/utils/file.js +3 -4
  84. package/src/utils/function.js +4 -5
  85. package/src/utils/string.js +7 -9
  86. package/src/utils/utils.js +4 -5
  87. package/src/video/canvas/canvas_renderer.js +60 -62
  88. package/src/video/renderer.js +53 -58
  89. package/src/video/texture.js +98 -112
  90. package/src/video/texture_cache.js +4 -6
  91. package/src/video/video.js +16 -17
  92. package/src/video/webgl/buffer/vertex.js +2 -2
  93. package/src/video/webgl/glshader.js +37 -39
  94. package/src/video/webgl/webgl_compositor.js +128 -110
  95. package/src/video/webgl/webgl_renderer.js +126 -106
@@ -6,37 +6,33 @@ import Sprite from "./sprite.js";
6
6
  * by proportionally scaling a sprite by splitting it in a grid of nine parts (with only parts 1, 3, 7, 9 not being scaled). <br>
7
7
  * <img src="images/9-slice-scaling.png"/><br>
8
8
  * @see https://en.wikipedia.org/wiki/9-slice_scaling
9
- * @class NineSliceSprite
10
- * @extends me.Sprite
11
- * @memberOf me
12
- * @constructor
13
- * @param {number} x the x coordinates of the sprite object
14
- * @param {number} y the y coordinates of the sprite object
15
- * @param {object} settings Configuration parameters for the Sprite object
16
- * @param {number} settings.width the width of the Renderable over which the sprite needs to be stretched
17
- * @param {number} settings.height the height of the Renderable over which the sprite needs to be stretched
18
- * @param {me.Renderer.Texture|HTMLImageElement|HTMLCanvasElement|string} settings.image reference to a texture, spritesheet image or to a texture atlas
19
- * @param {string} [settings.name=""] name of this object
20
- * @param {string} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
21
- * @param {number} [settings.framewidth] Width of a single frame within the spritesheet
22
- * @param {number} [settings.frameheight] Height of a single frame within the spritesheet
23
- * @param {string|me.Color} [settings.tint] a tint to be applied to this sprite
24
- * @param {number} [settings.flipX] flip the sprite on the horizontal axis
25
- * @param {number} [settings.flipY] flip the sprite on the vertical axis
26
- * @param {me.Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
27
- * @example
28
- * this.panelSprite = new me.NineSliceSprite(0, 0, {
29
- * image : game.texture,
30
- * region : "grey_panel",
31
- * width : this.width,
32
- * height : this.height
33
- * });
9
+ * @augments Sprite
34
10
  */
35
-
36
11
  class NineSliceSprite extends Sprite {
37
-
38
12
  /**
39
- * @ignore
13
+ * @param {number} x the x coordinates of the sprite object
14
+ * @param {number} y the y coordinates of the sprite object
15
+ * @param {object} settings Configuration parameters for the Sprite object
16
+ * @param {number} settings.width the width of the Renderable over which the sprite needs to be stretched
17
+ * @param {number} settings.height the height of the Renderable over which the sprite needs to be stretched
18
+ * @param {number} [settings.insetx] the width of a corner over which the sprite is unscaled (default is a quarter of the sprite width)
19
+ * @param {number} [settings.insety] the height of a corner over which the sprite is unscaled (default is a quarter of the sprite height)
20
+ * @param {HTMLImageElement|HTMLCanvasElement|TextureAtlas|string} settings.image reference to spritesheet image, a texture atlas or to a texture atlas
21
+ * @param {string} [settings.name=""] name of this object
22
+ * @param {string} [settings.region] region name of a specific region to use when using a texture atlas, see {@link TextureAtlas}
23
+ * @param {number} [settings.framewidth] Width of a single frame within the spritesheet
24
+ * @param {number} [settings.frameheight] Height of a single frame within the spritesheet
25
+ * @param {string|Color} [settings.tint] a tint to be applied to this sprite
26
+ * @param {number} [settings.flipX] flip the sprite on the horizontal axis
27
+ * @param {number} [settings.flipY] flip the sprite on the vertical axis
28
+ * @param {Vector2d} [settings.anchorPoint={x:0.5, y:0.5}] Anchor point to draw the frame at (defaults to the center of the frame).
29
+ * @example
30
+ * this.panelSprite = new me.NineSliceSprite(0, 0, {
31
+ * image : game.texture,
32
+ * region : "grey_panel",
33
+ * width : this.width,
34
+ * height : this.height
35
+ * });
40
36
  */
41
37
  constructor(x, y, settings) {
42
38
  // call the super constructor
@@ -47,10 +43,13 @@ class NineSliceSprite extends Sprite {
47
43
  throw new Error("height and width properties are mandatory");
48
44
  }
49
45
 
50
- // override the renderable sprite with the given one
51
- // resize based on the active frame
52
- this.width = settings.width;
53
- this.height = settings.height;
46
+ // nine slice sprite specific local variables
47
+ this.nss_width = Math.floor(settings.width);
48
+ this.nss_height = Math.floor(settings.height);
49
+
50
+ this.insetx = settings.insetx;
51
+ this.insety = settings.insety;
52
+
54
53
  }
55
54
 
56
55
  /**
@@ -85,8 +84,8 @@ class NineSliceSprite extends Sprite {
85
84
  sy = g_offset.y + frame_offset.y;
86
85
 
87
86
  // should this be configurable ?
88
- var corner_width = frame.width / 4,
89
- corner_height = frame.height / 4;
87
+ var corner_width = this.insetx || w / 4,
88
+ corner_height = this.insety || h / 4;
90
89
 
91
90
  // OPTIMIZE ME !
92
91
 
@@ -108,7 +107,7 @@ class NineSliceSprite extends Sprite {
108
107
  sx + w - corner_width, // sx
109
108
  sy, // sy
110
109
  corner_width, corner_height, // sw,sh
111
- dx + this.width - corner_width, // dx
110
+ dx + this.nss_width - corner_width, // dx
112
111
  dy, // dy
113
112
  corner_width, corner_height // dw,dh
114
113
  );
@@ -119,7 +118,7 @@ class NineSliceSprite extends Sprite {
119
118
  sy + h - corner_height, // sy
120
119
  corner_width, corner_height, // sw,sh
121
120
  dx, // dx
122
- dy + this.height - corner_height, // dy
121
+ dy + this.nss_height - corner_height, // dy
123
122
  corner_width, corner_height // dw,dh
124
123
  );
125
124
  // Bottom Right
@@ -128,8 +127,8 @@ class NineSliceSprite extends Sprite {
128
127
  sx + w - corner_width, // sx
129
128
  sy + h - corner_height, // sy
130
129
  corner_width, corner_height, // sw,sh
131
- dx + this.width - corner_width, //dx
132
- dy + this.height - corner_height, // dy
130
+ dx + this.nss_width - corner_width, //dx
131
+ dy + this.nss_height - corner_height, // dy
133
132
  corner_width, corner_height // dw,dh
134
133
  );
135
134
 
@@ -138,8 +137,8 @@ class NineSliceSprite extends Sprite {
138
137
  var image_center_width = w - (corner_width << 1);
139
138
  var image_center_height = h - (corner_height << 1);
140
139
 
141
- var target_center_width = this.width - (corner_width << 1);
142
- var target_center_height = this.height - (corner_height << 1);
140
+ var target_center_width = this.nss_width - (corner_width << 1);
141
+ var target_center_height = this.nss_height - (corner_height << 1);
143
142
 
144
143
  //Top center
145
144
  renderer.drawImage(
@@ -162,7 +161,7 @@ class NineSliceSprite extends Sprite {
162
161
  image_center_width, // sw
163
162
  corner_height, // sh
164
163
  dx + corner_width, // dx
165
- dy + this.height - corner_height, // dx
164
+ dy + this.nss_height - corner_height, // dx
166
165
  target_center_width, // dw
167
166
  corner_height // dh
168
167
  );
@@ -187,7 +186,7 @@ class NineSliceSprite extends Sprite {
187
186
  sy + corner_height, // sy
188
187
  corner_width, // sw
189
188
  image_center_height, // sh
190
- dx + this.width - corner_width, // dx
189
+ dx + this.nss_width - corner_width, // dx
191
190
  dy + corner_height, // dy
192
191
  corner_width, // dw
193
192
  target_center_height // dh