melonjs 10.3.0 → 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 (94) hide show
  1. package/README.md +6 -6
  2. package/dist/melonjs.js +2419 -3072
  3. package/dist/melonjs.min.js +3 -3
  4. package/dist/melonjs.module.d.ts +3417 -3816
  5. package/dist/melonjs.module.js +2737 -3002
  6. package/package.json +16 -16
  7. package/src/audio/audio.js +29 -30
  8. package/src/camera/camera2d.js +46 -56
  9. package/src/entity/draggable.js +12 -13
  10. package/src/entity/droptarget.js +13 -15
  11. package/src/entity/entity.js +30 -36
  12. package/src/game.js +21 -22
  13. package/src/geometries/ellipse.js +40 -46
  14. package/src/geometries/line.js +9 -11
  15. package/src/geometries/poly.js +53 -53
  16. package/src/geometries/rectangle.js +42 -44
  17. package/src/index.js +4 -14
  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 +30 -31
  22. package/src/input/pointerevent.js +26 -26
  23. package/src/lang/deprecated.js +25 -6
  24. package/src/level/level.js +23 -24
  25. package/src/level/tiled/TMXGroup.js +7 -8
  26. package/src/level/tiled/TMXLayer.js +30 -32
  27. package/src/level/tiled/TMXObject.js +21 -21
  28. package/src/level/tiled/TMXTile.js +18 -18
  29. package/src/level/tiled/TMXTileMap.js +37 -44
  30. package/src/level/tiled/TMXTileset.js +12 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +9 -9
  32. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
  33. package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
  34. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
  35. package/src/level/tiled/renderer/TMXRenderer.js +24 -25
  36. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
  37. package/src/loader/loader.js +14 -15
  38. package/src/loader/loadingscreen.js +2 -4
  39. package/src/math/color.js +47 -66
  40. package/src/math/math.js +15 -16
  41. package/src/math/matrix2.js +53 -58
  42. package/src/math/matrix3.js +56 -62
  43. package/src/math/observable_vector2.js +75 -76
  44. package/src/math/observable_vector3.js +79 -80
  45. package/src/math/vector2.js +91 -92
  46. package/src/math/vector3.js +94 -96
  47. package/src/particles/emitter.js +38 -40
  48. package/src/particles/particle.js +4 -5
  49. package/src/particles/particlecontainer.js +2 -3
  50. package/src/physics/body.js +44 -142
  51. package/src/physics/bounds.js +47 -47
  52. package/src/physics/collision.js +13 -14
  53. package/src/physics/detector.js +14 -14
  54. package/src/physics/quadtree.js +17 -19
  55. package/src/physics/sat.js +26 -26
  56. package/src/physics/world.js +24 -28
  57. package/src/plugin/plugin.js +11 -14
  58. package/src/renderable/GUI.js +41 -46
  59. package/src/renderable/collectable.js +4 -8
  60. package/src/renderable/colorlayer.js +6 -10
  61. package/src/renderable/container.js +87 -72
  62. package/src/renderable/imagelayer.js +25 -31
  63. package/src/renderable/nineslicesprite.js +41 -41
  64. package/src/renderable/renderable.js +112 -122
  65. package/src/renderable/sprite.js +62 -68
  66. package/src/renderable/trigger.js +25 -30
  67. package/src/state/stage.js +13 -17
  68. package/src/state/state.js +26 -27
  69. package/src/system/device.js +74 -75
  70. package/src/system/event.js +71 -72
  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 -54
  75. package/src/text/bitmaptextdata.js +10 -10
  76. package/src/text/glyph.js +3 -0
  77. package/src/text/text.js +44 -49
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +1 -1
  80. package/src/tweens/tween.js +43 -44
  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 +58 -59
  88. package/src/video/renderer.js +49 -53
  89. package/src/video/texture.js +98 -111
  90. package/src/video/texture_cache.js +2 -2
  91. package/src/video/video.js +15 -16
  92. package/src/video/webgl/glshader.js +37 -38
  93. package/src/video/webgl/webgl_compositor.js +31 -32
  94. package/src/video/webgl/webgl_renderer.js +79 -80
@@ -6,36 +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
- * @augments me.Sprite
11
- * @memberof me
12
- * @param {number} x the x coordinates of the sprite object
13
- * @param {number} y the y coordinates of the sprite object
14
- * @param {object} settings Configuration parameters for the Sprite object
15
- * @param {number} settings.width the width of the Renderable over which the sprite needs to be stretched
16
- * @param {number} settings.height the height of the Renderable over which the sprite needs to be stretched
17
- * @param {me.Renderer.Texture|HTMLImageElement|HTMLCanvasElement|string} settings.image reference to a texture, spritesheet image or to a texture atlas
18
- * @param {string} [settings.name=""] name of this object
19
- * @param {string} [settings.region] region name of a specific region to use when using a texture atlas, see {@link me.Renderer.Texture}
20
- * @param {number} [settings.framewidth] Width of a single frame within the spritesheet
21
- * @param {number} [settings.frameheight] Height of a single frame within the spritesheet
22
- * @param {string|me.Color} [settings.tint] a tint to be applied to this sprite
23
- * @param {number} [settings.flipX] flip the sprite on the horizontal axis
24
- * @param {number} [settings.flipY] flip the sprite on the vertical axis
25
- * @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).
26
- * @example
27
- * this.panelSprite = new me.NineSliceSprite(0, 0, {
28
- * image : game.texture,
29
- * region : "grey_panel",
30
- * width : this.width,
31
- * height : this.height
32
- * });
9
+ * @augments Sprite
33
10
  */
34
-
35
11
  class NineSliceSprite extends Sprite {
36
-
37
12
  /**
38
- * @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
+ * });
39
36
  */
40
37
  constructor(x, y, settings) {
41
38
  // call the super constructor
@@ -46,10 +43,13 @@ class NineSliceSprite extends Sprite {
46
43
  throw new Error("height and width properties are mandatory");
47
44
  }
48
45
 
49
- // override the renderable sprite with the given one
50
- // resize based on the active frame
51
- this.width = settings.width;
52
- 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
+
53
53
  }
54
54
 
55
55
  /**
@@ -84,8 +84,8 @@ class NineSliceSprite extends Sprite {
84
84
  sy = g_offset.y + frame_offset.y;
85
85
 
86
86
  // should this be configurable ?
87
- var corner_width = frame.width / 4,
88
- corner_height = frame.height / 4;
87
+ var corner_width = this.insetx || w / 4,
88
+ corner_height = this.insety || h / 4;
89
89
 
90
90
  // OPTIMIZE ME !
91
91
 
@@ -107,7 +107,7 @@ class NineSliceSprite extends Sprite {
107
107
  sx + w - corner_width, // sx
108
108
  sy, // sy
109
109
  corner_width, corner_height, // sw,sh
110
- dx + this.width - corner_width, // dx
110
+ dx + this.nss_width - corner_width, // dx
111
111
  dy, // dy
112
112
  corner_width, corner_height // dw,dh
113
113
  );
@@ -118,7 +118,7 @@ class NineSliceSprite extends Sprite {
118
118
  sy + h - corner_height, // sy
119
119
  corner_width, corner_height, // sw,sh
120
120
  dx, // dx
121
- dy + this.height - corner_height, // dy
121
+ dy + this.nss_height - corner_height, // dy
122
122
  corner_width, corner_height // dw,dh
123
123
  );
124
124
  // Bottom Right
@@ -127,8 +127,8 @@ class NineSliceSprite extends Sprite {
127
127
  sx + w - corner_width, // sx
128
128
  sy + h - corner_height, // sy
129
129
  corner_width, corner_height, // sw,sh
130
- dx + this.width - corner_width, //dx
131
- dy + this.height - corner_height, // dy
130
+ dx + this.nss_width - corner_width, //dx
131
+ dy + this.nss_height - corner_height, // dy
132
132
  corner_width, corner_height // dw,dh
133
133
  );
134
134
 
@@ -137,8 +137,8 @@ class NineSliceSprite extends Sprite {
137
137
  var image_center_width = w - (corner_width << 1);
138
138
  var image_center_height = h - (corner_height << 1);
139
139
 
140
- var target_center_width = this.width - (corner_width << 1);
141
- 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);
142
142
 
143
143
  //Top center
144
144
  renderer.drawImage(
@@ -161,7 +161,7 @@ class NineSliceSprite extends Sprite {
161
161
  image_center_width, // sw
162
162
  corner_height, // sh
163
163
  dx + corner_width, // dx
164
- dy + this.height - corner_height, // dx
164
+ dy + this.nss_height - corner_height, // dx
165
165
  target_center_width, // dw
166
166
  corner_height // dh
167
167
  );
@@ -186,7 +186,7 @@ class NineSliceSprite extends Sprite {
186
186
  sy + corner_height, // sy
187
187
  corner_width, // sw
188
188
  image_center_height, // sh
189
- dx + this.width - corner_width, // dx
189
+ dx + this.nss_width - corner_width, // dx
190
190
  dy + corner_height, // dy
191
191
  corner_width, // dw
192
192
  target_center_height // dh