melonjs 15.3.0 → 15.4.1

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 (287) hide show
  1. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  5. package/dist/melonjs.mjs/application/application.js +53 -5
  6. package/dist/melonjs.mjs/application/header.js +2 -2
  7. package/dist/melonjs.mjs/application/resize.js +4 -8
  8. package/dist/melonjs.mjs/application/settings.js +5 -5
  9. package/dist/melonjs.mjs/audio/audio.js +4 -6
  10. package/dist/melonjs.mjs/camera/camera2d.js +12 -14
  11. package/dist/melonjs.mjs/const.js +1 -1
  12. package/dist/melonjs.mjs/entity/entity.js +3 -4
  13. package/dist/melonjs.mjs/geometries/ellipse.js +26 -59
  14. package/dist/melonjs.mjs/geometries/line.js +18 -25
  15. package/dist/melonjs.mjs/geometries/path2d.js +16 -13
  16. package/dist/melonjs.mjs/geometries/point.js +8 -16
  17. package/dist/melonjs.mjs/geometries/poly.js +40 -97
  18. package/dist/melonjs.mjs/geometries/rectangle.js +37 -91
  19. package/dist/melonjs.mjs/geometries/roundrect.js +26 -35
  20. package/dist/melonjs.mjs/index.js +6 -6
  21. package/dist/melonjs.mjs/input/gamepad.js +1 -1
  22. package/dist/melonjs.mjs/input/input.js +1 -1
  23. package/dist/melonjs.mjs/input/keyboard.js +3 -3
  24. package/dist/melonjs.mjs/input/pointer.js +4 -4
  25. package/dist/melonjs.mjs/input/pointerevent.js +6 -7
  26. package/dist/melonjs.mjs/lang/console.js +1 -1
  27. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  28. package/dist/melonjs.mjs/level/level.js +1 -1
  29. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  30. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +16 -33
  31. package/dist/melonjs.mjs/level/tiled/TMXObject.js +3 -4
  32. package/dist/melonjs.mjs/level/tiled/TMXTile.js +4 -4
  33. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +3 -3
  34. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +4 -7
  35. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +2 -2
  36. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +26 -29
  37. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +3 -3
  39. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +2 -2
  40. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -2
  41. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  42. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +2 -2
  43. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  44. package/dist/melonjs.mjs/loader/cache.js +1 -1
  45. package/dist/melonjs.mjs/loader/loader.js +1 -1
  46. package/dist/melonjs.mjs/loader/loadingscreen.js +1 -1
  47. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  48. package/dist/melonjs.mjs/loader/parser.js +4 -5
  49. package/dist/melonjs.mjs/loader/settings.js +1 -1
  50. package/dist/melonjs.mjs/math/color.js +2 -2
  51. package/dist/melonjs.mjs/math/math.js +1 -1
  52. package/dist/melonjs.mjs/math/matrix2.js +5 -59
  53. package/dist/melonjs.mjs/math/matrix3.js +82 -141
  54. package/dist/melonjs.mjs/math/observable_vector2.js +7 -7
  55. package/dist/melonjs.mjs/math/observable_vector3.js +5 -5
  56. package/dist/melonjs.mjs/math/vector2.js +7 -91
  57. package/dist/melonjs.mjs/math/vector3.js +6 -90
  58. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +1 -1
  59. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +1 -1
  60. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  61. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  62. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  63. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  64. package/dist/melonjs.mjs/particles/emitter.js +2 -2
  65. package/dist/melonjs.mjs/particles/particle.js +2 -2
  66. package/dist/melonjs.mjs/particles/settings.js +1 -1
  67. package/dist/melonjs.mjs/physics/body.js +22 -20
  68. package/dist/melonjs.mjs/physics/bounds.js +27 -33
  69. package/dist/melonjs.mjs/physics/collision.js +5 -5
  70. package/dist/melonjs.mjs/physics/detector.js +10 -10
  71. package/dist/melonjs.mjs/physics/quadtree.js +5 -5
  72. package/dist/melonjs.mjs/physics/response.js +1 -1
  73. package/dist/melonjs.mjs/physics/sat.js +3 -4
  74. package/dist/melonjs.mjs/physics/world.js +6 -9
  75. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  76. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  77. package/dist/melonjs.mjs/renderable/colorlayer.js +4 -4
  78. package/dist/melonjs.mjs/renderable/container.js +25 -25
  79. package/dist/melonjs.mjs/renderable/draggable.js +1 -1
  80. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  81. package/dist/melonjs.mjs/renderable/imagelayer.js +4 -4
  82. package/dist/melonjs.mjs/renderable/light2d.js +3 -3
  83. package/dist/melonjs.mjs/renderable/nineslicesprite.js +2 -2
  84. package/dist/melonjs.mjs/renderable/renderable.js +26 -26
  85. package/dist/melonjs.mjs/renderable/sprite.js +3 -3
  86. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +421 -0
  87. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +195 -0
  88. package/dist/melonjs.mjs/renderable/text/glyph.js +65 -0
  89. package/dist/melonjs.mjs/renderable/text/text.js +422 -0
  90. package/dist/melonjs.mjs/renderable/text/textmetrics.js +175 -0
  91. package/dist/melonjs.mjs/renderable/text/textstyle.js +21 -0
  92. package/dist/melonjs.mjs/renderable/trigger.js +10 -10
  93. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +7 -7
  94. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +7 -7
  95. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +3 -3
  96. package/dist/melonjs.mjs/state/stage.js +2 -2
  97. package/dist/melonjs.mjs/state/state.js +1 -38
  98. package/dist/melonjs.mjs/system/device.js +49 -10
  99. package/dist/melonjs.mjs/system/dom.js +1 -1
  100. package/dist/melonjs.mjs/system/event.js +24 -2
  101. package/dist/melonjs.mjs/system/platform.js +18 -18
  102. package/dist/melonjs.mjs/system/pooling.js +10 -10
  103. package/dist/melonjs.mjs/system/save.js +1 -1
  104. package/dist/melonjs.mjs/system/timer.js +1 -1
  105. package/dist/melonjs.mjs/text/bitmaptext.js +1 -1
  106. package/dist/melonjs.mjs/text/bitmaptextdata.js +3 -6
  107. package/dist/melonjs.mjs/text/glyph.js +1 -1
  108. package/dist/melonjs.mjs/text/text.js +1 -1
  109. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  110. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  111. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  112. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  113. package/dist/melonjs.mjs/tweens/tween.js +2 -2
  114. package/dist/melonjs.mjs/utils/agent.js +1 -1
  115. package/dist/melonjs.mjs/utils/array.js +1 -1
  116. package/dist/melonjs.mjs/utils/file.js +1 -1
  117. package/dist/melonjs.mjs/utils/function.js +2 -3
  118. package/dist/melonjs.mjs/utils/string.js +1 -1
  119. package/dist/melonjs.mjs/utils/utils.js +1 -1
  120. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +3 -7
  121. package/dist/melonjs.mjs/video/renderer.js +16 -16
  122. package/dist/melonjs.mjs/video/texture/atlas.js +13 -13
  123. package/dist/melonjs.mjs/video/texture/cache.js +1 -1
  124. package/dist/melonjs.mjs/video/texture/canvas_texture.js +15 -15
  125. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  126. package/dist/melonjs.mjs/video/video.js +4 -4
  127. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
  128. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +13 -14
  129. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
  130. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +2 -3
  131. package/dist/melonjs.mjs/video/webgl/glshader.js +2 -2
  132. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/utils/precision.js +4 -4
  138. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  141. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +50 -52
  142. package/dist/melonjs.module.js +1137 -1576
  143. package/dist/types/application/application.d.ts +28 -4
  144. package/dist/types/application/header.d.ts +2 -2
  145. package/dist/types/application/settings.d.ts +23 -23
  146. package/dist/types/audio/audio.d.ts +3 -5
  147. package/dist/types/camera/camera2d.d.ts +13 -16
  148. package/dist/types/entity/entity.d.ts +0 -1
  149. package/dist/types/geometries/ellipse.d.ts +18 -50
  150. package/dist/types/geometries/path2d.d.ts +1 -1
  151. package/dist/types/geometries/point.d.ts +5 -13
  152. package/dist/types/geometries/poly.d.ts +26 -75
  153. package/dist/types/geometries/rectangle.d.ts +12 -58
  154. package/dist/types/geometries/roundrect.d.ts +2 -11
  155. package/dist/types/index.d.ts +3 -3
  156. package/dist/types/input/gamepad.d.ts +31 -31
  157. package/dist/types/input/keyboard.d.ts +105 -105
  158. package/dist/types/input/pointer.d.ts +21 -21
  159. package/dist/types/input/pointerevent.d.ts +6 -6
  160. package/dist/types/level/tiled/TMXLayer.d.ts +1 -1
  161. package/dist/types/math/matrix2.d.ts +9 -63
  162. package/dist/types/math/matrix3.d.ts +9 -68
  163. package/dist/types/math/observable_vector2.d.ts +2 -2
  164. package/dist/types/math/observable_vector3.d.ts +2 -2
  165. package/dist/types/math/vector2.d.ts +8 -92
  166. package/dist/types/math/vector3.d.ts +8 -92
  167. package/dist/types/particles/settings.d.ts +29 -29
  168. package/dist/types/physics/body.d.ts +10 -8
  169. package/dist/types/physics/bounds.d.ts +24 -30
  170. package/dist/types/physics/collision.d.ts +12 -12
  171. package/dist/types/physics/detector.d.ts +1 -1
  172. package/dist/types/physics/world.d.ts +4 -7
  173. package/dist/types/renderable/container.d.ts +19 -19
  174. package/dist/types/renderable/imagelayer.d.ts +6 -6
  175. package/dist/types/renderable/light2d.d.ts +7 -7
  176. package/dist/types/renderable/renderable.d.ts +9 -16
  177. package/dist/types/renderable/text/bitmaptext.d.ts +151 -0
  178. package/dist/types/renderable/text/bitmaptextdata.d.ts +35 -0
  179. package/dist/types/renderable/text/glyph.d.ts +28 -0
  180. package/dist/types/renderable/text/text.d.ts +159 -0
  181. package/dist/types/renderable/text/textmetrics.d.ts +47 -0
  182. package/dist/types/renderable/text/textstyle.d.ts +5 -0
  183. package/dist/types/renderable/ui/uibaseelement.d.ts +0 -1
  184. package/dist/types/renderable/ui/uispriteelement.d.ts +0 -1
  185. package/dist/types/renderable/ui/uitextbutton.d.ts +2 -7
  186. package/dist/types/state/state.d.ts +11 -11
  187. package/dist/types/system/device.d.ts +15 -9
  188. package/dist/types/system/event.d.ts +20 -0
  189. package/dist/types/system/platform.d.ts +17 -17
  190. package/dist/types/utils/function.d.ts +1 -2
  191. package/dist/types/video/renderer.d.ts +13 -13
  192. package/dist/types/video/texture/canvas_texture.d.ts +14 -14
  193. package/dist/types/video/video.d.ts +2 -2
  194. package/dist/types/video/webgl/buffer/vertex.d.ts +2 -2
  195. package/dist/types/video/webgl/compositors/compositor.d.ts +24 -13
  196. package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +0 -1
  197. package/dist/types/video/webgl/compositors/quad_compositor.d.ts +0 -1
  198. package/dist/types/video/webgl/utils/precision.d.ts +1 -1
  199. package/dist/types/video/webgl/webgl_renderer.d.ts +47 -50
  200. package/package.json +15 -15
  201. package/src/application/application.js +51 -3
  202. package/src/application/header.js +1 -1
  203. package/src/application/resize.js +3 -7
  204. package/src/application/settings.js +4 -4
  205. package/src/audio/audio.js +3 -5
  206. package/src/camera/camera2d.js +11 -13
  207. package/src/entity/entity.js +2 -3
  208. package/src/geometries/ellipse.js +25 -58
  209. package/src/geometries/line.js +17 -24
  210. package/src/geometries/path2d.js +15 -12
  211. package/src/geometries/point.js +7 -15
  212. package/src/geometries/poly.js +39 -96
  213. package/src/geometries/rectangle.js +36 -90
  214. package/src/geometries/roundrect.js +25 -34
  215. package/src/index.js +4 -4
  216. package/src/input/keyboard.js +2 -2
  217. package/src/input/pointer.js +3 -3
  218. package/src/input/pointerevent.js +5 -6
  219. package/src/lang/deprecated.js +1 -1
  220. package/src/level/tiled/TMXLayer.js +15 -32
  221. package/src/level/tiled/TMXObject.js +2 -3
  222. package/src/level/tiled/TMXTile.js +3 -3
  223. package/src/level/tiled/TMXTileMap.js +2 -2
  224. package/src/level/tiled/TMXTileset.js +3 -6
  225. package/src/level/tiled/TMXTilesetGroup.js +1 -1
  226. package/src/level/tiled/TMXUtils.js +25 -28
  227. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -2
  228. package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  229. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  230. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  231. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  232. package/src/loader/parser.js +3 -4
  233. package/src/math/color.js +1 -1
  234. package/src/math/matrix2.js +4 -58
  235. package/src/math/matrix3.js +81 -140
  236. package/src/math/observable_vector2.js +6 -6
  237. package/src/math/observable_vector3.js +4 -4
  238. package/src/math/vector2.js +6 -90
  239. package/src/math/vector3.js +5 -89
  240. package/src/particles/emitter.js +1 -1
  241. package/src/particles/particle.js +1 -1
  242. package/src/physics/body.js +21 -19
  243. package/src/physics/bounds.js +26 -32
  244. package/src/physics/collision.js +4 -4
  245. package/src/physics/detector.js +9 -9
  246. package/src/physics/quadtree.js +4 -4
  247. package/src/physics/sat.js +2 -3
  248. package/src/physics/world.js +5 -8
  249. package/src/polyfill/roundrect.js +163 -163
  250. package/src/renderable/collectable.js +1 -1
  251. package/src/renderable/colorlayer.js +3 -3
  252. package/src/renderable/container.js +24 -24
  253. package/src/renderable/imagelayer.js +3 -3
  254. package/src/renderable/light2d.js +2 -2
  255. package/src/renderable/nineslicesprite.js +1 -1
  256. package/src/renderable/renderable.js +25 -25
  257. package/src/renderable/sprite.js +2 -2
  258. package/src/{text → renderable/text}/bitmaptext.js +8 -8
  259. package/src/{text → renderable/text}/bitmaptextdata.js +4 -7
  260. package/src/{text → renderable/text}/glyph.js +1 -1
  261. package/src/{text → renderable/text}/text.js +16 -17
  262. package/src/{text → renderable/text}/textmetrics.js +2 -2
  263. package/src/renderable/trigger.js +9 -9
  264. package/src/renderable/ui/uibaseelement.js +6 -6
  265. package/src/renderable/ui/uispriteelement.js +6 -6
  266. package/src/renderable/ui/uitextbutton.js +2 -2
  267. package/src/state/stage.js +1 -1
  268. package/src/state/state.js +0 -49
  269. package/src/system/device.js +48 -9
  270. package/src/system/event.js +22 -0
  271. package/src/system/platform.js +18 -18
  272. package/src/system/pooling.js +9 -9
  273. package/src/tweens/tween.js +1 -1
  274. package/src/utils/function.js +1 -2
  275. package/src/video/canvas/canvas_renderer.js +2 -6
  276. package/src/video/renderer.js +15 -15
  277. package/src/video/texture/atlas.js +12 -12
  278. package/src/video/texture/canvas_texture.js +14 -14
  279. package/src/video/video.js +3 -3
  280. package/src/video/webgl/buffer/vertex.js +2 -2
  281. package/src/video/webgl/compositors/compositor.js +12 -13
  282. package/src/video/webgl/compositors/primitive_compositor.js +4 -4
  283. package/src/video/webgl/compositors/quad_compositor.js +1 -2
  284. package/src/video/webgl/glshader.js +1 -1
  285. package/src/video/webgl/utils/precision.js +3 -3
  286. package/src/video/webgl/webgl_renderer.js +49 -51
  287. /package/src/{text → renderable/text}/textstyle.js +0 -0
@@ -11,7 +11,7 @@ import * as stringUtil from "./../utils/string.js";
11
11
  * a generic Image Layer Object
12
12
  * @augments Renderable
13
13
  */
14
- export default class ImageLayer extends Sprite {
14
+ export default class ImageLayer extends Sprite {
15
15
  /**
16
16
  * @param {number} x - x coordinate
17
17
  * @param {number} y - y coordinate
@@ -20,7 +20,7 @@ import * as stringUtil from "./../utils/string.js";
20
20
  * @param {string} [settings.name="me.ImageLayer"] - layer name
21
21
  * @param {number} [settings.z=0] - z-index position
22
22
  * @param {number|Vector2d} [settings.ratio=1.0] - Scrolling ratio to be applied. See {@link ImageLayer#ratio}
23
- * @param {string} [settings.repeat='repeat'] - define if and how an Image Layer should be repeated (accepted values are 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'). See {@link ImageLayer#repeat}
23
+ * @param {"repeat"|"repeat-x"|"repeat-y"|"no-repeat"} [settings.repeat="repeat"] - define if and how an Image Layer should be repeated. See {@link ImageLayer#repeat}
24
24
  * @param {number|Vector2d} [settings.anchorPoint=0.0] - Image origin. See {@link ImageLayer#anchorPoint}
25
25
  * @example
26
26
  * // create a repetitive background pattern on the X axis using the citycloud image asset
@@ -227,7 +227,7 @@ import * as stringUtil from "./../utils/string.js";
227
227
  this.isDirty = true;
228
228
  }
229
229
 
230
- /**
230
+ /**
231
231
  * override the default predraw function
232
232
  * as repeat and anchor are managed directly in the draw method
233
233
  * @ignore
@@ -49,8 +49,8 @@ function createGradient(light) {
49
49
  * (multiple lights are not supported, alpha component of the ambient light is ignored)
50
50
  * @see stage.lights
51
51
  */
52
- export default class Light2d extends Renderable {
53
- /**
52
+ export default class Light2d extends Renderable {
53
+ /**
54
54
  * @param {number} x - The horizontal position of the light.
55
55
  * @param {number} y - The vertical position of the light.
56
56
  * @param {number} radiusX - The horizontal radius of the light.
@@ -8,7 +8,7 @@ import Sprite from "./sprite.js";
8
8
  * @see https://en.wikipedia.org/wiki/9-slice_scaling
9
9
  * @augments Sprite
10
10
  */
11
- export default class NineSliceSprite extends Sprite {
11
+ export default class NineSliceSprite extends Sprite {
12
12
  /**
13
13
  * @param {number} x - the x coordinates of the sprite object
14
14
  * @param {number} y - the y coordinates of the sprite object
@@ -10,7 +10,7 @@ import { clamp } from "./../math/math.js";
10
10
  * A base class for renderable objects.
11
11
  * @augments Rect
12
12
  */
13
- export default class Renderable extends Rect {
13
+ export default class Renderable extends Rect {
14
14
  /**
15
15
  * @param {number} x - position of the renderable object (accessible through inherited pos.x property)
16
16
  * @param {number} y - position of the renderable object (accessible through inherited pos.y property)
@@ -96,7 +96,7 @@ import { clamp } from "./../math/math.js";
96
96
  */
97
97
  this.body = undefined;
98
98
 
99
- /**
99
+ /**
100
100
  * (G)ame (U)nique (Id)entifier" <br>
101
101
  * a GUID will be allocated for any renderable object added <br>
102
102
  * to an object container (including the `me.game.world` container)
@@ -569,7 +569,7 @@ import { clamp } from "./../math/math.js";
569
569
  }
570
570
 
571
571
  if (absolute === true) {
572
- var absPos = this.getAbsolutePosition();
572
+ let absPos = this.getAbsolutePosition();
573
573
  bounds.centerOn(absPos.x + bounds.x + bounds.width / 2, absPos.y + bounds.y + bounds.height / 2);
574
574
  }
575
575
  return bounds;
@@ -585,25 +585,25 @@ import { clamp } from "./../math/math.js";
585
585
  * update the renderable's bounding rect (private)
586
586
  * @ignore
587
587
  */
588
- updateBoundsPos(newX = this.pos.x, newY = this.pos.y) {
588
+ updateBoundsPos(newX = this.pos.x, newY = this.pos.y) {
589
589
  this.getBounds().translate(newX - this.pos.x, newY - this.pos.y);
590
- }
590
+ }
591
591
 
592
- /**
592
+ /**
593
593
  * return the renderable absolute position in the game world
594
594
  * @returns {Vector2d}
595
595
  */
596
- getAbsolutePosition() {
597
- if (typeof this._absPos === "undefined") {
598
- this._absPos = pool.pull("Vector2d");
599
- }
600
- // XXX Cache me or something
601
- this._absPos.set(this.pos.x, this.pos.y);
602
- if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
603
- this._absPos.add(this.ancestor.getAbsolutePosition());
604
- }
605
- return this._absPos;
606
- }
596
+ getAbsolutePosition() {
597
+ if (typeof this._absPos === "undefined") {
598
+ this._absPos = pool.pull("Vector2d");
599
+ }
600
+ // XXX Cache me or something
601
+ this._absPos.set(this.pos.x, this.pos.y);
602
+ if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
603
+ this._absPos.add(this.ancestor.getAbsolutePosition());
604
+ }
605
+ return this._absPos;
606
+ }
607
607
 
608
608
  /**
609
609
  * called when the anchor point value is changed
@@ -611,14 +611,14 @@ import { clamp } from "./../math/math.js";
611
611
  * @param {number} x - the new X value to be set for the anchor
612
612
  * @param {number} y - the new Y value to be set for the anchor
613
613
  */
614
- onAnchorUpdate(x, y) {
615
- // since the callback is called before setting the new value
616
- // manually update the anchor point (required for updateBoundsPos)
617
- this.anchorPoint.setMuted(x, y);
618
- // then call updateBounds
619
- this.updateBounds();
620
- this.isDirty = true;
621
- }
614
+ onAnchorUpdate(x, y) {
615
+ // since the callback is called before setting the new value
616
+ // manually update the anchor point (required for updateBoundsPos)
617
+ this.anchorPoint.setMuted(x, y);
618
+ // then call updateBounds
619
+ this.updateBounds();
620
+ this.isDirty = true;
621
+ }
622
622
 
623
623
  /**
624
624
  * Prepare the rendering context before drawing (automatically called by melonJS).
@@ -10,7 +10,7 @@ import Color from "../math/color.js";
10
10
  * An object to display a fixed or animated sprite on screen.
11
11
  * @augments Renderable
12
12
  */
13
- export default class Sprite extends Renderable {
13
+ export default class Sprite extends Renderable {
14
14
  /**
15
15
  * @param {number} x - the x coordinates of the sprite object
16
16
  * @param {number} y - the y coordinates of the sprite object
@@ -307,7 +307,7 @@ import Color from "../math/color.js";
307
307
  };
308
308
  }
309
309
  else {
310
- frameObject = frame;
310
+ frameObject = frame;
311
311
  }
312
312
  let frameObjectName = frameObject.name;
313
313
  if (typeof(frameObjectName) === "number") {
@@ -1,7 +1,7 @@
1
- import Color from "./../math/color.js";
2
- import pool from "./../system/pooling.js";
3
- import { getImage, getBinary } from "./../loader/loader.js";
4
- import Renderable from "./../renderable/renderable.js";
1
+ import Color from "../../math/color.js";
2
+ import pool from "../../system/pooling.js";
3
+ import { getImage, getBinary } from "../../loader/loader.js";
4
+ import Renderable from "../renderable.js";
5
5
  import TextMetrics from "./textmetrics.js";
6
6
 
7
7
  /**
@@ -9,7 +9,7 @@ import TextMetrics from "./textmetrics.js";
9
9
  * a bitmap font object
10
10
  * @augments Renderable
11
11
  */
12
- export default class BitmapText extends Renderable {
12
+ export default class BitmapText extends Renderable {
13
13
  /**
14
14
  * @param {number} x - position of the text object
15
15
  * @param {number} y - position of the text object
@@ -210,8 +210,8 @@ import TextMetrics from "./textmetrics.js";
210
210
  break;
211
211
  }
212
212
 
213
- // adjust y pos based on alignment value
214
- switch (this.textBaseline) {
213
+ // adjust y pos based on alignment value
214
+ switch (this.textBaseline) {
215
215
  case "middle":
216
216
  ay = this.metrics.height * 0.5;
217
217
  break;
@@ -233,7 +233,7 @@ import TextMetrics from "./textmetrics.js";
233
233
 
234
234
  if (absolute === true) {
235
235
  if (typeof this.ancestor !== "undefined" && typeof this.ancestor.getAbsolutePosition === "function" && this.floating !== true) {
236
- bounds.translate(this.ancestor.getAbsolutePosition());
236
+ bounds.translate(this.ancestor.getAbsolutePosition());
237
237
  }
238
238
  }
239
239
 
@@ -56,9 +56,9 @@ function createSpaceGlyph(glyphs) {
56
56
  * Class for storing relevant data from the font file.
57
57
  * @ignore
58
58
  */
59
- export default class BitmapTextData {
59
+ export default class BitmapTextData {
60
60
 
61
- /**
61
+ /**
62
62
  * @param {string} data - The bitmap font data pulled from the resource loader using me.loader.getBinary()
63
63
  */
64
64
  constructor(data) {
@@ -116,14 +116,11 @@ function createSpaceGlyph(glyphs) {
116
116
  this.lineHeight = parseFloat(getValueFromPair(lines[1], /lineHeight\=\d+/g));
117
117
 
118
118
  let baseLine = parseFloat(getValueFromPair(lines[1], /base\=\d+/g));
119
-
120
119
  let padY = this.padTop + this.padBottom;
121
-
122
120
  let glyph = null;
123
121
 
124
- let i;
125
122
 
126
- for (i = 4; i < lines.length; i++) {
123
+ for (let i = 4; i < lines.length; i++) {
127
124
  let line = lines[i];
128
125
  let characterValues = line.split(/=|\s+/);
129
126
  if (!line || /^kernings/.test(line)) {
@@ -164,7 +161,7 @@ function createSpaceGlyph(glyphs) {
164
161
  createSpaceGlyph(this.glyphs);
165
162
 
166
163
  let capGlyph = null;
167
- for (i = 0; i < capChars.length; i++) {
164
+ for (let i = 0; i < capChars.length; i++) {
168
165
  let capChar = capChars[i];
169
166
  capGlyph = this.glyphs[capChar.charCodeAt(0)];
170
167
  if (capGlyph) {
@@ -7,7 +7,7 @@ const PAGE_SIZE = 1 << LOG2_PAGE_SIZE;
7
7
  * a glyph representing a single character in a font
8
8
  * @ignore
9
9
  */
10
- export default class Glyph {
10
+ export default class Glyph {
11
11
  /**
12
12
  * @ignore
13
13
  */
@@ -1,8 +1,8 @@
1
- import Color from "./../math/color.js";
2
- import { renderer as globalRenderer } from "./../video/video.js";
3
- import pool from "./../system/pooling.js";
4
- import Renderable from "./../renderable/renderable.js";
5
- import { nextPowerOfTwo } from "./../math/math.js";
1
+ import Color from "../../math/color.js";
2
+ import { renderer as globalRenderer } from "../../video/video.js";
3
+ import pool from "../../system/pooling.js";
4
+ import Renderable from "../renderable.js";
5
+ import { nextPowerOfTwo } from "../../math/math.js";
6
6
  import setContextStyle from "./textstyle.js";
7
7
  import TextMetrics from "./textmetrics.js";
8
8
 
@@ -14,7 +14,6 @@ import TextMetrics from "./textmetrics.js";
14
14
  * -> first char " " 32d (0x20);
15
15
  */
16
16
 
17
-
18
17
  const runits = ["ex", "em", "pt", "px"];
19
18
  const toPX = [12, 24, 0.75, 1];
20
19
 
@@ -23,7 +22,7 @@ const toPX = [12, 24, 0.75, 1];
23
22
  * a generic system font object.
24
23
  * @augments Renderable
25
24
  */
26
- export default class Text extends Renderable {
25
+ export default class Text extends Renderable {
27
26
  /**
28
27
  * @param {number} x - position of the text object
29
28
  * @param {number} y - position of the text object
@@ -76,16 +75,16 @@ const toPX = [12, 24, 0.75, 1];
76
75
  * @name strokeStyle
77
76
  * @default black
78
77
  */
79
- if (typeof settings.strokeStyle !== "undefined") {
80
- if (settings.strokeStyle instanceof Color) {
81
- this.strokeStyle = settings.strokeStyle;
82
- } else {
83
- // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
84
- this.strokeStyle = pool.pull("Color").parseCSS(settings.strokeStyle);
85
- }
86
- } else {
87
- this.strokeStyle = pool.pull("Color", 0, 0, 0);
88
- }
78
+ if (typeof settings.strokeStyle !== "undefined") {
79
+ if (settings.strokeStyle instanceof Color) {
80
+ this.strokeStyle = settings.strokeStyle;
81
+ } else {
82
+ // string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
83
+ this.strokeStyle = pool.pull("Color").parseCSS(settings.strokeStyle);
84
+ }
85
+ } else {
86
+ this.strokeStyle = pool.pull("Color", 0, 0, 0);
87
+ }
89
88
 
90
89
  /**
91
90
  * sets the current line width, in pixels, when drawing stroke
@@ -1,4 +1,4 @@
1
- import Bounds from "./../physics/bounds.js";
1
+ import Bounds from "../../physics/bounds.js";
2
2
  import Text from "./text.js";
3
3
  import setContextStyle from "./textstyle.js";
4
4
 
@@ -7,7 +7,7 @@ import setContextStyle from "./textstyle.js";
7
7
  * a Text Metrics object that contains helper for text manipulation
8
8
  * @augments Bounds
9
9
  */
10
- export default class TextMetrics extends Bounds {
10
+ export default class TextMetrics extends Bounds {
11
11
 
12
12
  /**
13
13
  * @param {Text|BitmapText} ancestor - the parent object that contains this TextMetrics object
@@ -9,7 +9,7 @@ import pool from "./../system/pooling.js";
9
9
  * trigger an event when colliding with another object
10
10
  * @augments Renderable
11
11
  */
12
- export default class Trigger extends Renderable {
12
+ export default class Trigger extends Renderable {
13
13
  /**
14
14
  * @param {number} x - the x coordinates of the trigger area
15
15
  * @param {number} y - the y coordinates of the trigger area
@@ -85,14 +85,14 @@ import pool from "./../system/pooling.js";
85
85
  /**
86
86
  * @ignore
87
87
  */
88
- getTriggerSettings() {
88
+ getTriggerSettings() {
89
89
  let world = this.ancestor.getRootAncestor();
90
- // Lookup for the container instance
91
- if (typeof(this.triggerSettings.container) === "string") {
92
- this.triggerSettings.container = world.getChildByName(this.triggerSettings.container)[0];
93
- }
94
- return this.triggerSettings;
95
- }
90
+ // Lookup for the container instance
91
+ if (typeof(this.triggerSettings.container) === "string") {
92
+ this.triggerSettings.container = world.getChildByName(this.triggerSettings.container)[0];
93
+ }
94
+ return this.triggerSettings;
95
+ }
96
96
 
97
97
  /**
98
98
  * @ignore
@@ -121,7 +121,7 @@ import pool from "./../system/pooling.js";
121
121
  if (!this.fading) {
122
122
  this.fading = true;
123
123
  world.app.viewport.fadeIn(this.fade, this.duration,
124
- () => this.onFadeComplete());
124
+ () => this.onFadeComplete());
125
125
  }
126
126
  } else {
127
127
  level.load(this.gotolevel, triggerSettings);
@@ -10,7 +10,7 @@ import pool from "../../system/pooling.js";
10
10
  * Use this for example if you want to display a panel that contains text, images or other UI elements.
11
11
  * @augments Container
12
12
  */
13
- export default class UIBaseElement extends Container {
13
+ export default class UIBaseElement extends Container {
14
14
  /**
15
15
  *
16
16
  * @param {number} x - The x position of the container
@@ -88,7 +88,7 @@ import pool from "../../system/pooling.js";
88
88
  clicked(event) {
89
89
  // Check if left mouse button is pressed
90
90
  if (event.button === 0 && this.isClickable) {
91
- this.dirty = true;
91
+ this.isDirty = true;
92
92
  this.released = false;
93
93
  if (this.isHoldable) {
94
94
  timer.clearTimeout(this.holdTimeout);
@@ -122,7 +122,7 @@ import pool from "../../system/pooling.js";
122
122
  */
123
123
  enter(event) {
124
124
  this.hover = true;
125
- this.dirty = true;
125
+ this.isDirty = true;
126
126
  if (this.isDraggable === true) {
127
127
  on(POINTERMOVE, this.pointerMove, this);
128
128
  // to memorize where we grab the object
@@ -168,7 +168,7 @@ import pool from "../../system/pooling.js";
168
168
  */
169
169
  leave(event) {
170
170
  this.hover = false;
171
- this.dirty = true;
171
+ this.isDirty = true;
172
172
  if (this.isDraggable === true) {
173
173
  // unregister on the global pointermove event
174
174
  off(POINTERMOVE, this.pointerMove);
@@ -194,7 +194,7 @@ import pool from "../../system/pooling.js";
194
194
  release(event) {
195
195
  if (this.released === false) {
196
196
  this.released = true;
197
- this.dirty = true;
197
+ this.isDirty = true;
198
198
  timer.clearTimeout(this.holdTimeout);
199
199
  this.holdTimeout = -1;
200
200
  return this.onRelease(event);
@@ -216,7 +216,7 @@ import pool from "../../system/pooling.js";
216
216
  hold() {
217
217
  timer.clearTimeout(this.holdTimeout);
218
218
  this.holdTimeout = -1;
219
- this.dirty = true;
219
+ this.isDirty = true;
220
220
  if (!this.released) {
221
221
  this.onHold();
222
222
  }
@@ -7,7 +7,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
7
7
  * This is a basic sprite based button which you can use in your Game UI.
8
8
  * @augments Sprite
9
9
  */
10
- export default class UISpriteElement extends Sprite {
10
+ export default class UISpriteElement extends Sprite {
11
11
  /**
12
12
  * @param {number} x - the x coordinate of the UISpriteElement Object
13
13
  * @param {number} y - the y coordinate of the UISpriteElement Object
@@ -93,7 +93,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
93
93
  clicked(event) {
94
94
  // Check if left mouse button is pressed
95
95
  if (event.button === 0 && this.isClickable) {
96
- this.dirty = true;
96
+ this.isDirty = true;
97
97
  this.released = false;
98
98
  if (this.isHoldable) {
99
99
  timer.clearTimeout(this.holdTimeout);
@@ -119,7 +119,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
119
119
  */
120
120
  enter(event) {
121
121
  this.hover = true;
122
- this.dirty = true;
122
+ this.isDirty = true;
123
123
  return this.onOver(event);
124
124
  }
125
125
 
@@ -137,7 +137,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
137
137
  */
138
138
  leave(event) {
139
139
  this.hover = false;
140
- this.dirty = true;
140
+ this.isDirty = true;
141
141
  this.release(event);
142
142
  return this.onOut(event);
143
143
  }
@@ -157,7 +157,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
157
157
  release(event) {
158
158
  if (this.released === false) {
159
159
  this.released = true;
160
- this.dirty = true;
160
+ this.isDirty = true;
161
161
  timer.clearTimeout(this.holdTimeout);
162
162
  this.holdTimeout = -1;
163
163
  return this.onRelease(event);
@@ -179,7 +179,7 @@ import { registerPointerEvent, releasePointerEvent} from "./../../input/input.js
179
179
  hold() {
180
180
  timer.clearTimeout(this.holdTimeout);
181
181
  this.holdTimeout = -1;
182
- this.dirty = true;
182
+ this.isDirty = true;
183
183
  if (!this.released) {
184
184
  this.onHold();
185
185
  }
@@ -1,4 +1,4 @@
1
- import BitmapText from "../../text/bitmaptext.js";
1
+ import BitmapText from "../text/bitmaptext.js";
2
2
  import RoundRect from "../../geometries/roundrect.js";
3
3
  import UIBaseElement from "./uibaseelement.js";
4
4
 
@@ -8,7 +8,7 @@ import UIBaseElement from "./uibaseelement.js";
8
8
  * This is a basic base text button which you can use in your Game UI.
9
9
  * @augments UIBaseElement
10
10
  */
11
- export default class UITextButton extends UIBaseElement {
11
+ export default class UITextButton extends UIBaseElement {
12
12
  /**
13
13
  * A Bitmap Text Button with an outlined background border, filled with background color.
14
14
  * It uses a RoundRect as background and changes the background color on hovering over.
@@ -18,7 +18,7 @@ let default_settings = {
18
18
  * through the state manager must inherit from this base class.
19
19
  * @see state
20
20
  */
21
- export default class Stage {
21
+ export default class Stage {
22
22
 
23
23
  /**
24
24
  * @param {object} [settings] - The stage` parameters
@@ -2,7 +2,6 @@ import { pauseTrack, resumeTrack } from "./../audio/audio.js";
2
2
  import * as fctUtil from "./../utils/function.js";
3
3
  import * as event from "./../system/event.js";
4
4
  import { game } from "../index.js";
5
- import * as device from "./../system/device.js";
6
5
  import Stage from "./../state/stage.js";
7
6
  import DefaultLoadingScreen from "./../loader/loadingscreen.js";
8
7
 
@@ -134,54 +133,6 @@ event.on(event.BOOT, () => {
134
133
  event.on(event.VIDEO_INIT, () => {
135
134
  state.change(state.DEFAULT, true);
136
135
  });
137
-
138
- if (typeof globalThis.addEventListener === "function") {
139
- // set pause/stop action on losing focus
140
- globalThis.addEventListener("blur", () => {
141
- if (device.stopOnBlur) {
142
- state.stop(true);
143
- }
144
- if (device.pauseOnBlur) {
145
- state.pause(true);
146
- }
147
- }, false);
148
- // set restart/resume action on gaining focus
149
- globalThis.addEventListener("focus", () => {
150
- if (device.stopOnBlur) {
151
- state.restart(true);
152
- }
153
- if (device.resumeOnFocus) {
154
- state.resume(true);
155
- }
156
- // force focus if autofocus is on
157
- if (device.autoFocus) {
158
- device.focus();
159
- }
160
- }, false);
161
- }
162
-
163
- if (typeof globalThis.document !== "undefined") {
164
- if (typeof globalThis.document.addEventListener === "function") {
165
- // register on the visibilitychange event if supported
166
- globalThis.document.addEventListener("visibilitychange", () => {
167
- if (globalThis.document.visibilityState === "visible") {
168
- if (device.stopOnBlur) {
169
- state.restart(true);
170
- }
171
- if (device.resumeOnFocus) {
172
- state.resume(true);
173
- }
174
- } else {
175
- if (device.stopOnBlur) {
176
- state.stop(true);
177
- }
178
- if (device.pauseOnBlur) {
179
- state.pause(true);
180
- }
181
- }
182
- }, false );
183
- }
184
- }
185
136
  });
186
137
 
187
138
  /**
@@ -1,5 +1,6 @@
1
1
  import { getParent } from "./../video/video.js";
2
2
  import save from "./save.js";
3
+ import * as event from "./../system/event.js";
3
4
  import { prefixed } from "./../utils/agent.js";
4
5
  import { DOMContentLoaded } from "./dom.js";
5
6
  import * as device_platform from "./platform.js"; // export * as name1 from …; // ECMAScript® 2020
@@ -349,6 +350,8 @@ export let alpha = 0;
349
350
  * Specify whether to pause the game when losing focus
350
351
  * @name pauseOnBlur
351
352
  * @memberof device
353
+ * @deprecated since 15.4.0
354
+ * @see Application.pauseOnBlur
352
355
  * @type {boolean}
353
356
  * @public
354
357
  * @default true
@@ -359,6 +362,8 @@ export let pauseOnBlur = true;
359
362
  * Specify whether to unpause the game when gaining focus
360
363
  * @name resumeOnFocus
361
364
  * @memberof device
365
+ * @deprecated since 15.4.0
366
+ * @see Application.resumeOnFocus
362
367
  * @type {boolean}
363
368
  * @public
364
369
  * @default true
@@ -366,25 +371,27 @@ export let pauseOnBlur = true;
366
371
  export let resumeOnFocus = true;
367
372
 
368
373
  /**
369
- * Specify whether to automatically bring the window to the front
370
- * @name autoFocus
374
+ * Specify whether to stop the game when losing focus or not.
375
+ * The engine restarts on focus if this is enabled.
376
+ * @name stopOnBlur
371
377
  * @memberof device
378
+ * @deprecated since 15.4.0
379
+ * @see Application.stopOnBlur
372
380
  * @type {boolean}
373
381
  * @public
374
- * @default true
382
+ * @default false
375
383
  */
376
- export let autoFocus = true;
384
+ export let stopOnBlur = false;
377
385
 
378
386
  /**
379
- * Specify whether to stop the game when losing focus or not.
380
- * The engine restarts on focus if this is enabled.
381
- * @name stopOnBlur
387
+ * Specify whether to automatically bring the window to the front
388
+ * @name autoFocus
382
389
  * @memberof device
383
390
  * @type {boolean}
384
391
  * @public
385
- * @default false
392
+ * @default true
386
393
  */
387
- export let stopOnBlur = false;
394
+ export let autoFocus = true;
388
395
 
389
396
  /**
390
397
  * specify a function to execute when the Device is fully loaded and ready
@@ -432,6 +439,38 @@ export let stopOnBlur = false;
432
439
  * });
433
440
  */
434
441
  export function onReady(fn) {
442
+ // register on blur/focus and visibility event handlers
443
+ if (typeof globalThis.addEventListener === "function") {
444
+ // set pause/stop action on losing focus
445
+ globalThis.addEventListener("blur", () => {
446
+ event.emit(event.BLUR);
447
+ }, false);
448
+ // set restart/resume action on gaining focus
449
+ globalThis.addEventListener("focus", () => {
450
+ event.emit(event.FOCUS);
451
+ // force focus if autofocus is on
452
+ if (autoFocus === true) {
453
+ focus();
454
+ }
455
+ }, false);
456
+ }
457
+ if (typeof globalThis.document !== "undefined") {
458
+ if (typeof globalThis.document.addEventListener === "function") {
459
+ // register on the visibilitychange event if supported
460
+ globalThis.document.addEventListener("visibilitychange", () => {
461
+ if (globalThis.document.visibilityState === "visible") {
462
+ event.emit(event.FOCUS);
463
+ // force focus if autofocus is on
464
+ if (autoFocus === true) {
465
+ focus();
466
+ }
467
+ } else {
468
+ event.emit(event.BLUR);
469
+ }
470
+ }, false );
471
+ }
472
+ }
473
+ // call the supplied function
435
474
  DOMContentLoaded(fn);
436
475
  }
437
476