melonjs 20.2.0 → 20.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 (515) hide show
  1. package/README.md +86 -8
  2. package/build/application/application.d.ts +0 -17
  3. package/build/application/application.d.ts.map +1 -1
  4. package/build/application/settings.d.ts +6 -2
  5. package/build/application/settings.d.ts.map +1 -1
  6. package/build/audio/audio.d.ts +2 -2
  7. package/build/audio/audio.d.ts.map +1 -1
  8. package/build/audio/backend/buffer.d.ts +26 -0
  9. package/build/audio/backend/buffer.d.ts.map +1 -0
  10. package/build/audio/backend/cache.d.ts +2 -0
  11. package/build/audio/backend/cache.d.ts.map +1 -0
  12. package/build/audio/backend/core.d.ts +24 -0
  13. package/build/audio/backend/core.d.ts.map +1 -0
  14. package/build/audio/backend/engine.d.ts +35 -0
  15. package/build/audio/backend/engine.d.ts.map +1 -0
  16. package/build/audio/backend/sound.d.ts +29 -0
  17. package/build/audio/backend/sound.d.ts.map +1 -0
  18. package/build/audio/backend/spatial.d.ts +191 -0
  19. package/build/audio/backend/spatial.d.ts.map +1 -0
  20. package/build/audio/backend/types.d.ts +107 -0
  21. package/build/audio/backend/types.d.ts.map +1 -0
  22. package/build/audio/backend/voice.d.ts +8 -0
  23. package/build/audio/backend/voice.d.ts.map +1 -0
  24. package/build/audio/playback.d.ts +49 -4
  25. package/build/audio/playback.d.ts.map +1 -1
  26. package/build/audio/procedural.d.ts.map +1 -1
  27. package/build/audio/state.d.ts +69 -0
  28. package/build/audio/state.d.ts.map +1 -0
  29. package/build/audio/types.d.ts +93 -1
  30. package/build/audio/types.d.ts.map +1 -1
  31. package/build/camera/camera2d.d.ts +0 -68
  32. package/build/camera/camera2d.d.ts.map +1 -1
  33. package/build/camera/camera3d.d.ts +91 -84
  34. package/build/camera/camera3d.d.ts.map +1 -1
  35. package/build/camera/effects/fade_effect.d.ts +0 -5
  36. package/build/camera/effects/fade_effect.d.ts.map +1 -1
  37. package/build/camera/effects/mask_effect.d.ts +0 -5
  38. package/build/camera/effects/mask_effect.d.ts.map +1 -1
  39. package/build/camera/fog.d.ts +118 -0
  40. package/build/camera/fog.d.ts.map +1 -0
  41. package/build/const.d.ts +2 -2
  42. package/build/geometries/box3d.d.ts +0 -28
  43. package/build/geometries/box3d.d.ts.map +1 -1
  44. package/build/geometries/ellipse.d.ts +0 -20
  45. package/build/geometries/ellipse.d.ts.map +1 -1
  46. package/build/geometries/observablePoint.d.ts +0 -3
  47. package/build/geometries/observablePoint.d.ts.map +1 -1
  48. package/build/geometries/path2d.d.ts +0 -19
  49. package/build/geometries/path2d.d.ts.map +1 -1
  50. package/build/geometries/polygon.d.ts +0 -12
  51. package/build/geometries/polygon.d.ts.map +1 -1
  52. package/build/geometries/roundrect.d.ts +0 -18
  53. package/build/geometries/roundrect.d.ts.map +1 -1
  54. package/build/geometries/sphere.d.ts +0 -9
  55. package/build/geometries/sphere.d.ts.map +1 -1
  56. package/build/geometries/toarccanvas.d.ts.map +1 -1
  57. package/build/index.d.ts +1 -0
  58. package/build/index.d.ts.map +1 -1
  59. package/build/index.js +12150 -11289
  60. package/build/index.js.map +4 -4
  61. package/build/input/gamepad.d.ts.map +1 -1
  62. package/build/input/input.d.ts +19 -0
  63. package/build/input/input.d.ts.map +1 -1
  64. package/build/input/pointer.d.ts +0 -4
  65. package/build/input/pointer.d.ts.map +1 -1
  66. package/build/input/pointerevent.d.ts +0 -6
  67. package/build/input/pointerevent.d.ts.map +1 -1
  68. package/build/lang/deprecated.d.ts +4 -2
  69. package/build/lang/deprecated.d.ts.map +1 -1
  70. package/build/level/gltf/GLTFModel.d.ts +0 -81
  71. package/build/level/gltf/GLTFModel.d.ts.map +1 -1
  72. package/build/level/gltf/GLTFScene.d.ts +13 -44
  73. package/build/level/gltf/GLTFScene.d.ts.map +1 -1
  74. package/build/level/gltf/gltf_sampler.d.ts +1 -48
  75. package/build/level/gltf/gltf_sampler.d.ts.map +1 -1
  76. package/build/level/level.d.ts +195 -113
  77. package/build/level/level.d.ts.map +1 -1
  78. package/build/level/tiled/TMXGroup.d.ts +1 -65
  79. package/build/level/tiled/TMXGroup.d.ts.map +1 -1
  80. package/build/level/tiled/TMXLayer.d.ts +0 -44
  81. package/build/level/tiled/TMXLayer.d.ts.map +1 -1
  82. package/build/level/tiled/TMXObject.d.ts +1 -136
  83. package/build/level/tiled/TMXObject.d.ts.map +1 -1
  84. package/build/level/tiled/TMXObjectFactory.d.ts +1 -40
  85. package/build/level/tiled/TMXObjectFactory.d.ts.map +1 -1
  86. package/build/level/tiled/TMXTile.d.ts +1 -30
  87. package/build/level/tiled/TMXTile.d.ts.map +1 -1
  88. package/build/level/tiled/TMXTileMap.d.ts +0 -10
  89. package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
  90. package/build/level/tiled/TMXTileset.d.ts +0 -113
  91. package/build/level/tiled/TMXTileset.d.ts.map +1 -1
  92. package/build/level/tiled/TMXTilesetGroup.d.ts +0 -1
  93. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -1
  94. package/build/level/tiled/TMXUtils.d.ts +1 -43
  95. package/build/level/tiled/TMXUtils.d.ts.map +1 -1
  96. package/build/level/tiled/factories/shape.d.ts +1 -7
  97. package/build/level/tiled/factories/shape.d.ts.map +1 -1
  98. package/build/level/tiled/factories/text.d.ts +1 -7
  99. package/build/level/tiled/factories/text.d.ts.map +1 -1
  100. package/build/level/tiled/factories/tile.d.ts +1 -7
  101. package/build/level/tiled/factories/tile.d.ts.map +1 -1
  102. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts +0 -60
  103. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
  104. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts +0 -42
  105. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
  106. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +0 -5
  107. package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
  108. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +0 -31
  109. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
  110. package/build/level/tiled/renderer/TMXRenderer.d.ts +2 -2
  111. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
  112. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
  113. package/build/level/tiled/renderer/autodetect.d.ts +1 -6
  114. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -1
  115. package/build/lighting/light2d.d.ts +0 -25
  116. package/build/lighting/light2d.d.ts.map +1 -1
  117. package/build/lighting/light3d.d.ts +0 -16
  118. package/build/lighting/light3d.d.ts.map +1 -1
  119. package/build/loader/loader.d.ts +46 -73
  120. package/build/loader/loader.d.ts.map +1 -1
  121. package/build/loader/loadingscreen.d.ts +0 -33
  122. package/build/loader/loadingscreen.d.ts.map +1 -1
  123. package/build/loader/parsers/aseprite.d.ts +0 -13
  124. package/build/loader/parsers/aseprite.d.ts.map +1 -1
  125. package/build/loader/parsers/audio.d.ts +2 -0
  126. package/build/loader/parsers/audio.d.ts.map +1 -0
  127. package/build/loader/parsers/binary.d.ts +1 -10
  128. package/build/loader/parsers/binary.d.ts.map +1 -1
  129. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -1
  130. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +1 -7
  131. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -1
  132. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +1 -7
  133. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -1
  134. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +1 -7
  135. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -1
  136. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +1 -7
  137. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -1
  138. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +1 -7
  139. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -1
  140. package/build/loader/parsers/fontface.d.ts +1 -13
  141. package/build/loader/parsers/fontface.d.ts.map +1 -1
  142. package/build/loader/parsers/gltf.d.ts +1 -70
  143. package/build/loader/parsers/gltf.d.ts.map +1 -1
  144. package/build/loader/parsers/image.d.ts +1 -22
  145. package/build/loader/parsers/image.d.ts.map +1 -1
  146. package/build/loader/parsers/json.d.ts +1 -10
  147. package/build/loader/parsers/json.d.ts.map +1 -1
  148. package/build/loader/parsers/mtl.d.ts +1 -28
  149. package/build/loader/parsers/mtl.d.ts.map +1 -1
  150. package/build/loader/parsers/obj.d.ts +1 -59
  151. package/build/loader/parsers/obj.d.ts.map +1 -1
  152. package/build/loader/parsers/pbr.d.ts +1 -62
  153. package/build/loader/parsers/pbr.d.ts.map +1 -1
  154. package/build/loader/parsers/script.d.ts +1 -10
  155. package/build/loader/parsers/script.d.ts.map +1 -1
  156. package/build/loader/parsers/shader.d.ts +1 -52
  157. package/build/loader/parsers/shader.d.ts.map +1 -1
  158. package/build/loader/parsers/tmx.d.ts +1 -10
  159. package/build/loader/parsers/tmx.d.ts.map +1 -1
  160. package/build/loader/parsers/video.d.ts +1 -10
  161. package/build/loader/parsers/video.d.ts.map +1 -1
  162. package/build/math/color.d.ts.map +1 -1
  163. package/build/math/noise.d.ts +0 -40
  164. package/build/math/noise.d.ts.map +1 -1
  165. package/build/math/observableVector2d.d.ts +0 -3
  166. package/build/math/observableVector2d.d.ts.map +1 -1
  167. package/build/math/observableVector3d.d.ts +0 -3
  168. package/build/math/observableVector3d.d.ts.map +1 -1
  169. package/build/math/vector2d.d.ts +0 -6
  170. package/build/math/vector2d.d.ts.map +1 -1
  171. package/build/math/vertex.d.ts +25 -0
  172. package/build/math/vertex.d.ts.map +1 -1
  173. package/build/particles/emitter.d.ts +0 -65
  174. package/build/particles/emitter.d.ts.map +1 -1
  175. package/build/particles/particle.d.ts +0 -81
  176. package/build/particles/particle.d.ts.map +1 -1
  177. package/build/physics/adapter.d.ts +3 -3
  178. package/build/physics/bounds.d.ts +0 -1
  179. package/build/physics/bounds.d.ts.map +1 -1
  180. package/build/physics/broadphase/broadphase.d.ts +0 -7
  181. package/build/physics/broadphase/broadphase.d.ts.map +1 -1
  182. package/build/physics/broadphase/octree.d.ts +0 -91
  183. package/build/physics/broadphase/octree.d.ts.map +1 -1
  184. package/build/physics/broadphase/quadtree.d.ts +0 -47
  185. package/build/physics/broadphase/quadtree.d.ts.map +1 -1
  186. package/build/physics/builtin/body.d.ts +5 -69
  187. package/build/physics/builtin/body.d.ts.map +1 -1
  188. package/build/physics/builtin/detector.d.ts +0 -312
  189. package/build/physics/builtin/detector.d.ts.map +1 -1
  190. package/build/physics/builtin/sat.d.ts +1 -48
  191. package/build/physics/builtin/sat.d.ts.map +1 -1
  192. package/build/physics/builtin/sat3d.d.ts +1 -56
  193. package/build/physics/builtin/sat3d.d.ts.map +1 -1
  194. package/build/physics/collision.d.ts +0 -2
  195. package/build/physics/collision.d.ts.map +1 -1
  196. package/build/physics/response.d.ts +0 -1
  197. package/build/physics/response.d.ts.map +1 -1
  198. package/build/physics/world.d.ts.map +1 -1
  199. package/build/plugin/plugin.d.ts +9 -1
  200. package/build/plugin/plugin.d.ts.map +1 -1
  201. package/build/polyfill/index.d.ts +1 -4
  202. package/build/polyfill/index.d.ts.map +1 -1
  203. package/build/renderable/anchorPoint.d.ts +1 -73
  204. package/build/renderable/anchorPoint.d.ts.map +1 -1
  205. package/build/renderable/animation.d.ts +0 -7
  206. package/build/renderable/animation.d.ts.map +1 -1
  207. package/build/renderable/colorlayer.d.ts +0 -5
  208. package/build/renderable/colorlayer.d.ts.map +1 -1
  209. package/build/renderable/container.d.ts +0 -55
  210. package/build/renderable/container.d.ts.map +1 -1
  211. package/build/renderable/draggable.d.ts +0 -5
  212. package/build/renderable/draggable.d.ts.map +1 -1
  213. package/build/renderable/dragndrop.d.ts +1 -12
  214. package/build/renderable/dragndrop.d.ts.map +1 -1
  215. package/build/renderable/entity/entity.d.ts +0 -8
  216. package/build/renderable/entity/entity.d.ts.map +1 -1
  217. package/build/renderable/frameAnimation.d.ts +0 -41
  218. package/build/renderable/frameAnimation.d.ts.map +1 -1
  219. package/build/renderable/groundshadow.d.ts +1 -91
  220. package/build/renderable/groundshadow.d.ts.map +1 -1
  221. package/build/renderable/imagelayer.d.ts +0 -29
  222. package/build/renderable/imagelayer.d.ts.map +1 -1
  223. package/build/renderable/instanced_mesh.d.ts +26 -104
  224. package/build/renderable/instanced_mesh.d.ts.map +1 -1
  225. package/build/renderable/mesh.d.ts +145 -140
  226. package/build/renderable/mesh.d.ts.map +1 -1
  227. package/build/renderable/nineslicesprite.d.ts +0 -4
  228. package/build/renderable/nineslicesprite.d.ts.map +1 -1
  229. package/build/renderable/renderable.d.ts +17 -54
  230. package/build/renderable/renderable.d.ts.map +1 -1
  231. package/build/renderable/sprite.d.ts +7 -52
  232. package/build/renderable/sprite.d.ts.map +1 -1
  233. package/build/renderable/sprite3d.d.ts +0 -95
  234. package/build/renderable/sprite3d.d.ts.map +1 -1
  235. package/build/renderable/text/bitmaptext.d.ts +0 -14
  236. package/build/renderable/text/bitmaptext.d.ts.map +1 -1
  237. package/build/renderable/text/bitmaptextdata.d.ts +0 -22
  238. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -1
  239. package/build/renderable/text/glyph.d.ts +1 -39
  240. package/build/renderable/text/glyph.d.ts.map +1 -1
  241. package/build/renderable/text/text.d.ts +0 -20
  242. package/build/renderable/text/text.d.ts.map +1 -1
  243. package/build/renderable/text/textstyle.d.ts +1 -5
  244. package/build/renderable/text/textstyle.d.ts.map +1 -1
  245. package/build/renderable/trail.d.ts +0 -29
  246. package/build/renderable/trail.d.ts.map +1 -1
  247. package/build/renderable/trigger.d.ts +0 -6
  248. package/build/renderable/trigger.d.ts.map +1 -1
  249. package/build/renderable/ui/uibaseelement.d.ts +0 -40
  250. package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
  251. package/build/renderable/ui/uispriteelement.d.ts +0 -35
  252. package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
  253. package/build/state/stage.d.ts +4 -68
  254. package/build/state/stage.d.ts.map +1 -1
  255. package/build/state/state.d.ts.map +1 -1
  256. package/build/system/device.d.ts +0 -12
  257. package/build/system/device.d.ts.map +1 -1
  258. package/build/system/dom.d.ts +1 -8
  259. package/build/system/dom.d.ts.map +1 -1
  260. package/build/system/event.d.ts +1 -1
  261. package/build/system/legacy_pool.d.ts +1 -6
  262. package/build/system/legacy_pool.d.ts.map +1 -1
  263. package/build/system/platform.d.ts +21 -2
  264. package/build/system/platform.d.ts.map +1 -1
  265. package/build/system/pool.d.ts +0 -9
  266. package/build/system/pool.d.ts.map +1 -1
  267. package/build/system/save.d.ts.map +1 -1
  268. package/build/system/timer.d.ts +0 -20
  269. package/build/system/timer.d.ts.map +1 -1
  270. package/build/tweens/tween.d.ts +0 -62
  271. package/build/tweens/tween.d.ts.map +1 -1
  272. package/build/utils/array-multimap.d.ts +1 -13
  273. package/build/utils/array-multimap.d.ts.map +1 -1
  274. package/build/utils/decode.d.ts.map +1 -1
  275. package/build/utils/fetchdata.d.ts +2 -0
  276. package/build/utils/fetchdata.d.ts.map +1 -0
  277. package/build/utils/utils.d.ts +0 -13
  278. package/build/utils/utils.d.ts.map +1 -1
  279. package/build/video/blendmodes.d.ts +1 -106
  280. package/build/video/blendmodes.d.ts.map +1 -1
  281. package/build/video/buffer/index.d.ts +1 -39
  282. package/build/video/buffer/index.d.ts.map +1 -1
  283. package/build/video/buffer/vertex.d.ts +1 -82
  284. package/build/video/buffer/vertex.d.ts.map +1 -1
  285. package/build/video/canvas/canvas_renderer.d.ts +7 -25
  286. package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
  287. package/build/video/canvas_factory.d.ts +1 -24
  288. package/build/video/canvas_factory.d.ts.map +1 -1
  289. package/build/video/effects/blendEffect.d.ts +0 -54
  290. package/build/video/effects/blendEffect.d.ts.map +1 -1
  291. package/build/video/effects/blur.d.ts +4 -4
  292. package/build/video/effects/blur.d.ts.map +1 -1
  293. package/build/video/effects/chromaticAberration.d.ts +5 -5
  294. package/build/video/effects/chromaticAberration.d.ts.map +1 -1
  295. package/build/video/effects/colorMatrix.d.ts +5 -15
  296. package/build/video/effects/colorMatrix.d.ts.map +1 -1
  297. package/build/video/effects/desaturate.d.ts +5 -5
  298. package/build/video/effects/desaturate.d.ts.map +1 -1
  299. package/build/video/effects/dissolve.d.ts +4 -4
  300. package/build/video/effects/dissolve.d.ts.map +1 -1
  301. package/build/video/effects/dropShadow.d.ts +5 -5
  302. package/build/video/effects/dropShadow.d.ts.map +1 -1
  303. package/build/video/effects/flash.d.ts +4 -4
  304. package/build/video/effects/flash.d.ts.map +1 -1
  305. package/build/video/effects/glow.d.ts +5 -5
  306. package/build/video/effects/glow.d.ts.map +1 -1
  307. package/build/video/effects/glsl_realization.d.ts +1 -17
  308. package/build/video/effects/glsl_realization.d.ts.map +1 -1
  309. package/build/video/effects/hologram.d.ts +4 -4
  310. package/build/video/effects/hologram.d.ts.map +1 -1
  311. package/build/video/effects/invert.d.ts +5 -5
  312. package/build/video/effects/invert.d.ts.map +1 -1
  313. package/build/video/effects/outline.d.ts +6 -6
  314. package/build/video/effects/outline.d.ts.map +1 -1
  315. package/build/video/effects/pixelate.d.ts +4 -4
  316. package/build/video/effects/pixelate.d.ts.map +1 -1
  317. package/build/video/effects/radialGradient.d.ts +2 -3
  318. package/build/video/effects/radialGradient.d.ts.map +1 -1
  319. package/build/video/effects/scanline.d.ts +6 -6
  320. package/build/video/effects/scanline.d.ts.map +1 -1
  321. package/build/video/effects/sepia.d.ts +5 -5
  322. package/build/video/effects/sepia.d.ts.map +1 -1
  323. package/build/video/effects/shadereffect.d.ts +12 -123
  324. package/build/video/effects/shadereffect.d.ts.map +1 -1
  325. package/build/video/effects/shine.d.ts +3 -3
  326. package/build/video/effects/shine.d.ts.map +1 -1
  327. package/build/video/effects/tintPulse.d.ts +4 -4
  328. package/build/video/effects/tintPulse.d.ts.map +1 -1
  329. package/build/video/effects/vignette.d.ts +6 -6
  330. package/build/video/effects/vignette.d.ts.map +1 -1
  331. package/build/video/effects/wave.d.ts +4 -4
  332. package/build/video/effects/wave.d.ts.map +1 -1
  333. package/build/video/effects/wgsl/layout.d.ts +1 -27
  334. package/build/video/effects/wgsl/layout.d.ts.map +1 -1
  335. package/build/video/effects/wgsl/parse.d.ts +1 -8
  336. package/build/video/effects/wgsl/parse.d.ts.map +1 -1
  337. package/build/video/effects/wgsl/scaffold.d.ts +1 -42
  338. package/build/video/effects/wgsl/scaffold.d.ts.map +1 -1
  339. package/build/video/effects/wgsl_realization.d.ts +1 -82
  340. package/build/video/effects/wgsl_realization.d.ts.map +1 -1
  341. package/build/video/gpu/batcher.d.ts +1 -13
  342. package/build/video/gpu/batcher.d.ts.map +1 -1
  343. package/build/video/gpu/instancerecord.d.ts +1 -163
  344. package/build/video/gpu/instancerecord.d.ts.map +1 -1
  345. package/build/video/gpu/meshchunk.d.ts +1 -48
  346. package/build/video/gpu/meshchunk.d.ts.map +1 -1
  347. package/build/video/gpu/meshvertex.d.ts +1 -53
  348. package/build/video/gpu/meshvertex.d.ts.map +1 -1
  349. package/build/video/gpu/primitives.d.ts +1 -59
  350. package/build/video/gpu/primitives.d.ts.map +1 -1
  351. package/build/video/gpu/quadcorners.d.ts +1 -10
  352. package/build/video/gpu/quadcorners.d.ts.map +1 -1
  353. package/build/video/gpu/textureslots.d.ts +1 -121
  354. package/build/video/gpu/textureslots.d.ts.map +1 -1
  355. package/build/video/gpu/texturestore.d.ts +1 -138
  356. package/build/video/gpu/texturestore.d.ts.map +1 -1
  357. package/build/video/gpu/topology.d.ts.map +1 -1
  358. package/build/video/gpu/vertexformat.d.ts +0 -28
  359. package/build/video/gpu/vertexformat.d.ts.map +1 -1
  360. package/build/video/gradient.d.ts +0 -81
  361. package/build/video/gradient.d.ts.map +1 -1
  362. package/build/video/renderer.d.ts +21 -102
  363. package/build/video/renderer.d.ts.map +1 -1
  364. package/build/video/renderstate.d.ts +0 -51
  365. package/build/video/renderstate.d.ts.map +1 -1
  366. package/build/video/rendertarget/canvasrendertarget.d.ts +0 -10
  367. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -1
  368. package/build/video/rendertarget/render_target_pool.d.ts +1 -82
  369. package/build/video/rendertarget/render_target_pool.d.ts.map +1 -1
  370. package/build/video/rendertarget/webglrendertarget.d.ts +1 -64
  371. package/build/video/rendertarget/webglrendertarget.d.ts.map +1 -1
  372. package/build/video/rendertarget/webgpurendertarget.d.ts +0 -8
  373. package/build/video/rendertarget/webgpurendertarget.d.ts.map +1 -1
  374. package/build/video/texture/atlas.d.ts +2 -76
  375. package/build/video/texture/atlas.d.ts.map +1 -1
  376. package/build/video/texture/cache.d.ts +0 -136
  377. package/build/video/texture/cache.d.ts.map +1 -1
  378. package/build/video/texture/frametexture.d.ts +1 -71
  379. package/build/video/texture/frametexture.d.ts.map +1 -1
  380. package/build/video/texture/noise_texture2d.d.ts +0 -43
  381. package/build/video/texture/noise_texture2d.d.ts.map +1 -1
  382. package/build/video/texture/parser/aseprite.d.ts +1 -8
  383. package/build/video/texture/parser/aseprite.d.ts.map +1 -1
  384. package/build/video/texture/parser/spritesheet.d.ts +1 -8
  385. package/build/video/texture/parser/spritesheet.d.ts.map +1 -1
  386. package/build/video/texture/parser/texturepacker.d.ts +1 -8
  387. package/build/video/texture/parser/texturepacker.d.ts.map +1 -1
  388. package/build/video/texture/resource.d.ts +0 -9
  389. package/build/video/texture/resource.d.ts.map +1 -1
  390. package/build/video/texture/texture2d.d.ts +0 -11
  391. package/build/video/texture/texture2d.d.ts.map +1 -1
  392. package/build/video/utils/autodetect.d.ts +1 -5
  393. package/build/video/utils/autodetect.d.ts.map +1 -1
  394. package/build/video/webgl/batchers/batcher.d.ts +0 -55
  395. package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
  396. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts +0 -14
  397. package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
  398. package/build/video/webgl/batchers/lit_quad_batcher.d.ts +0 -72
  399. package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
  400. package/build/video/webgl/batchers/material_batcher.d.ts +0 -89
  401. package/build/video/webgl/batchers/material_batcher.d.ts.map +1 -1
  402. package/build/video/webgl/batchers/mesh_batcher.d.ts +14 -343
  403. package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
  404. package/build/video/webgl/batchers/primitive_batcher.d.ts +0 -10
  405. package/build/video/webgl/batchers/primitive_batcher.d.ts.map +1 -1
  406. package/build/video/webgl/batchers/quad_batcher.d.ts +0 -30
  407. package/build/video/webgl/batchers/quad_batcher.d.ts.map +1 -1
  408. package/build/video/webgl/buffer/index.d.ts +1 -36
  409. package/build/video/webgl/buffer/index.d.ts.map +1 -1
  410. package/build/video/webgl/buffer/instance_buffer.d.ts +1 -53
  411. package/build/video/webgl/buffer/instance_buffer.d.ts.map +1 -1
  412. package/build/video/webgl/buffer/retained_geometry.d.ts +1 -81
  413. package/build/video/webgl/buffer/retained_geometry.d.ts.map +1 -1
  414. package/build/video/webgl/buffer/uniformblock.d.ts +1 -80
  415. package/build/video/webgl/buffer/uniformblock.d.ts.map +1 -1
  416. package/build/video/webgl/buffer/vertexstate.d.ts +1 -100
  417. package/build/video/webgl/buffer/vertexstate.d.ts.map +1 -1
  418. package/build/video/webgl/glshader.d.ts +2 -51
  419. package/build/video/webgl/glshader.d.ts.map +1 -1
  420. package/build/video/webgl/lighting/pack3d.d.ts +1 -47
  421. package/build/video/webgl/lighting/pack3d.d.ts.map +1 -1
  422. package/build/video/webgl/lighting/std140.d.ts +1 -109
  423. package/build/video/webgl/lighting/std140.d.ts.map +1 -1
  424. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts +1 -103
  425. package/build/video/webgl/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  426. package/build/video/webgl/shaders/multitexture-lit.d.ts +1 -26
  427. package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
  428. package/build/video/webgl/shaders/multitexture.d.ts +1 -9
  429. package/build/video/webgl/shaders/multitexture.d.ts.map +1 -1
  430. package/build/video/webgl/texture/store.d.ts +1 -50
  431. package/build/video/webgl/texture/store.d.ts.map +1 -1
  432. package/build/video/webgl/utils/attributes.d.ts +1 -11
  433. package/build/video/webgl/utils/attributes.d.ts.map +1 -1
  434. package/build/video/webgl/utils/maxtextures.d.ts +1 -36
  435. package/build/video/webgl/utils/maxtextures.d.ts.map +1 -1
  436. package/build/video/webgl/utils/precision.d.ts +1 -14
  437. package/build/video/webgl/utils/precision.d.ts.map +1 -1
  438. package/build/video/webgl/utils/program.d.ts +1 -5
  439. package/build/video/webgl/utils/program.d.ts.map +1 -1
  440. package/build/video/webgl/utils/samplercache.d.ts +1 -68
  441. package/build/video/webgl/utils/samplercache.d.ts.map +1 -1
  442. package/build/video/webgl/utils/string.d.ts +1 -21
  443. package/build/video/webgl/utils/string.d.ts.map +1 -1
  444. package/build/video/webgl/utils/topology.d.ts +1 -23
  445. package/build/video/webgl/utils/topology.d.ts.map +1 -1
  446. package/build/video/webgl/utils/uniforms.d.ts +1 -25
  447. package/build/video/webgl/utils/uniforms.d.ts.map +1 -1
  448. package/build/video/webgl/utils/vertexformat.d.ts +1 -26
  449. package/build/video/webgl/utils/vertexformat.d.ts.map +1 -1
  450. package/build/video/webgl/webgl_renderer.d.ts +24 -286
  451. package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
  452. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts +0 -6
  453. package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
  454. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +0 -8
  455. package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
  456. package/build/video/webgpu/batchers/mesh_batcher.d.ts +1 -230
  457. package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
  458. package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
  459. package/build/video/webgpu/batchers/quad_batcher.d.ts +0 -82
  460. package/build/video/webgpu/batchers/quad_batcher.d.ts.map +1 -1
  461. package/build/video/webgpu/buffer/arena.d.ts +1 -63
  462. package/build/video/webgpu/buffer/arena.d.ts.map +1 -1
  463. package/build/video/webgpu/buffer/instance_buffer.d.ts +1 -64
  464. package/build/video/webgpu/buffer/instance_buffer.d.ts.map +1 -1
  465. package/build/video/webgpu/buffer/retained_geometry.d.ts +1 -54
  466. package/build/video/webgpu/buffer/retained_geometry.d.ts.map +1 -1
  467. package/build/video/webgpu/buffer/uniformring.d.ts +1 -67
  468. package/build/video/webgpu/buffer/uniformring.d.ts.map +1 -1
  469. package/build/video/webgpu/effect_binding.d.ts +1 -16
  470. package/build/video/webgpu/effect_binding.d.ts.map +1 -1
  471. package/build/video/webgpu/pipeline/bindgroups.d.ts +1 -32
  472. package/build/video/webgpu/pipeline/bindgroups.d.ts.map +1 -1
  473. package/build/video/webgpu/pipeline/cache.d.ts +1 -163
  474. package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
  475. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts +1 -87
  476. package/build/video/webgpu/renderers/tmxlayer/orthogonal.d.ts.map +1 -1
  477. package/build/video/webgpu/shaders/mesh-instanced.d.ts +1 -43
  478. package/build/video/webgpu/shaders/mesh-instanced.d.ts.map +1 -1
  479. package/build/video/webgpu/texture/compressed.d.ts +1 -32
  480. package/build/video/webgpu/texture/compressed.d.ts.map +1 -1
  481. package/build/video/webgpu/texture/frametexture.d.ts +1 -62
  482. package/build/video/webgpu/texture/frametexture.d.ts.map +1 -1
  483. package/build/video/webgpu/texture/store.d.ts +1 -147
  484. package/build/video/webgpu/texture/store.d.ts.map +1 -1
  485. package/build/video/webgpu/webgpu_renderer.d.ts +2 -89
  486. package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
  487. package/package.json +8 -11
  488. package/skills/AGENTS.md +67 -0
  489. package/skills/melonjs/SKILL.md +156 -0
  490. package/skills/melonjs-20-migration/SKILL.md +160 -0
  491. package/skills/melonjs-3d/SKILL.md +525 -0
  492. package/skills/melonjs-3d-assets/SKILL.md +258 -0
  493. package/skills/melonjs-audio/SKILL.md +236 -0
  494. package/skills/melonjs-camera-and-drawing/SKILL.md +175 -0
  495. package/skills/melonjs-deployment/SKILL.md +113 -0
  496. package/skills/melonjs-effects-and-shaders/SKILL.md +178 -0
  497. package/skills/melonjs-events/SKILL.md +159 -0
  498. package/skills/melonjs-getting-started/SKILL.md +183 -0
  499. package/skills/melonjs-input/SKILL.md +166 -0
  500. package/skills/melonjs-lighting/SKILL.md +139 -0
  501. package/skills/melonjs-loading-assets/SKILL.md +186 -0
  502. package/skills/melonjs-particles-and-trails/SKILL.md +136 -0
  503. package/skills/melonjs-performance/SKILL.md +183 -0
  504. package/skills/melonjs-physics/SKILL.md +321 -0
  505. package/skills/melonjs-plugins/SKILL.md +191 -0
  506. package/skills/melonjs-renderables/SKILL.md +214 -0
  507. package/skills/melonjs-renderer-backends/SKILL.md +173 -0
  508. package/skills/melonjs-scenes-and-state/SKILL.md +180 -0
  509. package/skills/melonjs-sprites-and-animation/SKILL.md +173 -0
  510. package/skills/melonjs-tilemaps/SKILL.md +213 -0
  511. package/skills/melonjs-ui-and-text/SKILL.md +65 -0
  512. package/build/audio/backend.d.ts +0 -140
  513. package/build/audio/backend.d.ts.map +0 -1
  514. package/build/loader/parsers/fetchdata.d.ts +0 -32
  515. package/build/loader/parsers/fetchdata.d.ts.map +0 -1
@@ -0,0 +1,180 @@
1
+ ---
2
+ name: melonjs-scenes-and-state
3
+ description: "Use this skill for scene structure and game flow in melonJS — Stage subclasses, the state manager, transitions, pausing, the update loop, timers and tweens. Covers onResetEvent versus the constructor, state.set before state.change, the camera and world lifecycle per stage, and pause-aware timing. Triggers on: Stage, state, state.set, state.change, state.transition, state.pause, onResetEvent, onDestroyEvent, onActivateEvent, onDeactivateEvent, PLAY, MENU, LOADING, update loop, GAME_UPDATE, timer, setTimeout, setInterval, Tween, freeze."
4
+ license: MIT
5
+ ---
6
+
7
+ # Scenes, game state and timing
8
+
9
+ ## Stages and the state manager
10
+
11
+ A `Stage` is a screen. Register it against a state id, then change to it:
12
+
13
+ ```js
14
+ import { Stage, state } from "melonjs";
15
+
16
+ class PlayScreen extends Stage {
17
+ onResetEvent(app) { /* build the scene */ }
18
+ onDestroyEvent(app) { /* tear it down */ }
19
+ }
20
+
21
+ state.set(state.PLAY, new PlayScreen()); // register first
22
+ state.change(state.PLAY); // then switch
23
+ ```
24
+
25
+ Built-in ids: `state.LOADING`, `state.MENU`, `state.READY`, `state.PLAY`,
26
+ `state.GAMEOVER` (no underscore), `state.GAME_END`, `state.SCORE`,
27
+ `state.CREDITS`, `state.SETTINGS`, `state.DEFAULT`. `state.USER` (100) is the
28
+ base for your own ids — `const CUTSCENE = state.USER + 1`.
29
+
30
+ **Build scene content in `onResetEvent`, not the constructor.** `onResetEvent`
31
+ runs on *every* entry to the state; the constructor runs once. Scene content
32
+ created in the constructor exists once and is not rebuilt when you return.
33
+
34
+ `onResetEvent(app)` receives the `Application` — use that rather than importing
35
+ the global `game`.
36
+
37
+ Extra arguments to `state.change` are forwarded:
38
+
39
+ ```js
40
+ state.change(state.PLAY, false, { level: 2 }); // → onResetEvent(app, { level: 2 })
41
+ ```
42
+
43
+ The second argument is `forceChange`: pass `true` to switch immediately instead
44
+ of on a deferred tick, which is what you want when changing state right after a
45
+ preload completes. It is ignored when a transition is configured — a transition
46
+ always drives the switch from its own completion callback.
47
+
48
+ `state.change` **throws** `Undefined Stage for state '<id>'` if nothing was
49
+ registered for that id, and `state.set` throws if the second argument is not a
50
+ `Stage` instance. Neither fails quietly.
51
+
52
+ ## Persistent objects across levels
53
+
54
+ ```js
55
+ if (typeof this.HUD === "undefined") {
56
+ this.HUD = new Container(); // construct once (or UIBaseElement)
57
+ }
58
+ this.HUD.isPersistent = true; // survives level changes
59
+ this.HUD.floating = true; // screen coordinates, not world
60
+ app.world.addChild(this.HUD, 100); // explicit z — see melonjs-renderables
61
+ ```
62
+
63
+ ## Transitions and pausing
64
+
65
+ ```js
66
+ state.transition("fade", "#FFFFFF", 250);
67
+ state.transition("mask", "#000", 500, new Ellipse(0, 0, 1, 1)); // shape required
68
+ state.pause(); // freeze update, keep drawing
69
+ state.resume();
70
+ app.freeze(150); // brief hit-stop (proxies state.freeze)
71
+ ```
72
+
73
+ `state.transition` is global and sticky — once set it applies to every later
74
+ `state.change`. The `"mask"` form needs its fourth argument, an `Ellipse` or
75
+ `Polygon`; without one it warns and falls back to a direct switch.
76
+
77
+ ## The update loop
78
+
79
+ There is no loop you own. Logic goes in `update(dt)` overrides, or a
80
+ `GAME_UPDATE` subscription for scene-level animation:
81
+
82
+ ```js
83
+ event.on(event.GAME_UPDATE, () => { /* per frame */ });
84
+ ```
85
+
86
+ `update(dt)` must **return `true`** when the object changed and needs redrawing.
87
+ Returning nothing is falsy and the object can appear frozen while its state moves.
88
+
89
+ `dt` is milliseconds since the last frame and is the right basis for motion —
90
+ the engine already paces it. Do not reach for `performance.now()`.
91
+
92
+ A common idiom for a per-frame game controller with nothing to draw is a
93
+ `Renderable(0, 0, 1, 1)` with `alwaysUpdate = true` and an empty `draw()`.
94
+
95
+ ## Timers: use the engine's, not the window's
96
+
97
+ ```js
98
+ import { timer } from "melonjs";
99
+
100
+ timer.setTimeout(fn, 1000);
101
+ const id = timer.setInterval(fn, 500);
102
+ timer.clearInterval(id); // in the Stage's onDestroyEvent
103
+ ```
104
+
105
+ `Stage` has only `onResetEvent` and `onDestroyEvent` — there is no
106
+ `onActivateEvent` / `onDeactivateEvent` on a stage. Those two are `Renderable`
107
+ hooks; put per-renderable teardown there instead.
108
+
109
+ Engine timers are **pause-aware**. `window.setTimeout` keeps firing while the
110
+ game is paused, which produces enemies spawning behind a pause menu. Pass
111
+ `false` as the third argument — `timer.setInterval(fn, 500, false)` — for one
112
+ that keeps running through a pause, which is what a pause-menu animation or a
113
+ countdown that should not freeze needs. (That argument was ignored by
114
+ `setInterval` before 20.3.)
115
+
116
+ ## Tweens
117
+
118
+ ```js
119
+ import { Tween, pool } from "melonjs";
120
+
121
+ const t = pool.pull("Tween", sprite.pos) // registered name is "Tween"
122
+ .to({ x: 300 }, { duration: 500 }) // options object, not a number
123
+ .easing(Tween.Easing.Quadratic.Out)
124
+ .onComplete(() => { /* … */ })
125
+ .start(); // ← without this, nothing happens
126
+ ```
127
+
128
+ Four traps:
129
+
130
+ - **A tween without `.start()`** (or `autoStart: true` in the `to()` options)
131
+ silently does nothing.
132
+ - **`to()`'s second argument is an options object**
133
+ (`{ duration, easing, yoyo, repeat, delay, repeatDelay, interpolation,
134
+ autoStart }`). Passing a bare number is not a duration — it is read for a
135
+ `.duration` property, finds none, and the tween silently runs the default
136
+ 1000 ms.
137
+ - **Tweens freeze during `state.pause()` / `freeze()`** unless
138
+ `tween.updateWhenPaused = true` — which is how you get an effect that decays
139
+ *through* a hit-stop.
140
+ - **Stop a tween before destroying its target**, or `onUpdate` fires against a
141
+ dead renderable.
142
+
143
+ ## Guard teardown-adjacent callbacks
144
+
145
+ Callbacks can fire while a stage is being torn down, when the current state is
146
+ already something else:
147
+
148
+ ```js
149
+ if (!state.isCurrent(state.PLAY)) return;
150
+ ```
151
+
152
+ Without the guard, a "children emptied" handler can reset the wrong stage.
153
+
154
+ ## Persistence
155
+
156
+ ```js
157
+ import { save } from "melonjs";
158
+
159
+ save.add({ hiscore: 0 }); // once; idempotent, loads any stored value
160
+ save.hiscore = 1200; // plain assignment writes to localStorage
161
+ ```
162
+
163
+ ## Symptom → cause
164
+
165
+ | symptom | cause |
166
+ |---|---|
167
+ | scene builds once and is empty on return | content created in the constructor, not `onResetEvent` |
168
+ | `Undefined Stage for state 'N'` thrown | no `state.set` for that id first |
169
+ | a tween finishes in 1000 ms whatever you pass | `to()` takes `{ duration }`, not a number |
170
+ | object frozen while its state updates | `update()` not returning `true` |
171
+ | timers fire behind a pause menu | `window.setTimeout` instead of `timer.setTimeout` |
172
+ | a tween does nothing | `.start()` never called |
173
+ | effect stops during a hit-stop | tween needs `updateWhenPaused = true` |
174
+ | crash after a stage switch | callback ran during teardown — guard with `state.isCurrent` |
175
+ | HUD scrolls away with the camera | missing `floating = true` |
176
+
177
+ ## Related skills
178
+
179
+ - `melonjs-getting-started` — the Application and the first scene
180
+ - `melonjs-renderables` — `floating`, draw order, update/draw contracts
@@ -0,0 +1,173 @@
1
+ ---
2
+ name: melonjs-sprites-and-animation
3
+ description: "Use this skill when creating sprites, playing frame animations, or working with texture atlases in melonJS. Covers Sprite construction from a plain image or an atlas region, addAnimation/setCurrentAnimation, TextureAtlas for TexturePacker/ShoeBox/Aseprite, tint, flip, NineSliceSprite, and the centred anchorPoint that offsets naive positioning. Triggers on: Sprite, new Sprite, addAnimation, setCurrentAnimation, isCurrentAnimation, TextureAtlas, TexturePacker, Aseprite, ShoeBox, atlas, region, framewidth, frameheight, tint, flipX, flipY, NineSliceSprite, animation."
4
+ license: MIT
5
+ ---
6
+
7
+ # Sprites, animation and atlases
8
+
9
+ > Creating sprites from images or atlases, driving frame animation, and the
10
+ > positioning trap that catches almost everyone.
11
+
12
+ ## `pos` is the centre, not the top-left
13
+
14
+ `Renderable.anchorPoint` defaults to **`(0.5, 0.5)`**, so a sprite's `pos` is its
15
+ **centre**. `Container` forces `(0, 0)` instead, which is why containers and
16
+ sprites appear to disagree.
17
+
18
+ ```js
19
+ // a 64×64 sprite at (100, 100) covers 68..132, not 100..164
20
+ const s = new Sprite(100, 100, { image: "hero", framewidth: 64, frameheight: 64 });
21
+
22
+ s.anchorPoint.set(0, 0); // switch to top-left positioning if you prefer
23
+ ```
24
+
25
+ Writing top-left maths against the centred default puts everything half a sprite
26
+ off, with no error. It is the most common source of "close but subtly wrong"
27
+ placement.
28
+
29
+ ## Constructing a sprite
30
+
31
+ From a plain image:
32
+
33
+ ```js
34
+ const hero = new Sprite(x, y, {
35
+ image: "hero", // preloaded asset name
36
+ framewidth: 32,
37
+ frameheight: 32,
38
+ });
39
+ ```
40
+
41
+ From a texture atlas region:
42
+
43
+ ```js
44
+ const atlas = new TextureAtlas(loader.getJSON("sprites"), loader.getImage("sprites"));
45
+ const coin = new Sprite(x, y, { image: atlas, region: "coin_01.png" });
46
+ ```
47
+
48
+ `framewidth` / `frameheight` define the animation grid on a sheet. Omit them and
49
+ the whole image is one frame.
50
+
51
+ ## Animation
52
+
53
+ ```js
54
+ hero.addAnimation("idle", [0, 1, 2, 3], 100); // frames, ms per frame
55
+ hero.addAnimation("walk", [4, 5, 6, 7]);
56
+ hero.addAnimation("die", [8, 9], 150);
57
+
58
+ hero.setCurrentAnimation("walk");
59
+ hero.setCurrentAnimation("die", "idle"); // chain to idle when it ends
60
+ hero.setCurrentAnimation("die", { loop: false }); // play once, hold the last frame
61
+ hero.setCurrentAnimation("die", { loop: false, onComplete: fn }); // …and call fn when it does
62
+
63
+ if (hero.isCurrentAnimation("walk")) { /* … */ }
64
+ ```
65
+
66
+ Frame indices are into the `framewidth`/`frameheight` grid. With an atlas, use
67
+ `atlas.getAnimationSettings([regionNames])` and spread it into the Sprite
68
+ settings, or `atlas.createAnimationFromName([regionNames])`, which returns a
69
+ ready-made Sprite. On a fixed-cell spritesheet only numeric indices are
70
+ accepted — passing region names throws.
71
+
72
+ The second argument to `setCurrentAnimation` is polymorphic. A **string** chains
73
+ to that animation when this one ends. An **options object** takes
74
+ `{ loop, next, speed, onComplete }`, and only an explicit `loop: false` stops the
75
+ looping. A **bare function** is the legacy form: it fires at *every* cycle end,
76
+ and only holds the last frame if it returns `false`. Omit the argument entirely
77
+ and the animation loops forever.
78
+
79
+ Re-selecting the animation that is already current is a no-op, so calling
80
+ `setCurrentAnimation` every frame is safe. An unknown id throws.
81
+
82
+ ## Texture atlases
83
+
84
+ `TextureAtlas` reads several formats:
85
+
86
+ | source | how |
87
+ |---|---|
88
+ | TexturePacker / Free Texture Packer JSON | `new TextureAtlas(loader.getJSON(name), loader.getImage(name))` |
89
+ | Aseprite **JSON export** | same as TexturePacker — the format is detected from `meta.app` |
90
+ | Aseprite **`.aseprite` / `.ase` binary** | loader type `"aseprite"`, which stores the composited image *and* a JSON sidecar under the one asset name |
91
+ | ShoeBox | JSON export using the melonJS exporter settings file; same call as TexturePacker |
92
+ | fixed-cell spritesheet | `new TextureAtlas({ framewidth, frameheight, anchorPoint }, loader.getImage(name))` |
93
+ | multi-page | pass an array of atlas JSON objects as the first argument |
94
+
95
+ Helpers: `createSpriteFromName(name)`, `createAnimationFromName([names])`,
96
+ `getAnimationSettings([names])`.
97
+
98
+ Atlases matter for performance: the GPU batchers bind several textures at once
99
+ (up to `renderer.maxTextures`), so a handful of separate images still batch —
100
+ but once a frame crosses that many distinct textures the batch has to flush.
101
+ Packing into one atlas keeps everything on a single binding.
102
+
103
+ ## Visual properties
104
+
105
+ ```js
106
+ sprite.tint.setColor(255, 128, 0); // multiply tint
107
+ sprite.alpha = 0.5;
108
+ sprite.flipX(true); // mirror horizontally
109
+ sprite.flipY(true);
110
+ sprite.blendMode = "additive"; // see the effects skill for the full list
111
+ sprite.scale(2, 2); // ← multiplicative, see below
112
+ ```
113
+
114
+ **`scale()` is multiplicative, not absolute.** Calling it every frame compounds.
115
+ For absolute scaling reset first:
116
+
117
+ ```js
118
+ sprite.currentTransform.identity();
119
+ sprite.currentTransform.scale(s, s, 1);
120
+ ```
121
+
122
+ This bites hardest with pooled sprites, which arrive carrying their previous
123
+ life's transform.
124
+
125
+ ## `NineSliceSprite`
126
+
127
+ For panels and dialogue boxes that stretch without distorting their corners:
128
+
129
+ ```js
130
+ new NineSliceSprite(x, y, {
131
+ image: "panel", width: 300, height: 120,
132
+ insetx: 12, insety: 12, // lowercase x/y — `insetX` is silently ignored
133
+ });
134
+ ```
135
+
136
+ `width` and `height` are mandatory and the constructor throws without them.
137
+ The insets default to a quarter of the frame.
138
+
139
+ ## Pooling
140
+
141
+ Frequently spawned sprites should be pooled:
142
+
143
+ ```js
144
+ pool.register("bullet", Bullet, true); // true = recyclable
145
+ const b = pool.pull("bullet", x, y); // new Bullet(x, y), or onResetEvent(x, y) on a reused one
146
+ world.removeChild(b); // returns it to the pool automatically
147
+ ```
148
+
149
+ Two consequences:
150
+
151
+ - A recyclable class's `onResetEvent` must reset **everything** its lifetime
152
+ mutates — alpha, tint, scale, animation state. Anything you forget carries
153
+ over to the next use.
154
+ - Pool-recycled objects do **not** fire `onDestroyEvent` on removal. Pair event
155
+ subscriptions with `onActivateEvent` / `onDeactivateEvent` instead.
156
+
157
+ ## Symptom → cause
158
+
159
+ | symptom | cause |
160
+ |---|---|
161
+ | everything offset by half a sprite | top-left maths against the centred `anchorPoint` |
162
+ | sprite grows every frame | `scale()` is multiplicative — reset the transform |
163
+ | a recycled sprite keeps its old look | `onResetEvent` does not restore every mutated property |
164
+ | event handlers leak on pooled objects | bound in the constructor rather than `onActivateEvent` |
165
+ | animation never advances | no `framewidth`/`frameheight`, so the sheet is one frame |
166
+ | animation plays once and stops | `{ loop: false }`, or a callback that returned `false` |
167
+ | sprites do not batch | more distinct textures in one frame than `renderer.maxTextures` |
168
+ | nine-slice corners stretch anyway | `insetX`/`insetY` instead of `insetx`/`insety` |
169
+
170
+ ## Related skills
171
+
172
+ - `melonjs-renderables` — anchors, draw order, custom draw
173
+ - `melonjs-getting-started` — preloading images and atlases
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: melonjs-tilemaps
3
+ description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, level.load async, await level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax."
4
+ license: MIT
5
+ ---
6
+
7
+ # Tiled maps
8
+
9
+ > melonJS's flagship content pipeline. Maps are authored in
10
+ > [Tiled](https://www.mapeditor.org/) and loaded through the `level` director —
11
+ > you rarely touch the `TMX*` classes directly.
12
+
13
+ ## Loading a level
14
+
15
+ Preload the map **and** everything it references — the `.tmx`, any external
16
+ `.tsx` tilesets, and the tileset images:
17
+
18
+ ```js
19
+ await loader.preload([
20
+ { name: "map1", type: "tmx", src: "data/map/map1.tmx" },
21
+ { name: "tileset", type: "tsx", src: "data/map/tileset.tsx" },
22
+ { name: "tiles", type: "image", src: "data/img/tiles.png" },
23
+ ]);
24
+
25
+ level.load("map1"); // inside Stage.onResetEvent
26
+ ```
27
+
28
+ Asset `type` is `"tmx"` for maps and `"tsx"` for external tilesets — those are
29
+ the only two type strings the loader knows. The *file* can be `.tmx` / `.tsx`
30
+ (XML), or `.json` / `.tmj` / `.tsj`; the parser branches on the extension, not
31
+ on the type. `type: "tmj"` throws `unknown or invalid resource type`. You can
32
+ also skip `src` and pass the map inline via `data` (with `format: "json"` or
33
+ `"xml"`).
34
+
35
+ `level.load(levelId, options)` accepts `container` (default `game.world`),
36
+ `onLoaded` (default `game.onLevelLoaded`), `flatten` (default `game.mergeGroup`),
37
+ `setViewportBounds` (default **`true`**) and `async` (default `false`). It throws
38
+ `level <id> not found` for an unknown id — synchronously, in both forms, because
39
+ that is a typo rather than a load failure.
40
+
41
+ **`level.load` is deferred while the game loop is running.** It calls
42
+ `state.stop()` and finishes the load on a timer, after the current frame, so by
43
+ default it returns `true` before anything is in the world. Two ways to sequence
44
+ work after it:
45
+
46
+ ```js
47
+ // await it
48
+ await level.load("map1", { async: true });
49
+ // the world is populated here
50
+
51
+ // ...or use the callback / event, which fire in both forms
52
+ level.load("map1", { onLoaded: () => this.spawnPlayer() });
53
+ ```
54
+
55
+ `async: true` is the only thing that changes the return value — everything else
56
+ behaves identically, `onLoaded` included. Without it the call returns a boolean,
57
+ so `await level.load("map1")` is not an error and does not await the load:
58
+ `await true` resolves immediately, while the load is still sitting on a timer.
59
+ Pass the flag when you mean to await.
60
+
61
+ `level.reload()`, `level.next()` and `level.previous()` take the same `async`
62
+ option and resolve the same value they return — so `if (level.next())` becomes
63
+ `if (await level.next({ async: true }))`. Running out of levels reports `false`
64
+ either way rather than throwing. `level.getCurrentLevelId()` and
65
+ `level.levelCount()` round out the namespace. `flatten: false` wraps each Tiled
66
+ object group in its own `Container` named after the group.
67
+
68
+ ## Spawning entities from Tiled objects
69
+
70
+ Objects are matched against a factory registry, in this order: the object's
71
+ Tiled **class**, then its **name**, then the structural fallbacks `"text"`,
72
+ `"tile"` and `"shape"`.
73
+
74
+ ```js
75
+ pool.register("mainPlayer", PlayerEntity); // ← matches Tiled class OR name
76
+ level.load("map1");
77
+ ```
78
+
79
+ `pool.register(className, classObj, recycling)` also registers the class as a
80
+ Tiled object factory (and again under an `me.`-prefixed alias), unless you set
81
+ `pool.autoRegisterTiled = false`. The dedicated entry points are:
82
+
83
+ ```js
84
+ import { registerTiledObjectClass, registerTiledObjectFactory } from "melonjs";
85
+
86
+ registerTiledObjectClass("Enemy", Enemy); // new Enemy(x, y, settings)
87
+ registerTiledObjectFactory("Spine", (settings, map) => { /* → Renderable */ });
88
+ ```
89
+
90
+ Register **before** loading. With no match the object falls through to the
91
+ structural factory and becomes a plain `Renderable` with a static body — it does
92
+ not error, it just has none of your behaviour.
93
+
94
+ `registerTiledObjectClass` **throws** if you register a *different* constructor
95
+ under a name already taken (re-registering the same one is a no-op).
96
+ `registerTiledObjectFactory` overwrites and only `console.warn`s, so it is the
97
+ one to use for overriding a built-in such as `"shape"`.
98
+
99
+ melonJS pre-registers `Renderable`, `Sprite`, `NineSliceSprite`, `Text`,
100
+ `BitmapText`, `ImageLayer`, `ColorLayer`, `Light2d`, `Collectable` and `Trigger`
101
+ as Tiled classes, so `Collectable` and `Trigger` work out of the box.
102
+
103
+ ## Camera bounds
104
+
105
+ `level.load` sets the viewport bounds to the map size for you —
106
+ `setViewportBounds` defaults to `true`, and the handler is re-run on every
107
+ viewport resize, centring the map when it is smaller than the screen. You only
108
+ need to do it by hand when you opted out:
109
+
110
+ ```js
111
+ level.load("map1", { setViewportBounds: false });
112
+ app.viewport.setBounds(0, 0, mapWidth, mapHeight); // now it's on you
113
+ ```
114
+
115
+ The same is true if you drive `TMXTileMap.addTo(container, flatten, setViewportBounds)`
116
+ directly — note that method's `setViewportBounds` defaults to **`false`**, the
117
+ opposite of `level.load`'s.
118
+
119
+ ## Collision shapes
120
+
121
+ Draw collision geometry in Tiled on an object layer and melonJS turns it into
122
+ world shapes automatically — rectangles, polygons, polylines, ellipses and
123
+ points all work.
124
+
125
+ The contract is the **layer name**: melonJS lowercases it and checks whether it
126
+ *contains* `"collision"` (so `collision`, `Collision`, `world collision` all
127
+ match). Inside such a layer, objects **with no name** get
128
+ `collisionType = collision.types.WORLD_SHAPE` and `type = "static"`. A *named*
129
+ object in a collision layer keeps whatever its factory gave it — that is how you
130
+ mix triggers into the collision layer.
131
+
132
+ An object that matches no factory and carries no text or tile data falls to the
133
+ `"shape"` factory: a plain `Renderable` with a static `bodyDef` built from its
134
+ geometry, which the world auto-registers with the active adapter on `addChild`.
135
+
136
+ For per-object physics, set the object's custom properties in Tiled; they arrive
137
+ on the settings object passed to your entity's constructor.
138
+
139
+ ## Map orientations
140
+
141
+ Orthogonal, **isometric**, hexagonal, staggered and oblique are all supported;
142
+ anything else throws `<orientation> type TMX Tile Map not supported!` at load.
143
+ Isometric maps need y-sorting so objects overlap correctly:
144
+
145
+ ```js
146
+ app.world.sortOn = "y"; // after level.load
147
+ ```
148
+
149
+ `sortOn` only accepts `"x"`, `"y"`, `"z"` (the default) or `"depth"` and throws
150
+ on anything else. `Vector2d`, `Vector3d`, their observable variants and `Polygon`
151
+ all carry `.toIso()` / `.to2d()` for converting between screen and map space.
152
+
153
+ ## Image layers
154
+
155
+ `ImageLayer` gives parallax backgrounds with a ratio per axis, set in Tiled or in
156
+ code. Repeat behaviour matches Tiled's.
157
+
158
+ ## Compressed maps need a plugin
159
+
160
+ A map saved with **gzip, zlib or zstd** compressed layer data throws
161
+ `No inflate function set — GZIP/ZLIB decompression not supported!` at parse time
162
+ without:
163
+
164
+ ```js
165
+ import { plugin } from "melonjs";
166
+ import { TiledInflatePlugin } from "@melonjs/tiled-inflate-plugin";
167
+
168
+ plugin.register(TiledInflatePlugin); // before preloading any compressed map
169
+ ```
170
+
171
+ Uncompressed base64 and CSV layer data need no plugin. If a map loads in Tiled
172
+ but not in melonJS, check the layer compression setting first.
173
+
174
+ ## Rendering
175
+
176
+ Each tile layer resolves to one of three `renderMode`s — `"shader"`,
177
+ `"prerender"` or `"perTile"` — auto-selected in that order of preference, or
178
+ forced per layer. The `"shader"` path is a single quad per tileset with a
179
+ per-pixel GID lookup in the fragment shader. It requires **all** of:
180
+
181
+ - a renderer that reports GPU tile-layer support (WebGL 2 / WebGPU — not Canvas),
182
+ - `world.gpuTilemap !== false` (the `gpuTilemap` application setting, default `true`),
183
+ - an **orthogonal** layer — isometric, hexagonal, staggered and oblique always
184
+ fall back,
185
+ - no collection-of-image tileset, no non-zero `tileoffset`, and tile overflow
186
+ within the shader's 4-cell limit.
187
+
188
+ When a layer falls back, melonJS `console.warn`s once with the reason. Practical
189
+ consequences: fewer tilesets means fewer batches (one packed tileset beats
190
+ several small ones), and on the Canvas fallback large maps get noticeably
191
+ slower. `world.preRender` (or a `preRender` layer property in Tiled) opts an
192
+ unanimated layer into the offscreen-bake path instead.
193
+
194
+ ## Symptom → cause
195
+
196
+ | symptom | cause |
197
+ |---|---|
198
+ | a Tiled object becomes a plain shape with no behaviour | its class/name does not match any registered factory, or it was registered after `level.load` |
199
+ | the world is still empty right after `level.load` | the load is deferred to a timer while the loop runs — `await level.load(id, { async: true })`, or use `onLoaded` / `LEVEL_LOADED` |
200
+ | `await level.load(id)` returned `true` rather than a promise | without `async: true` the call returns a boolean; `await true` resolves immediately and the load has not run yet — pass the flag when you mean to await |
201
+ | `level <id> not found` | the map was never preloaded, or the asset `name` differs from the id passed to `load` |
202
+ | `unknown or invalid resource type` | asset `type` set to `"tmj"` / `"tsj"` — use `"tmx"` / `"tsx"` with the `.tmj` / `.tsj` file |
203
+ | camera will not scroll | `setViewportBounds: false`, or the map was added with `addTo()` (which defaults to `false`) |
204
+ | `No inflate function set` at parse time | compressed layers without the tiled-inflate plugin |
205
+ | collision shapes are not solid | the object layer's name does not contain `"collision"`, or the objects are named |
206
+ | isometric objects overlap wrongly | `world.sortOn` not set to `"y"` |
207
+ | missing tiles or a blank map | the `.tsx` or tileset image was not preloaded |
208
+ | tilemap slow on some machines | layer fell back off the shader path — check the console warning for the reason |
209
+
210
+ ## Related skills
211
+
212
+ - `melonjs-physics` — what the collision shapes become once loaded
213
+ - `melonjs-getting-started` — preloading and the asset type list
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: melonjs-ui-and-text
3
+ description: "Use this skill for HUDs, buttons, menus, dialogue panels and on-screen text in melonJS. Covers UIBaseElement/UISpriteElement/UITextButton, Draggable and DropTarget, the floating screen-space container pattern, Text and BitmapText, web font loading, and NineSliceSprite panels. Triggers on: UI, HUD, button, UIBaseElement, UISpriteElement, UITextButton, Draggable, DropTarget, menu, dialogue, Text, BitmapText, font, fontface, wordWrapWidth, NineSliceSprite, score display, floating."
4
+ license: MIT
5
+ ---
6
+
7
+ # UI, HUD and text
8
+
9
+ ## The HUD pattern
10
+
11
+ A HUD is a `floating` container at a high z, built once and re-added:
12
+
13
+ ```js
14
+ class HUD extends Container {
15
+ constructor(app) {
16
+ super(0, 0, app.viewport.width, app.viewport.height);
17
+ this.floating = true; // screen space, not world space
18
+ this.isPersistent = true; // survives a world reset
19
+ }
20
+ }
21
+
22
+ app.world.addChild(new HUD(app), 100); // explicit z — not `.z = Infinity`
23
+ ```
24
+
25
+ There is no `UIContainer` class. Use `Container`, or `UIBaseElement` when the
26
+ panel itself must react to the pointer — it is a `Container` that already sets
27
+ `floating = true` and `isKinematic = false`.
28
+
29
+ Three things matter here:
30
+
31
+ - **`floating = true`** opts the container out of camera transforms, so it stays
32
+ put while the world scrolls. Without it the HUD scrolls away — a silent
33
+ failure.
34
+ - **Only the parent container needs `floating`.** `addChild` forces
35
+ `child.floating = false` under a floating parent, and the container applies one
36
+ projection swap for the whole subtree.
37
+ - **Pass an explicit z.** `this.z = Number.POSITIVE_INFINITY` appears in several
38
+ shipped examples and does nothing — `renderable.z` is not a real property. The
39
+ real accessor is `depth` (an alias for `pos.z`); `addChild(child, z)` sets it
40
+ for you.
41
+
42
+ ### In a 3D scene, a HUD needs a SMALL depth
43
+
44
+ `floating` opts a renderable out of the camera transform. It does **not** opt it
45
+ out of the depth sort, and the two sorts read z differently:
46
+
47
+ | container `sortOn` | ordered by | on top |
48
+ | --- | --- | --- |
49
+ | `"z"` (default, 2D) | `pos.z` | **highest** z |
50
+ | `"depth"` (what `Camera3d` sets) | distance from the camera | **nearest** the camera |
51
+
52
+ Under `"depth"` a floating child is ordered by `|pos.z|` alone — its `pos.x/y`
53
+ are screen pixels, not a place in the world, and the camera does not move
54
+ relative to it. So the *magnitude* is the distance, and the sign is ignored:
55
+
56
+ ```js
57
+ world.addChild(hud, -150); // small -> in front of the whole scene
58
+ world.addChild(backdrop, -10000); // large -> behind the whole scene
59
+ world.addChild(backdrop, 100000); // equally far: sign does not matter
60
+ ```
61
+
62
+ Give a HUD the huge z that would put it on top in 2D and it lands at the far end
63
+ of the level instead, with the scenery drawing over it. Both shipped idioms are
64
+ the same rule: afterBurner's HUD sits at `-150`, and the glTF, Billboard, Night
65
+ City and Instanced Forest examples park a floating sky at `-10000` or `100000`.