melonjs 14.5.0 → 15.1.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 (315) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +6 -6
  3. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  7. package/dist/melonjs.mjs/_virtual/index.js +7 -3
  8. package/dist/melonjs.mjs/_virtual/index2.js +1 -1
  9. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  10. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  11. package/dist/melonjs.mjs/application/application.js +27 -17
  12. package/dist/melonjs.mjs/application/header.js +6 -5
  13. package/dist/melonjs.mjs/application/resize.js +20 -20
  14. package/dist/melonjs.mjs/application/settings.js +1 -1
  15. package/dist/melonjs.mjs/audio/audio.js +18 -20
  16. package/dist/melonjs.mjs/camera/camera2d.js +10 -10
  17. package/dist/melonjs.mjs/const.js +1 -1
  18. package/dist/melonjs.mjs/entity/entity.js +4 -4
  19. package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
  20. package/dist/melonjs.mjs/geometries/line.js +9 -9
  21. package/dist/melonjs.mjs/geometries/path2d.js +56 -56
  22. package/dist/melonjs.mjs/geometries/point.js +2 -2
  23. package/dist/melonjs.mjs/geometries/poly.js +29 -29
  24. package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
  25. package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
  26. package/dist/melonjs.mjs/index.js +8 -6
  27. package/dist/melonjs.mjs/input/gamepad.js +30 -30
  28. package/dist/melonjs.mjs/input/input.js +2 -2
  29. package/dist/melonjs.mjs/input/keyboard.js +15 -15
  30. package/dist/melonjs.mjs/input/pointer.js +2 -2
  31. package/dist/melonjs.mjs/input/pointerevent.js +59 -59
  32. package/dist/melonjs.mjs/lang/console.js +3 -3
  33. package/dist/melonjs.mjs/lang/deprecated.js +2 -2
  34. package/dist/melonjs.mjs/level/level.js +9 -9
  35. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
  36. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
  37. package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
  38. package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
  39. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
  40. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
  41. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
  42. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
  43. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
  48. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
  49. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  50. package/dist/melonjs.mjs/loader/cache.js +1 -1
  51. package/dist/melonjs.mjs/loader/loader.js +7 -7
  52. package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
  53. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  54. package/dist/melonjs.mjs/loader/parser.js +13 -13
  55. package/dist/melonjs.mjs/loader/settings.js +3 -3
  56. package/dist/melonjs.mjs/math/color.js +25 -24
  57. package/dist/melonjs.mjs/math/math.js +2 -2
  58. package/dist/melonjs.mjs/math/matrix2.js +22 -22
  59. package/dist/melonjs.mjs/math/matrix3.js +52 -52
  60. package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
  61. package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
  62. package/dist/melonjs.mjs/math/vector2.js +11 -11
  63. package/dist/melonjs.mjs/math/vector3.js +21 -21
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
  67. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
  68. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
  69. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
  70. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  71. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
  72. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  73. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  74. package/dist/melonjs.mjs/particles/emitter.js +5 -5
  75. package/dist/melonjs.mjs/particles/particle.js +8 -8
  76. package/dist/melonjs.mjs/particles/settings.js +3 -3
  77. package/dist/melonjs.mjs/physics/body.js +17 -17
  78. package/dist/melonjs.mjs/physics/bounds.js +12 -12
  79. package/dist/melonjs.mjs/physics/collision.js +3 -3
  80. package/dist/melonjs.mjs/physics/detector.js +14 -14
  81. package/dist/melonjs.mjs/physics/quadtree.js +19 -19
  82. package/dist/melonjs.mjs/physics/response.js +1 -1
  83. package/dist/melonjs.mjs/physics/sat.js +60 -60
  84. package/dist/melonjs.mjs/physics/world.js +4 -4
  85. package/dist/melonjs.mjs/plugin/plugin.js +11 -11
  86. package/dist/melonjs.mjs/renderable/collectable.js +2 -2
  87. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  88. package/dist/melonjs.mjs/renderable/container.js +77 -59
  89. package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
  90. package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
  91. package/dist/melonjs.mjs/renderable/light2d.js +6 -6
  92. package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
  93. package/dist/melonjs.mjs/renderable/renderable.js +35 -13
  94. package/dist/melonjs.mjs/renderable/sprite.js +25 -25
  95. package/dist/melonjs.mjs/renderable/trigger.js +11 -9
  96. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
  97. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
  98. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -65
  99. package/dist/melonjs.mjs/state/stage.js +7 -7
  100. package/dist/melonjs.mjs/state/state.js +15 -15
  101. package/dist/melonjs.mjs/system/device.js +3 -3
  102. package/dist/melonjs.mjs/system/dom.js +1 -1
  103. package/dist/melonjs.mjs/system/event.js +2 -2
  104. package/dist/melonjs.mjs/system/platform.js +1 -1
  105. package/dist/melonjs.mjs/system/pooling.js +9 -9
  106. package/dist/melonjs.mjs/system/save.js +6 -6
  107. package/dist/melonjs.mjs/system/timer.js +16 -12
  108. package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
  109. package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
  110. package/dist/melonjs.mjs/text/glyph.js +3 -3
  111. package/dist/melonjs.mjs/text/text.js +63 -92
  112. package/dist/melonjs.mjs/text/textmetrics.js +15 -15
  113. package/dist/melonjs.mjs/text/textstyle.js +4 -6
  114. package/dist/melonjs.mjs/tweens/easing.js +4 -4
  115. package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
  116. package/dist/melonjs.mjs/tweens/tween.js +11 -11
  117. package/dist/melonjs.mjs/utils/agent.js +6 -6
  118. package/dist/melonjs.mjs/utils/array.js +4 -4
  119. package/dist/melonjs.mjs/utils/file.js +1 -1
  120. package/dist/melonjs.mjs/utils/function.js +5 -5
  121. package/dist/melonjs.mjs/utils/string.js +3 -3
  122. package/dist/melonjs.mjs/utils/utils.js +16 -16
  123. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +41 -119
  124. package/dist/melonjs.mjs/video/renderer.js +70 -14
  125. package/dist/melonjs.mjs/video/texture/atlas.js +39 -45
  126. package/dist/melonjs.mjs/video/texture/cache.js +9 -10
  127. package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
  128. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  129. package/dist/melonjs.mjs/video/video.js +2 -2
  130. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +23 -19
  131. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +80 -80
  132. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +77 -0
  133. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +252 -0
  134. package/dist/melonjs.mjs/video/webgl/compositors/webgl_compositor.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
  136. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +2 -2
  138. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +2 -2
  140. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
  141. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  142. package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
  143. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  144. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
  145. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +188 -181
  146. package/dist/melonjs.module.js +25040 -25193
  147. package/dist/types/application/application.d.ts +11 -8
  148. package/dist/types/audio/audio.d.ts +3 -3
  149. package/dist/types/entity/entity.d.ts +1 -1
  150. package/dist/types/index.d.ts +7 -4
  151. package/dist/types/input/input.d.ts +1 -1
  152. package/dist/types/input/keyboard.d.ts +1 -1
  153. package/dist/types/input/pointerevent.d.ts +6 -6
  154. package/dist/types/level/level.d.ts +2 -2
  155. package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
  156. package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
  157. package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
  158. package/dist/types/loader/loader.d.ts +2 -2
  159. package/dist/types/loader/settings.d.ts +2 -2
  160. package/dist/types/particles/emitter.d.ts +1 -1
  161. package/dist/types/physics/collision.d.ts +1 -1
  162. package/dist/types/physics/detector.d.ts +1 -1
  163. package/dist/types/plugin/plugin.d.ts +2 -2
  164. package/dist/types/renderable/container.d.ts +21 -17
  165. package/dist/types/renderable/renderable.d.ts +6 -0
  166. package/dist/types/renderable/sprite.d.ts +11 -11
  167. package/dist/types/renderable/trigger.d.ts +1 -1
  168. package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
  169. package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
  170. package/dist/types/renderable/ui/uitextbutton.d.ts +52 -12
  171. package/dist/types/state/stage.d.ts +1 -1
  172. package/dist/types/system/device.d.ts +1 -1
  173. package/dist/types/system/pooling.d.ts +3 -3
  174. package/dist/types/system/timer.d.ts +5 -5
  175. package/dist/types/text/bitmaptext.d.ts +1 -1
  176. package/dist/types/text/text.d.ts +7 -21
  177. package/dist/types/text/textstyle.d.ts +1 -1
  178. package/dist/types/utils/array.d.ts +2 -2
  179. package/dist/types/video/canvas/canvas_renderer.d.ts +8 -81
  180. package/dist/types/video/renderer.d.ts +48 -4
  181. package/dist/types/video/texture/atlas.d.ts +3 -3
  182. package/dist/types/video/texture/canvas_texture.d.ts +40 -0
  183. package/dist/types/video/webgl/buffer/vertex.d.ts +3 -3
  184. package/dist/types/video/webgl/compositors/compositor.d.ts +38 -32
  185. package/dist/types/video/webgl/compositors/primitive_compositor.d.ts +22 -0
  186. package/dist/types/video/webgl/compositors/quad_compositor.d.ts +72 -0
  187. package/dist/types/video/webgl/glshader.d.ts +1 -1
  188. package/dist/types/video/webgl/webgl_renderer.d.ts +47 -37
  189. package/package.json +16 -17
  190. package/src/application/application.js +26 -16
  191. package/src/application/header.js +5 -4
  192. package/src/application/resize.js +19 -19
  193. package/src/audio/audio.js +17 -19
  194. package/src/camera/camera2d.js +9 -9
  195. package/src/entity/entity.js +3 -3
  196. package/src/geometries/ellipse.js +5 -5
  197. package/src/geometries/line.js +8 -8
  198. package/src/geometries/path2d.js +55 -55
  199. package/src/geometries/point.js +1 -1
  200. package/src/geometries/poly.js +28 -28
  201. package/src/geometries/rectangle.js +7 -7
  202. package/src/geometries/roundrect.js +5 -5
  203. package/src/index.js +9 -4
  204. package/src/input/gamepad.js +29 -29
  205. package/src/input/input.js +1 -1
  206. package/src/input/keyboard.js +14 -14
  207. package/src/input/pointer.js +1 -1
  208. package/src/input/pointerevent.js +52 -52
  209. package/src/lang/console.js +2 -2
  210. package/src/lang/deprecated.js +1 -1
  211. package/src/level/level.js +8 -8
  212. package/src/level/tiled/TMXGroup.js +2 -2
  213. package/src/level/tiled/TMXLayer.js +30 -30
  214. package/src/level/tiled/TMXObject.js +7 -7
  215. package/src/level/tiled/TMXTile.js +7 -7
  216. package/src/level/tiled/TMXTileMap.js +18 -18
  217. package/src/level/tiled/TMXTileset.js +14 -14
  218. package/src/level/tiled/TMXTilesetGroup.js +2 -2
  219. package/src/level/tiled/TMXUtils.js +45 -40
  220. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
  221. package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
  222. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
  223. package/src/level/tiled/renderer/TMXRenderer.js +1 -1
  224. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
  225. package/src/loader/loader.js +6 -6
  226. package/src/loader/loadingscreen.js +1 -1
  227. package/src/loader/parser.js +12 -12
  228. package/src/loader/settings.js +2 -2
  229. package/src/math/color.js +24 -23
  230. package/src/math/math.js +1 -1
  231. package/src/math/matrix2.js +21 -21
  232. package/src/math/matrix3.js +51 -51
  233. package/src/math/observable_vector2.js +11 -11
  234. package/src/math/observable_vector3.js +21 -21
  235. package/src/math/vector2.js +10 -10
  236. package/src/math/vector3.js +20 -20
  237. package/src/particles/emitter.js +4 -4
  238. package/src/particles/particle.js +7 -7
  239. package/src/particles/settings.js +2 -2
  240. package/src/physics/body.js +16 -16
  241. package/src/physics/bounds.js +11 -11
  242. package/src/physics/collision.js +2 -2
  243. package/src/physics/detector.js +13 -13
  244. package/src/physics/quadtree.js +18 -18
  245. package/src/physics/sat.js +59 -59
  246. package/src/physics/world.js +3 -3
  247. package/src/plugin/plugin.js +8 -8
  248. package/src/polyfill/index.js +0 -2
  249. package/src/renderable/collectable.js +1 -1
  250. package/src/renderable/container.js +76 -58
  251. package/src/renderable/dragndrop.js +4 -4
  252. package/src/renderable/imagelayer.js +6 -5
  253. package/src/renderable/light2d.js +5 -5
  254. package/src/renderable/nineslicesprite.js +11 -11
  255. package/src/renderable/renderable.js +34 -12
  256. package/src/renderable/sprite.js +24 -24
  257. package/src/renderable/trigger.js +10 -8
  258. package/src/renderable/ui/uibaseelement.js +96 -26
  259. package/src/renderable/ui/uispriteelement.js +24 -24
  260. package/src/renderable/ui/uitextbutton.js +85 -67
  261. package/src/state/stage.js +6 -6
  262. package/src/state/state.js +14 -14
  263. package/src/system/device.js +2 -2
  264. package/src/system/event.js +1 -1
  265. package/src/system/pooling.js +8 -8
  266. package/src/system/save.js +5 -5
  267. package/src/system/timer.js +15 -11
  268. package/src/text/bitmaptext.js +19 -19
  269. package/src/text/bitmaptextdata.js +21 -21
  270. package/src/text/glyph.js +2 -2
  271. package/src/text/text.js +62 -91
  272. package/src/text/textmetrics.js +14 -14
  273. package/src/text/textstyle.js +3 -5
  274. package/src/tweens/easing.js +3 -3
  275. package/src/tweens/interpolation.js +7 -7
  276. package/src/tweens/tween.js +10 -10
  277. package/src/utils/agent.js +5 -5
  278. package/src/utils/array.js +3 -3
  279. package/src/utils/function.js +4 -4
  280. package/src/utils/string.js +2 -2
  281. package/src/utils/utils.js +15 -15
  282. package/src/video/canvas/canvas_renderer.js +39 -117
  283. package/src/video/renderer.js +68 -12
  284. package/src/video/texture/atlas.js +38 -44
  285. package/src/video/texture/cache.js +6 -6
  286. package/src/video/texture/canvas_texture.js +62 -2
  287. package/src/video/video.js +1 -1
  288. package/src/video/webgl/buffer/vertex.js +22 -18
  289. package/src/video/webgl/compositors/compositor.js +79 -80
  290. package/src/video/webgl/compositors/primitive_compositor.js +68 -0
  291. package/src/video/webgl/compositors/{webgl_compositor.js → quad_compositor.js} +52 -109
  292. package/src/video/webgl/glshader.js +6 -6
  293. package/src/video/webgl/shaders/primitive.vert +2 -5
  294. package/src/video/webgl/shaders/quad.vert +3 -1
  295. package/src/video/webgl/utils/attributes.js +1 -1
  296. package/src/video/webgl/utils/program.js +6 -6
  297. package/src/video/webgl/utils/uniforms.js +3 -3
  298. package/src/video/webgl/webgl_renderer.js +186 -179
  299. package/dist/melonjs.mjs/_virtual/make-built-in.js +0 -10
  300. package/dist/melonjs.mjs/_virtual/object-define-property.js +0 -10
  301. package/dist/melonjs.mjs/_virtual/object-get-own-property-descriptor.js +0 -10
  302. package/dist/melonjs.mjs/_virtual/object-get-own-property-names.js +0 -10
  303. package/dist/melonjs.mjs/_virtual/object-get-own-property-symbols.js +0 -10
  304. package/dist/melonjs.mjs/_virtual/object-property-is-enumerable.js +0 -10
  305. package/dist/melonjs.mjs/_virtual/shared.js +0 -10
  306. package/dist/melonjs.mjs/game.js +0 -29
  307. package/dist/melonjs.mjs/polyfill/console.js +0 -18
  308. package/dist/melonjs.mjs/polyfill/performance.js +0 -27
  309. package/dist/melonjs.mjs/polyfill/requestAnimationFrame.js +0 -46
  310. package/dist/melonjs.mjs/polyfill/roundrect.js +0 -242
  311. package/dist/melonjs.mjs/renderable/re_container.js +0 -1016
  312. package/dist/melonjs.mjs/video/utils/resize.js +0 -116
  313. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +0 -494
  314. package/src/polyfill/performance.js +0 -20
  315. package/src/polyfill/requestAnimationFrame.js +0 -39
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -39,7 +39,7 @@ import TextMetrics from './textmetrics.js';
39
39
  * { name: "arial", type: "image" src: "data/font/arial.png" },
40
40
  * ])
41
41
  * // Then create an instance of your bitmap font:
42
- * var myFont = new me.BitmapText(x, y, {font:"arial", text:"Hello"});
42
+ * let myFont = new me.BitmapText(x, y, {font:"arial", text:"Hello"});
43
43
  * // two possibilities for using "myFont"
44
44
  * // either call the draw function from your Renderable draw function
45
45
  * myFont.draw(renderer, "Hello!", 0, 0);
@@ -194,12 +194,12 @@ import TextMetrics from './textmetrics.js';
194
194
  * @returns {Bounds} this Bitmap Text bounding box Rectangle object
195
195
  */
196
196
  updateBounds(absolute = true) {
197
- var bounds = this.getBounds();
197
+ let bounds = this.getBounds();
198
198
 
199
199
  bounds.clear();
200
200
 
201
201
  if (typeof this.metrics !== "undefined") {
202
- var ax, ay;
202
+ let ax, ay;
203
203
 
204
204
  bounds.addBounds(this.metrics.measureText(this._text));
205
205
 
@@ -298,7 +298,7 @@ import TextMetrics from './textmetrics.js';
298
298
  */
299
299
  draw(renderer, text, x, y) {
300
300
  // save the previous global alpha value
301
- var _alpha = renderer.globalAlpha();
301
+ let _alpha = renderer.globalAlpha();
302
302
 
303
303
  // allows to provide backward compatibility when
304
304
  // adding Bitmap Font to an object container
@@ -312,15 +312,15 @@ import TextMetrics from './textmetrics.js';
312
312
  y = this.pos.y;
313
313
  }
314
314
 
315
- var lX = x;
316
- var stringHeight = this.metrics.lineHeight();
317
- var maxWidth = 0;
315
+ let lX = x;
316
+ let stringHeight = this.metrics.lineHeight();
317
+ let maxWidth = 0;
318
318
 
319
- for (var i = 0; i < this._text.length; i++) {
319
+ for (let i = 0; i < this._text.length; i++) {
320
320
  x = lX;
321
- var string = this._text[i].trimEnd();
321
+ let string = this._text[i].trimEnd();
322
322
  // adjust x pos based on alignment value
323
- var stringWidth = this.metrics.lineWidth(string);
323
+ let stringWidth = this.metrics.lineWidth(string);
324
324
  switch (this.textAlign) {
325
325
  case "right":
326
326
  x -= stringWidth;
@@ -356,18 +356,18 @@ import TextMetrics from './textmetrics.js';
356
356
  }
357
357
 
358
358
  // draw the string
359
- var lastGlyph = null;
360
- for (var c = 0, len = string.length; c < len; c++) {
359
+ let lastGlyph = null;
360
+ for (let c = 0, len = string.length; c < len; c++) {
361
361
  // calculate the char index
362
- var ch = string.charCodeAt(c);
363
- var glyph = this.fontData.glyphs[ch];
362
+ let ch = string.charCodeAt(c);
363
+ let glyph = this.fontData.glyphs[ch];
364
364
 
365
365
  if (typeof glyph !== "undefined") {
366
- var glyphWidth = glyph.width;
367
- var glyphHeight = glyph.height;
368
- var kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
369
- var scaleX = this.fontScale.x;
370
- var scaleY = this.fontScale.y;
366
+ let glyphWidth = glyph.width;
367
+ let glyphHeight = glyph.height;
368
+ let kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
369
+ let scaleX = this.fontScale.x;
370
+ let scaleY = this.fontScale.y;
371
371
 
372
372
  // draw it
373
373
  if (glyphWidth !== 0 && glyphHeight !== 0) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -15,7 +15,7 @@ const capChars = ["M", "N", "B", "D", "C", "E", "F", "K", "A", "G", "H", "I", "J
15
15
  * @ignore
16
16
  */
17
17
  function getValueFromPair(string, pattern) {
18
- var value = string.match(pattern);
18
+ let value = string.match(pattern);
19
19
  if (!value) {
20
20
  throw new Error("Could not find pattern " + pattern + " in string: " + string);
21
21
  }
@@ -32,8 +32,8 @@ function getValueFromPair(string, pattern) {
32
32
  * @returns {Glyph}
33
33
  */
34
34
  function getFirstGlyph(glyphs) {
35
- var keys = Object.keys(glyphs);
36
- for (var i = 0; i < keys.length; i++) {
35
+ let keys = Object.keys(glyphs);
36
+ for (let i = 0; i < keys.length; i++) {
37
37
  if (keys[i] > 32) {
38
38
  return glyphs[keys[i]];
39
39
  }
@@ -49,8 +49,8 @@ function getFirstGlyph(glyphs) {
49
49
  * @param {object} glyphs - the map of glyphs, each key is a char code
50
50
  */
51
51
  function createSpaceGlyph(glyphs) {
52
- var spaceCharCode = " ".charCodeAt(0);
53
- var glyph = glyphs[spaceCharCode];
52
+ let spaceCharCode = " ".charCodeAt(0);
53
+ let glyph = glyphs[spaceCharCode];
54
54
  if (!glyph) {
55
55
  glyph = new Glyph();
56
56
  glyph.id = spaceCharCode;
@@ -109,12 +109,12 @@ function createSpaceGlyph(glyphs) {
109
109
  if (!fontData) {
110
110
  throw new Error("File containing font data was empty, cannot load the bitmap font.");
111
111
  }
112
- var lines = fontData.split(/\r\n|\n/);
113
- var padding = fontData.match(/padding\=\d+,\d+,\d+,\d+/g);
112
+ let lines = fontData.split(/\r\n|\n/);
113
+ let padding = fontData.match(/padding\=\d+,\d+,\d+,\d+/g);
114
114
  if (!padding) {
115
115
  throw new Error("Padding not found in first line");
116
116
  }
117
- var paddingValues = padding[0].split("=")[1].split(",");
117
+ let paddingValues = padding[0].split("=")[1].split(",");
118
118
  this.padTop = parseFloat(paddingValues[0]);
119
119
  this.padLeft = parseFloat(paddingValues[1]);
120
120
  this.padBottom = parseFloat(paddingValues[2]);
@@ -122,24 +122,24 @@ function createSpaceGlyph(glyphs) {
122
122
 
123
123
  this.lineHeight = parseFloat(getValueFromPair(lines[1], /lineHeight\=\d+/g));
124
124
 
125
- var baseLine = parseFloat(getValueFromPair(lines[1], /base\=\d+/g));
125
+ let baseLine = parseFloat(getValueFromPair(lines[1], /base\=\d+/g));
126
126
 
127
- var padY = this.padTop + this.padBottom;
127
+ let padY = this.padTop + this.padBottom;
128
128
 
129
- var glyph = null;
129
+ let glyph = null;
130
130
 
131
- var i;
131
+ let i;
132
132
 
133
133
  for (i = 4; i < lines.length; i++) {
134
- var line = lines[i];
135
- var characterValues = line.split(/=|\s+/);
134
+ let line = lines[i];
135
+ let characterValues = line.split(/=|\s+/);
136
136
  if (!line || /^kernings/.test(line)) {
137
137
  continue;
138
138
  }
139
139
  if (/^kerning\s/.test(line)) {
140
- var first = parseFloat(characterValues[2]);
141
- var second = parseFloat(characterValues[4]);
142
- var amount = parseFloat(characterValues[6]);
140
+ let first = parseFloat(characterValues[2]);
141
+ let second = parseFloat(characterValues[4]);
142
+ let amount = parseFloat(characterValues[6]);
143
143
 
144
144
  glyph = this.glyphs[first];
145
145
  if (glyph !== null && typeof glyph !== "undefined") {
@@ -148,7 +148,7 @@ function createSpaceGlyph(glyphs) {
148
148
  } else {
149
149
  glyph = new Glyph();
150
150
 
151
- var ch = parseFloat(characterValues[2]);
151
+ let ch = parseFloat(characterValues[2]);
152
152
  glyph.id = ch;
153
153
  glyph.x = parseFloat(characterValues[4]);
154
154
  glyph.y = parseFloat(characterValues[6]);
@@ -170,16 +170,16 @@ function createSpaceGlyph(glyphs) {
170
170
 
171
171
  createSpaceGlyph(this.glyphs);
172
172
 
173
- var capGlyph = null;
173
+ let capGlyph = null;
174
174
  for (i = 0; i < capChars.length; i++) {
175
- var capChar = capChars[i];
175
+ let capChar = capChars[i];
176
176
  capGlyph = this.glyphs[capChar.charCodeAt(0)];
177
177
  if (capGlyph) {
178
178
  break;
179
179
  }
180
180
  }
181
181
  if (!capGlyph) {
182
- for (var charCode in this.glyphs) {
182
+ for (let charCode in this.glyphs) {
183
183
  if (this.glyphs.hasOwnProperty(charCode)) {
184
184
  glyph = this.glyphs[charCode];
185
185
  if (glyph.height === 0 || glyph.width === 0) {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -38,7 +38,7 @@ const PAGE_SIZE = 1 << LOG2_PAGE_SIZE;
38
38
  */
39
39
  getKerning(ch) {
40
40
  if (this.kerning) {
41
- var page = this.kerning[ch >>> LOG2_PAGE_SIZE];
41
+ let page = this.kerning[ch >>> LOG2_PAGE_SIZE];
42
42
  if (page) {
43
43
  return page[ch & PAGE_SIZE - 1] || 0;
44
44
  }
@@ -53,7 +53,7 @@ const PAGE_SIZE = 1 << LOG2_PAGE_SIZE;
53
53
  if (!this.kerning) {
54
54
  this.kerning = {};
55
55
  }
56
- var page = this.kerning[ch >>> LOG2_PAGE_SIZE];
56
+ let page = this.kerning[ch >>> LOG2_PAGE_SIZE];
57
57
  if (typeof page === "undefined") {
58
58
  this.kerning[ch >>> LOG2_PAGE_SIZE] = {};
59
59
  page = this.kerning[ch >>> LOG2_PAGE_SIZE];
@@ -1,12 +1,11 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
6
6
  * @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
7
7
  */
8
8
  import Color from '../math/color.js';
9
- import WebGLRenderer from '../video/webgl/webgl_renderer.js';
10
9
  import { renderer } from '../video/video.js';
11
10
  import pool from '../system/pooling.js';
12
11
  import Renderable from '../renderable/renderable.js';
@@ -26,18 +25,6 @@ import TextMetrics from './textmetrics.js';
26
25
  const runits = ["ex", "em", "pt", "px"];
27
26
  const toPX = [12, 24, 0.75, 1];
28
27
 
29
- // return a valid 2d context for Text rendering/styling
30
- var getContext2d = function (renderer$1, text) {
31
- if (text.offScreenCanvas === true) {
32
- return text.canvasTexture.context;
33
- } else {
34
- if (typeof renderer$1 === "undefined") {
35
- renderer$1 = renderer;
36
- }
37
- return renderer$1.getFontContext();
38
- }
39
- };
40
-
41
28
  /**
42
29
  * @classdesc
43
30
  * a generic system font object.
@@ -52,16 +39,15 @@ var getContext2d = function (renderer$1, text) {
52
39
  * @param {number|string} settings.size - size, or size + suffix (px, em, pt)
53
40
  * @param {Color|string} [settings.fillStyle="#000000"] - a CSS color value
54
41
  * @param {Color|string} [settings.strokeStyle="#000000"] - a CSS color value
55
- * @param {number} [settings.lineWidth=1] - line width, in pixels, when drawing stroke
42
+ * @param {number} [settings.lineWidth=0] - line width, in pixels, when drawing stroke
56
43
  * @param {string} [settings.textAlign="left"] - horizontal text alignment
57
44
  * @param {string} [settings.textBaseline="top"] - the text baseline
58
45
  * @param {number} [settings.lineHeight=1.0] - line spacing height
59
46
  * @param {Vector2d} [settings.anchorPoint={x:0.0, y:0.0}] - anchor point to draw the text at
60
- * @param {boolean} [settings.offScreenCanvas=false] - whether to draw the font to an individual "cache" texture first
61
47
  * @param {number} [settings.wordWrapWidth] - the maximum length in CSS pixel for a single segment of text
62
48
  * @param {(string|string[])} [settings.text=""] - a string, or an array of strings
63
49
  * @example
64
- * var font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
50
+ * let font = new me.Text(0, 0, {font: "Arial", size: 8, fillStyle: this.color});
65
51
  */
66
52
  constructor(x, y, settings) {
67
53
  // call the parent constructor
@@ -112,9 +98,9 @@ var getContext2d = function (renderer$1, text) {
112
98
  * sets the current line width, in pixels, when drawing stroke
113
99
  * @public
114
100
  * @type {number}
115
- * @default 1
101
+ * @default 0
116
102
  */
117
- this.lineWidth = settings.lineWidth || 1;
103
+ this.lineWidth = settings.lineWidth || 0;
118
104
 
119
105
  /**
120
106
  * Set the default text alignment (or justification),<br>
@@ -143,16 +129,6 @@ var getContext2d = function (renderer$1, text) {
143
129
  */
144
130
  this.lineHeight = settings.lineHeight || 1.0;
145
131
 
146
- /**
147
- * whether to draw the font to a indidividual offscreen canvas texture first <br>
148
- * Note: this will improve performances when using WebGL, but will impact
149
- * memory consumption as every text element will have its own canvas texture
150
- * @public
151
- * @type {boolean}
152
- * @default false
153
- */
154
- this.offScreenCanvas = false;
155
-
156
132
  /**
157
133
  * the maximum length in CSS pixel for a single segment of text.
158
134
  * (use -1 to disable word wrapping)
@@ -199,10 +175,9 @@ var getContext2d = function (renderer$1, text) {
199
175
  this.italic();
200
176
  }
201
177
 
202
- if (settings.offScreenCanvas === true) {
203
- this.offScreenCanvas = true;
204
- this.canvasTexture = pool.pull("CanvasTexture", 2, 2, { offscreenCanvas: true });
205
- }
178
+ // the canvas Texture used to render this text
179
+ // XXX: offscreenCanvas is currently disabled for text rendering due to issue in WebGL mode
180
+ this.canvasTexture = pool.pull("CanvasTexture", 2, 2, { offscreenCanvas: false });
206
181
 
207
182
  // instance to text metrics functions
208
183
  this.metrics = new TextMetrics(this);
@@ -242,7 +217,7 @@ var getContext2d = function (renderer$1, text) {
242
217
  */
243
218
  setFont(font, size = 10) {
244
219
  // font name and type
245
- var font_names = font.split(",").map((value) => {
220
+ let font_names = font.split(",").map((value) => {
246
221
  value = value.trim();
247
222
  return (
248
223
  !/(^".*"$)|(^'.*'$)/.test(value)
@@ -255,7 +230,7 @@ var getContext2d = function (renderer$1, text) {
255
230
  size += "px";
256
231
  } else /* string */ {
257
232
  // extract the units and convert if necessary
258
- var CSSval = size.match(/([-+]?[\d.]*)(.*)/);
233
+ let CSSval = size.match(/([-+]?[\d.]*)(.*)/);
259
234
  this.fontSize = parseFloat(CSSval[1]);
260
235
  if (CSSval[2]) {
261
236
  this.fontSize *= toPX[runits.indexOf(CSSval[2])];
@@ -278,7 +253,7 @@ var getContext2d = function (renderer$1, text) {
278
253
  * @returns {Text} this object for chaining
279
254
  */
280
255
  setText(value = "") {
281
- var bounds = this.getBounds();
256
+ let bounds = this.getBounds();
282
257
 
283
258
  // set the next text
284
259
  if (this._text.toString() !== value.toString()) {
@@ -291,38 +266,38 @@ var getContext2d = function (renderer$1, text) {
291
266
 
292
267
  // word wrap if necessary
293
268
  if (this._text.length > 0 && this.wordWrapWidth > 0) {
294
- this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth, getContext2d(renderer, this));
269
+ this._text = this.metrics.wordWrap(this._text, this.wordWrapWidth, this.canvasTexture.context);
295
270
  }
296
271
 
297
272
  // calculcate the text size and update the bounds accordingly
298
- bounds.addBounds(this.metrics.measureText(this._text, getContext2d(renderer, this)), true);
273
+ bounds.addBounds(this.metrics.measureText(this._text, this.canvasTexture.context), true);
299
274
 
300
275
  // update the offScreenCanvas texture if required
301
- if (this.offScreenCanvas === true) {
302
- var width = Math.ceil(this.metrics.width),
303
- height = Math.ceil(this.metrics.height);
304
-
305
- if (renderer instanceof WebGLRenderer) {
306
- // invalidate the previous corresponding texture so that it can reuploaded once changed
307
- this.glTextureUnit = renderer.cache.getUnit(renderer.cache.get(this.canvasTexture.canvas));
308
- renderer.currentCompositor.unbindTexture2D(null, this.glTextureUnit);
309
-
310
- if (renderer.WebGLVersion === 1) {
311
- // round size to next Pow2
312
- width = nextPowerOfTwo(this.metrics.width);
313
- height = nextPowerOfTwo(this.metrics.height);
314
- }
315
- }
316
-
317
- // resize the cache canvas if necessary
318
- if (this.canvasTexture.width < width || this.canvasTexture.height < height) {
319
- this.canvasTexture.resize(width, height);
276
+ let width = Math.ceil(this.metrics.width),
277
+ height = Math.ceil(this.metrics.height);
278
+
279
+ if (typeof renderer.gl !== "undefined") {
280
+ // make sure the right compositor is active
281
+ renderer.setCompositor("quad");
282
+ // invalidate the previous corresponding texture so that it can reuploaded once changed
283
+ this.glTextureUnit = renderer.cache.getUnit(renderer.cache.get(this.canvasTexture.canvas));
284
+ renderer.currentCompositor.unbindTexture2D(null, this.glTextureUnit);
285
+
286
+ if (renderer.WebGLVersion === 1) {
287
+ // round size to next Pow2
288
+ width = nextPowerOfTwo(this.metrics.width);
289
+ height = nextPowerOfTwo(this.metrics.height);
320
290
  }
291
+ }
321
292
 
322
- this.canvasTexture.clear();
323
- this._drawFont(this.canvasTexture.context, this._text, this.pos.x - this.metrics.x, this.pos.y - this.metrics.y, false);
293
+ // resize the cache canvas if necessary
294
+ if (this.canvasTexture.width < width || this.canvasTexture.height < height) {
295
+ this.canvasTexture.resize(width, height);
324
296
  }
325
297
 
298
+ this.canvasTexture.clear();
299
+ this._drawFont(this.canvasTexture.context, this._text, this.pos.x - this.metrics.x, this.pos.y - this.metrics.y);
300
+
326
301
  this.isDirty = true;
327
302
 
328
303
  return this;
@@ -335,7 +310,7 @@ var getContext2d = function (renderer$1, text) {
335
310
  * @returns {TextMetrics} a TextMetrics object defining the dimensions of the given piece of text
336
311
  */
337
312
  measureText(renderer, text = this._text) {
338
- return this.metrics.measureText(text, getContext2d(renderer, this));
313
+ return this.metrics.measureText(text, this.canvasTexture.context);
339
314
  }
340
315
 
341
316
 
@@ -345,9 +320,8 @@ var getContext2d = function (renderer$1, text) {
345
320
  * @param {string} [text]
346
321
  * @param {number} [x]
347
322
  * @param {number} [y]
348
- * @param {boolean} [stroke=false] - draw stroke the the text if true
349
323
  */
350
- draw(renderer, text, x = this.pos.x, y = this.pos.y, stroke = false) {
324
+ draw(renderer, text, x = this.pos.x, y = this.pos.y) {
351
325
  // "hacky patch" for backward compatibilty
352
326
  if (typeof this.ancestor === "undefined") {
353
327
 
@@ -361,21 +335,18 @@ var getContext2d = function (renderer$1, text) {
361
335
  // update text cache
362
336
  this.setText(text);
363
337
 
364
- x = this.metrics.x;
365
- y = this.metrics.y;
366
-
367
338
  // save the previous context
368
339
  renderer.save();
369
340
 
370
341
  // apply the defined alpha value
371
342
  renderer.setGlobalAlpha(renderer.globalAlpha() * this.getOpacity());
372
343
 
373
- } else {
374
- // added directly to an object container
375
- x = this.pos.x;
376
- y = this.pos.y;
377
344
  }
378
345
 
346
+ // adjust x,y position based on the bounding box
347
+ x = this.metrics.x;
348
+ y = this.metrics.y;
349
+
379
350
  // clamp to pixel grid if required
380
351
  if (renderer.settings.subPixel === false) {
381
352
  x = ~~x;
@@ -383,12 +354,7 @@ var getContext2d = function (renderer$1, text) {
383
354
  }
384
355
 
385
356
  // draw the text
386
- if (this.offScreenCanvas === true) {
387
- renderer.drawImage(this.canvasTexture.canvas, x, y);
388
- } else {
389
- renderer.drawFont(this._drawFont(renderer.getFontContext(), this._text, x, y, stroke));
390
- }
391
-
357
+ renderer.drawImage(this.canvasTexture.canvas, x, y);
392
358
 
393
359
  // for backward compatibilty
394
360
  if (typeof this.ancestor === "undefined") {
@@ -398,28 +364,33 @@ var getContext2d = function (renderer$1, text) {
398
364
  }
399
365
 
400
366
  /**
401
- * draw a stroke text at the specified coord, as defined <br>
402
- * by the `lineWidth` and `fillStroke` properties. <br>
403
- * Note : using drawStroke is not recommended for performance reasons
367
+ * draw a stroke text at the specified coord, as defined by the `lineWidth` and `fillStroke` properties.
368
+ * @deprecated since 15.0.0
404
369
  * @param {CanvasRenderer|WebGLRenderer} renderer - Reference to the destination renderer instance
405
370
  * @param {string} text
406
371
  * @param {number} x
407
372
  * @param {number} y
408
373
  */
409
374
  drawStroke(renderer, text, x, y) {
410
- this.draw(renderer, text, x, y, true);
375
+ this.draw(renderer, text, x, y);
411
376
  }
412
377
 
413
378
  /**
414
379
  * @ignore
415
380
  */
416
- _drawFont(context, text, x, y, stroke = false) {
417
- setContextStyle(context, this, stroke);
381
+ _drawFont(context, text, x, y) {
382
+ setContextStyle(context, this);
418
383
 
419
- for (var i = 0; i < text.length; i++) {
420
- var string = text[i].trimEnd();
384
+ for (let i = 0; i < text.length; i++) {
385
+ let string = text[i].trimEnd();
421
386
  // draw the string
422
- context[stroke ? "strokeText" : "fillText"](string, x, y);
387
+ if (this.fillStyle.alpha > 0) {
388
+ context.fillText(string, x, y);
389
+ }
390
+ // stroke the text
391
+ if (this.lineWidth > 0 && this.strokeStyle.alpha > 0) {
392
+ context.strokeText(string, x, y);
393
+ }
423
394
  // add leading space
424
395
  y += this.metrics.lineHeight();
425
396
  }
@@ -431,15 +402,15 @@ var getContext2d = function (renderer$1, text) {
431
402
  * @ignore
432
403
  */
433
404
  destroy() {
434
- if (this.offScreenCanvas === true) {
435
- if (renderer instanceof WebGLRenderer) {
436
- renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit));
437
- this.glTextureUnit = undefined;
438
- }
439
- renderer.cache.delete(this.canvasTexture.canvas);
440
- pool.push(this.canvasTexture);
441
- this.canvasTexture = undefined;
405
+ if (typeof renderer.gl !== "undefined") {
406
+ // make sure the right compositor is active
407
+ renderer.setCompositor("quad");
408
+ renderer.currentCompositor.deleteTexture2D(renderer.currentCompositor.getTexture2D(this.glTextureUnit));
409
+ this.glTextureUnit = undefined;
442
410
  }
411
+ renderer.cache.delete(this.canvasTexture.canvas);
412
+ pool.push(this.canvasTexture);
413
+ this.canvasTexture = undefined;
443
414
  pool.push(this.fillStyle);
444
415
  pool.push(this.strokeStyle);
445
416
  this.fillStyle = this.strokeStyle = undefined;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -57,14 +57,14 @@ import setContextStyle from './textstyle.js';
57
57
  if (this.ancestor instanceof Text) {
58
58
  return context.measureText(text).width;
59
59
  } else { // it's a BitmapText
60
- var characters = text.split("");
61
- var width = 0;
62
- var lastGlyph = null;
63
- for (var i = 0; i < characters.length; i++) {
64
- var ch = characters[i].charCodeAt(0);
65
- var glyph = this.ancestor.fontData.glyphs[ch];
60
+ let characters = text.split("");
61
+ let width = 0;
62
+ let lastGlyph = null;
63
+ for (let i = 0; i < characters.length; i++) {
64
+ let ch = characters[i].charCodeAt(0);
65
+ let glyph = this.ancestor.fontData.glyphs[ch];
66
66
  if (typeof glyph !== "undefined") {
67
- var kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
67
+ let kerning = (lastGlyph && lastGlyph.kerning) ? lastGlyph.getKerning(ch) : 0;
68
68
  width += (glyph.xadvance + kerning) * this.ancestor.fontScale.x;
69
69
  lastGlyph = glyph;
70
70
  }
@@ -80,7 +80,7 @@ import setContextStyle from './textstyle.js';
80
80
  * @returns {TextMetrics} this
81
81
  */
82
82
  measureText(text, context) {
83
- var strings;
83
+ let strings;
84
84
 
85
85
  if (!Array.isArray(text)) {
86
86
  strings = ("" + text).split("\n");
@@ -99,7 +99,7 @@ import setContextStyle from './textstyle.js';
99
99
  // compute the bounding box size
100
100
  this.width = this.height = 0;
101
101
 
102
- for (var i = 0; i < strings.length; i++) {
102
+ for (let i = 0; i < strings.length; i++) {
103
103
  this.width = Math.max(this.lineWidth(strings[i].trimEnd(), context), this.width);
104
104
  this.height += this.lineHeight();
105
105
  }
@@ -130,9 +130,9 @@ import setContextStyle from './textstyle.js';
130
130
  * @returns {string[]} an array of string representing wrapped text
131
131
  */
132
132
  wordWrap(text, width, context) {
133
- var words;
134
- var currentLine = "";
135
- var output = [];
133
+ let words;
134
+ let currentLine = "";
135
+ let output = [];
136
136
 
137
137
  if (Array.isArray(text)) {
138
138
  // join into a single string
@@ -150,8 +150,8 @@ import setContextStyle from './textstyle.js';
150
150
  }
151
151
 
152
152
  for (let i = 0; i < words.length; i++) {
153
- var word = words[i];
154
- var lineWidth = this.lineWidth(currentLine + word + " ", context);
153
+ let word = words[i];
154
+ let lineWidth = this.lineWidth(currentLine + word + " ", context);
155
155
  if (lineWidth < width) {
156
156
  // add the word to the current line
157
157
  currentLine += word + " ";
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -9,13 +9,11 @@
9
9
  * apply the current text style to the given context
10
10
  * @ignore
11
11
  */
12
- function setContextStyle(context, style, stroke = false) {
12
+ function setContextStyle(context, style) {
13
13
  context.font = style.font;
14
14
  context.fillStyle = style.fillStyle.toRGBA();
15
- if (stroke === true) {
16
- context.strokeStyle = style.strokeStyle.toRGBA();
17
- context.lineWidth = style.lineWidth;
18
- }
15
+ context.strokeStyle = style.strokeStyle.toRGBA();
16
+ context.lineWidth = style.lineWidth;
19
17
  context.textAlign = style.textAlign;
20
18
  context.textBaseline = style.textBaseline;
21
19
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * melonJS Game Engine - v14.5.0
2
+ * melonJS Game Engine - v15.1.0
3
3
  * http://www.melonjs.org
4
4
  * melonjs is licensed under the MIT License.
5
5
  * http://www.opensource.org/licenses/mit-license
@@ -270,21 +270,21 @@ let Easing = {
270
270
  /** @ignore */
271
271
  In: function ( k ) {
272
272
 
273
- var s = 1.70158;
273
+ const s = 1.70158;
274
274
  return k * k * ( ( s + 1 ) * k - s );
275
275
 
276
276
  },
277
277
  /** @ignore */
278
278
  Out: function ( k ) {
279
279
 
280
- var s = 1.70158;
280
+ const s = 1.70158;
281
281
  return --k * k * ( ( s + 1 ) * k + s ) + 1;
282
282
 
283
283
  },
284
284
  /** @ignore */
285
285
  InOut: function ( k ) {
286
286
 
287
- var s = 1.70158 * 1.525;
287
+ const s = 1.70158 * 1.525;
288
288
  if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) );
289
289
  return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 );
290
290