kaplay 3001.0.10 → 3001.0.13

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 (301) hide show
  1. package/CHANGELOG.md +2 -1719
  2. package/README.md +102 -99
  3. package/dist/declaration/global.d.ts +1 -2
  4. package/dist/doc.d.ts +127 -53
  5. package/dist/kaboom.js +8 -9
  6. package/dist/kaplay.cjs +8 -8
  7. package/dist/kaplay.cjs.map +4 -4
  8. package/dist/kaplay.js +8 -8
  9. package/dist/kaplay.js.map +4 -4
  10. package/dist/kaplay.mjs +8 -8
  11. package/dist/kaplay.mjs.map +4 -4
  12. package/package.json +37 -17
  13. package/dist/declaration/app/app.d.ts +0 -182
  14. package/dist/declaration/app/app.d.ts.map +0 -1
  15. package/dist/declaration/app/frame.d.ts +0 -4
  16. package/dist/declaration/app/frame.d.ts.map +0 -1
  17. package/dist/declaration/app/index.d.ts +0 -4
  18. package/dist/declaration/app/index.d.ts.map +0 -1
  19. package/dist/declaration/app/inputBindings.d.ts +0 -27
  20. package/dist/declaration/app/inputBindings.d.ts.map +0 -1
  21. package/dist/declaration/assets/aseprite.d.ts +0 -26
  22. package/dist/declaration/assets/aseprite.d.ts.map +0 -1
  23. package/dist/declaration/assets/asset.d.ts +0 -58
  24. package/dist/declaration/assets/asset.d.ts.map +0 -1
  25. package/dist/declaration/assets/bitmapFont.d.ts +0 -18
  26. package/dist/declaration/assets/bitmapFont.d.ts.map +0 -1
  27. package/dist/declaration/assets/font.d.ts +0 -17
  28. package/dist/declaration/assets/font.d.ts.map +0 -1
  29. package/dist/declaration/assets/index.d.ts +0 -11
  30. package/dist/declaration/assets/index.d.ts.map +0 -1
  31. package/dist/declaration/assets/pedit.d.ts +0 -10
  32. package/dist/declaration/assets/pedit.d.ts.map +0 -1
  33. package/dist/declaration/assets/shader.d.ts +0 -36
  34. package/dist/declaration/assets/shader.d.ts.map +0 -1
  35. package/dist/declaration/assets/sound.d.ts +0 -12
  36. package/dist/declaration/assets/sound.d.ts.map +0 -1
  37. package/dist/declaration/assets/sprite.d.ts +0 -114
  38. package/dist/declaration/assets/sprite.d.ts.map +0 -1
  39. package/dist/declaration/assets/spriteAtlas.d.ts +0 -26
  40. package/dist/declaration/assets/spriteAtlas.d.ts.map +0 -1
  41. package/dist/declaration/assets/utils.d.ts +0 -2
  42. package/dist/declaration/assets/utils.d.ts.map +0 -1
  43. package/dist/declaration/audio/audio.d.ts +0 -8
  44. package/dist/declaration/audio/audio.d.ts.map +0 -1
  45. package/dist/declaration/audio/burp.d.ts +0 -3
  46. package/dist/declaration/audio/burp.d.ts.map +0 -1
  47. package/dist/declaration/audio/index.d.ts +0 -6
  48. package/dist/declaration/audio/index.d.ts.map +0 -1
  49. package/dist/declaration/audio/play.d.ts +0 -122
  50. package/dist/declaration/audio/play.d.ts.map +0 -1
  51. package/dist/declaration/audio/playMusic.d.ts +0 -3
  52. package/dist/declaration/audio/playMusic.d.ts.map +0 -1
  53. package/dist/declaration/audio/volume.d.ts +0 -4
  54. package/dist/declaration/audio/volume.d.ts.map +0 -1
  55. package/dist/declaration/components/draw/circle.d.ts +0 -32
  56. package/dist/declaration/components/draw/circle.d.ts.map +0 -1
  57. package/dist/declaration/components/draw/color.d.ts +0 -12
  58. package/dist/declaration/components/draw/color.d.ts.map +0 -1
  59. package/dist/declaration/components/draw/drawon.d.ts +0 -6
  60. package/dist/declaration/components/draw/drawon.d.ts.map +0 -1
  61. package/dist/declaration/components/draw/fadeIn.d.ts +0 -3
  62. package/dist/declaration/components/draw/fadeIn.d.ts.map +0 -1
  63. package/dist/declaration/components/draw/index.d.ts +0 -16
  64. package/dist/declaration/components/draw/index.d.ts.map +0 -1
  65. package/dist/declaration/components/draw/mask.d.ts +0 -11
  66. package/dist/declaration/components/draw/mask.d.ts.map +0 -1
  67. package/dist/declaration/components/draw/opacity.d.ts +0 -16
  68. package/dist/declaration/components/draw/opacity.d.ts.map +0 -1
  69. package/dist/declaration/components/draw/outline.d.ts +0 -13
  70. package/dist/declaration/components/draw/outline.d.ts.map +0 -1
  71. package/dist/declaration/components/draw/particles.d.ts +0 -43
  72. package/dist/declaration/components/draw/particles.d.ts.map +0 -1
  73. package/dist/declaration/components/draw/polygon.d.ts +0 -46
  74. package/dist/declaration/components/draw/polygon.d.ts.map +0 -1
  75. package/dist/declaration/components/draw/raycast.d.ts +0 -3
  76. package/dist/declaration/components/draw/raycast.d.ts.map +0 -1
  77. package/dist/declaration/components/draw/rect.d.ts +0 -43
  78. package/dist/declaration/components/draw/rect.d.ts.map +0 -1
  79. package/dist/declaration/components/draw/shader.d.ts +0 -19
  80. package/dist/declaration/components/draw/shader.d.ts.map +0 -1
  81. package/dist/declaration/components/draw/sprite.d.ts +0 -141
  82. package/dist/declaration/components/draw/sprite.d.ts.map +0 -1
  83. package/dist/declaration/components/draw/text.d.ts +0 -126
  84. package/dist/declaration/components/draw/text.d.ts.map +0 -1
  85. package/dist/declaration/components/draw/uvquad.d.ts +0 -24
  86. package/dist/declaration/components/draw/uvquad.d.ts.map +0 -1
  87. package/dist/declaration/components/index.d.ts +0 -6
  88. package/dist/declaration/components/index.d.ts.map +0 -1
  89. package/dist/declaration/components/level/agent.d.ts +0 -35
  90. package/dist/declaration/components/level/agent.d.ts.map +0 -1
  91. package/dist/declaration/components/level/index.d.ts +0 -6
  92. package/dist/declaration/components/level/index.d.ts.map +0 -1
  93. package/dist/declaration/components/level/pathfinder.d.ts +0 -21
  94. package/dist/declaration/components/level/pathfinder.d.ts.map +0 -1
  95. package/dist/declaration/components/level/patrol.d.ts +0 -22
  96. package/dist/declaration/components/level/patrol.d.ts.map +0 -1
  97. package/dist/declaration/components/level/sentry.d.ts +0 -48
  98. package/dist/declaration/components/level/sentry.d.ts.map +0 -1
  99. package/dist/declaration/components/level/tile.d.ts +0 -61
  100. package/dist/declaration/components/level/tile.d.ts.map +0 -1
  101. package/dist/declaration/components/misc/animate.d.ts +0 -141
  102. package/dist/declaration/components/misc/animate.d.ts.map +0 -1
  103. package/dist/declaration/components/misc/boom.d.ts +0 -3
  104. package/dist/declaration/components/misc/boom.d.ts.map +0 -1
  105. package/dist/declaration/components/misc/health.d.ts +0 -53
  106. package/dist/declaration/components/misc/health.d.ts.map +0 -1
  107. package/dist/declaration/components/misc/index.d.ts +0 -10
  108. package/dist/declaration/components/misc/index.d.ts.map +0 -1
  109. package/dist/declaration/components/misc/lifespan.d.ts +0 -14
  110. package/dist/declaration/components/misc/lifespan.d.ts.map +0 -1
  111. package/dist/declaration/components/misc/named.d.ts +0 -12
  112. package/dist/declaration/components/misc/named.d.ts.map +0 -1
  113. package/dist/declaration/components/misc/state.d.ts +0 -41
  114. package/dist/declaration/components/misc/state.d.ts.map +0 -1
  115. package/dist/declaration/components/misc/stay.d.ts +0 -18
  116. package/dist/declaration/components/misc/stay.d.ts.map +0 -1
  117. package/dist/declaration/components/misc/textInput.d.ts +0 -18
  118. package/dist/declaration/components/misc/textInput.d.ts.map +0 -1
  119. package/dist/declaration/components/misc/timer.d.ts +0 -34
  120. package/dist/declaration/components/misc/timer.d.ts.map +0 -1
  121. package/dist/declaration/components/physics/area.d.ts +0 -189
  122. package/dist/declaration/components/physics/area.d.ts.map +0 -1
  123. package/dist/declaration/components/physics/body.d.ts +0 -175
  124. package/dist/declaration/components/physics/body.d.ts.map +0 -1
  125. package/dist/declaration/components/physics/doubleJump.d.ts +0 -23
  126. package/dist/declaration/components/physics/doubleJump.d.ts.map +0 -1
  127. package/dist/declaration/components/physics/effectors.d.ts +0 -83
  128. package/dist/declaration/components/physics/effectors.d.ts.map +0 -1
  129. package/dist/declaration/components/physics/index.d.ts +0 -5
  130. package/dist/declaration/components/physics/index.d.ts.map +0 -1
  131. package/dist/declaration/components/transform/anchor.d.ts +0 -15
  132. package/dist/declaration/components/transform/anchor.d.ts.map +0 -1
  133. package/dist/declaration/components/transform/fixed.d.ts +0 -14
  134. package/dist/declaration/components/transform/fixed.d.ts.map +0 -1
  135. package/dist/declaration/components/transform/follow.d.ts +0 -21
  136. package/dist/declaration/components/transform/follow.d.ts.map +0 -1
  137. package/dist/declaration/components/transform/index.d.ts +0 -11
  138. package/dist/declaration/components/transform/index.d.ts.map +0 -1
  139. package/dist/declaration/components/transform/layer.d.ts +0 -26
  140. package/dist/declaration/components/transform/layer.d.ts.map +0 -1
  141. package/dist/declaration/components/transform/move.d.ts +0 -4
  142. package/dist/declaration/components/transform/move.d.ts.map +0 -1
  143. package/dist/declaration/components/transform/offscreen.d.ts +0 -48
  144. package/dist/declaration/components/transform/offscreen.d.ts.map +0 -1
  145. package/dist/declaration/components/transform/pos.d.ts +0 -77
  146. package/dist/declaration/components/transform/pos.d.ts.map +0 -1
  147. package/dist/declaration/components/transform/rotate.d.ts +0 -24
  148. package/dist/declaration/components/transform/rotate.d.ts.map +0 -1
  149. package/dist/declaration/components/transform/scale.d.ts +0 -41
  150. package/dist/declaration/components/transform/scale.d.ts.map +0 -1
  151. package/dist/declaration/components/transform/z.d.ts +0 -14
  152. package/dist/declaration/components/transform/z.d.ts.map +0 -1
  153. package/dist/declaration/constants.d.ts +0 -34
  154. package/dist/declaration/constants.d.ts.map +0 -1
  155. package/dist/declaration/events/eventMap.d.ts +0 -223
  156. package/dist/declaration/events/eventMap.d.ts.map +0 -1
  157. package/dist/declaration/events/events.d.ts +0 -57
  158. package/dist/declaration/events/events.d.ts.map +0 -1
  159. package/dist/declaration/events/globalEvents.d.ts +0 -30
  160. package/dist/declaration/events/globalEvents.d.ts.map +0 -1
  161. package/dist/declaration/events/index.d.ts +0 -3
  162. package/dist/declaration/events/index.d.ts.map +0 -1
  163. package/dist/declaration/game/camera.d.ts +0 -19
  164. package/dist/declaration/game/camera.d.ts.map +0 -1
  165. package/dist/declaration/game/game.d.ts +0 -67
  166. package/dist/declaration/game/game.d.ts.map +0 -1
  167. package/dist/declaration/game/gravity.d.ts +0 -6
  168. package/dist/declaration/game/gravity.d.ts.map +0 -1
  169. package/dist/declaration/game/index.d.ts +0 -13
  170. package/dist/declaration/game/index.d.ts.map +0 -1
  171. package/dist/declaration/game/initEvents.d.ts +0 -2
  172. package/dist/declaration/game/initEvents.d.ts.map +0 -1
  173. package/dist/declaration/game/kaboom.d.ts +0 -23
  174. package/dist/declaration/game/kaboom.d.ts.map +0 -1
  175. package/dist/declaration/game/layers.d.ts +0 -5
  176. package/dist/declaration/game/layers.d.ts.map +0 -1
  177. package/dist/declaration/game/level.d.ts +0 -32
  178. package/dist/declaration/game/level.d.ts.map +0 -1
  179. package/dist/declaration/game/make.d.ts +0 -3
  180. package/dist/declaration/game/make.d.ts.map +0 -1
  181. package/dist/declaration/game/object.d.ts +0 -4
  182. package/dist/declaration/game/object.d.ts.map +0 -1
  183. package/dist/declaration/game/scenes.d.ts +0 -11
  184. package/dist/declaration/game/scenes.d.ts.map +0 -1
  185. package/dist/declaration/game/utils.d.ts +0 -11
  186. package/dist/declaration/game/utils.d.ts.map +0 -1
  187. package/dist/declaration/gfx/anchor.d.ts +0 -7
  188. package/dist/declaration/gfx/anchor.d.ts.map +0 -1
  189. package/dist/declaration/gfx/bg.d.ts +0 -4
  190. package/dist/declaration/gfx/bg.d.ts.map +0 -1
  191. package/dist/declaration/gfx/draw/drawBezier.d.ts +0 -22
  192. package/dist/declaration/gfx/draw/drawBezier.d.ts.map +0 -1
  193. package/dist/declaration/gfx/draw/drawCircle.d.ts +0 -40
  194. package/dist/declaration/gfx/draw/drawCircle.d.ts.map +0 -1
  195. package/dist/declaration/gfx/draw/drawCurve.d.ts +0 -14
  196. package/dist/declaration/gfx/draw/drawCurve.d.ts.map +0 -1
  197. package/dist/declaration/gfx/draw/drawDebug.d.ts +0 -2
  198. package/dist/declaration/gfx/draw/drawDebug.d.ts.map +0 -1
  199. package/dist/declaration/gfx/draw/drawEllipse.d.ts +0 -3
  200. package/dist/declaration/gfx/draw/drawEllipse.d.ts.map +0 -1
  201. package/dist/declaration/gfx/draw/drawFormattedText.d.ts +0 -31
  202. package/dist/declaration/gfx/draw/drawFormattedText.d.ts.map +0 -1
  203. package/dist/declaration/gfx/draw/drawFrame.d.ts +0 -2
  204. package/dist/declaration/gfx/draw/drawFrame.d.ts.map +0 -1
  205. package/dist/declaration/gfx/draw/drawInspectText.d.ts +0 -3
  206. package/dist/declaration/gfx/draw/drawInspectText.d.ts.map +0 -1
  207. package/dist/declaration/gfx/draw/drawLine.d.ts +0 -56
  208. package/dist/declaration/gfx/draw/drawLine.d.ts.map +0 -1
  209. package/dist/declaration/gfx/draw/drawLoadingScreen.d.ts +0 -2
  210. package/dist/declaration/gfx/draw/drawLoadingScreen.d.ts.map +0 -1
  211. package/dist/declaration/gfx/draw/drawMasked.d.ts +0 -2
  212. package/dist/declaration/gfx/draw/drawMasked.d.ts.map +0 -1
  213. package/dist/declaration/gfx/draw/drawPolygon.d.ts +0 -3
  214. package/dist/declaration/gfx/draw/drawPolygon.d.ts.map +0 -1
  215. package/dist/declaration/gfx/draw/drawRaw.d.ts +0 -5
  216. package/dist/declaration/gfx/draw/drawRaw.d.ts.map +0 -1
  217. package/dist/declaration/gfx/draw/drawRect.d.ts +0 -42
  218. package/dist/declaration/gfx/draw/drawRect.d.ts.map +0 -1
  219. package/dist/declaration/gfx/draw/drawSprite.d.ts +0 -50
  220. package/dist/declaration/gfx/draw/drawSprite.d.ts.map +0 -1
  221. package/dist/declaration/gfx/draw/drawStenciled.d.ts +0 -2
  222. package/dist/declaration/gfx/draw/drawStenciled.d.ts.map +0 -1
  223. package/dist/declaration/gfx/draw/drawSubstracted.d.ts +0 -2
  224. package/dist/declaration/gfx/draw/drawSubstracted.d.ts.map +0 -1
  225. package/dist/declaration/gfx/draw/drawText.d.ts +0 -117
  226. package/dist/declaration/gfx/draw/drawText.d.ts.map +0 -1
  227. package/dist/declaration/gfx/draw/drawTexture.d.ts +0 -3
  228. package/dist/declaration/gfx/draw/drawTexture.d.ts.map +0 -1
  229. package/dist/declaration/gfx/draw/drawTriangle.d.ts +0 -29
  230. package/dist/declaration/gfx/draw/drawTriangle.d.ts.map +0 -1
  231. package/dist/declaration/gfx/draw/drawUVQuad.d.ts +0 -3
  232. package/dist/declaration/gfx/draw/drawUVQuad.d.ts.map +0 -1
  233. package/dist/declaration/gfx/draw/drawUnscaled.d.ts +0 -2
  234. package/dist/declaration/gfx/draw/drawUnscaled.d.ts.map +0 -1
  235. package/dist/declaration/gfx/draw/index.d.ts +0 -23
  236. package/dist/declaration/gfx/draw/index.d.ts.map +0 -1
  237. package/dist/declaration/gfx/formatText.d.ts +0 -7
  238. package/dist/declaration/gfx/formatText.d.ts.map +0 -1
  239. package/dist/declaration/gfx/gfx.d.ts +0 -101
  240. package/dist/declaration/gfx/gfx.d.ts.map +0 -1
  241. package/dist/declaration/gfx/gfxApp.d.ts +0 -58
  242. package/dist/declaration/gfx/gfxApp.d.ts.map +0 -1
  243. package/dist/declaration/gfx/index.d.ts +0 -10
  244. package/dist/declaration/gfx/index.d.ts.map +0 -1
  245. package/dist/declaration/gfx/stack.d.ts +0 -16
  246. package/dist/declaration/gfx/stack.d.ts.map +0 -1
  247. package/dist/declaration/gfx/texPacker.d.ts +0 -21
  248. package/dist/declaration/gfx/texPacker.d.ts.map +0 -1
  249. package/dist/declaration/gfx/viewport.d.ts +0 -2
  250. package/dist/declaration/gfx/viewport.d.ts.map +0 -1
  251. package/dist/declaration/index.d.ts +0 -11
  252. package/dist/declaration/index.d.ts.map +0 -1
  253. package/dist/declaration/kaplay.d.ts +0 -40
  254. package/dist/declaration/kaplay.d.ts.map +0 -1
  255. package/dist/declaration/math/color.d.ts +0 -90
  256. package/dist/declaration/math/color.d.ts.map +0 -1
  257. package/dist/declaration/math/easings.d.ts +0 -35
  258. package/dist/declaration/math/easings.d.ts.map +0 -1
  259. package/dist/declaration/math/index.d.ts +0 -8
  260. package/dist/declaration/math/index.d.ts.map +0 -1
  261. package/dist/declaration/math/math.d.ts +0 -487
  262. package/dist/declaration/math/math.d.ts.map +0 -1
  263. package/dist/declaration/math/navigation.d.ts +0 -12
  264. package/dist/declaration/math/navigation.d.ts.map +0 -1
  265. package/dist/declaration/math/navigationgrid.d.ts +0 -33
  266. package/dist/declaration/math/navigationgrid.d.ts.map +0 -1
  267. package/dist/declaration/math/navigationmesh.d.ts +0 -41
  268. package/dist/declaration/math/navigationmesh.d.ts.map +0 -1
  269. package/dist/declaration/math/various.d.ts +0 -6
  270. package/dist/declaration/math/various.d.ts.map +0 -1
  271. package/dist/declaration/types.d.ts +0 -6098
  272. package/dist/declaration/types.d.ts.map +0 -1
  273. package/dist/declaration/utils/asserts.d.ts +0 -7
  274. package/dist/declaration/utils/asserts.d.ts.map +0 -1
  275. package/dist/declaration/utils/benchmark.d.ts +0 -3
  276. package/dist/declaration/utils/benchmark.d.ts.map +0 -1
  277. package/dist/declaration/utils/binaryheap.d.ts +0 -30
  278. package/dist/declaration/utils/binaryheap.d.ts.map +0 -1
  279. package/dist/declaration/utils/dataURL.d.ts +0 -10
  280. package/dist/declaration/utils/dataURL.d.ts.map +0 -1
  281. package/dist/declaration/utils/deepEq.d.ts +0 -2
  282. package/dist/declaration/utils/deepEq.d.ts.map +0 -1
  283. package/dist/declaration/utils/index.d.ts +0 -13
  284. package/dist/declaration/utils/index.d.ts.map +0 -1
  285. package/dist/declaration/utils/log.d.ts +0 -5
  286. package/dist/declaration/utils/log.d.ts.map +0 -1
  287. package/dist/declaration/utils/numbers.d.ts +0 -2
  288. package/dist/declaration/utils/numbers.d.ts.map +0 -1
  289. package/dist/declaration/utils/overload.d.ts +0 -6
  290. package/dist/declaration/utils/overload.d.ts.map +0 -1
  291. package/dist/declaration/utils/runes.d.ts +0 -3
  292. package/dist/declaration/utils/runes.d.ts.map +0 -1
  293. package/dist/declaration/utils/sets.d.ts +0 -4
  294. package/dist/declaration/utils/sets.d.ts.map +0 -1
  295. package/dist/declaration/utils/uid.d.ts +0 -2
  296. package/dist/declaration/utils/uid.d.ts.map +0 -1
  297. package/dist/kaboom.cjs +0 -57
  298. package/dist/kaboom.cjs.map +0 -7
  299. package/dist/kaboom.js.map +0 -7
  300. package/dist/kaboom.mjs +0 -57
  301. package/dist/kaboom.mjs.map +0 -7
package/CHANGELOG.md CHANGED
@@ -1,1721 +1,4 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is (mostly) based on
6
- [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
7
- adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
-
9
- ## [3001.0.10] - 2025-03-22
10
-
11
- ### Added
12
-
13
- - Added new option in `LoadSpriteOpt` for loading sprites in an individual
14
- spritesheet - @chqs-git
15
- ```js
16
- loadSprite(
17
- "player",
18
- "sprites/player.png",
19
- {
20
- singular: true,
21
- },
22
- );
23
- ```
24
-
25
- - Frame option for load animations with singular frames (**experimental**) -
26
- @dragoncoder047
27
- ```js
28
- loadSpriteAtlas("/examples/sprites/dungeon.png", {
29
- wizard: {
30
- x: 128,
31
- y: 140,
32
- width: 144,
33
- height: 28,
34
- sliceX: 9,
35
- anims: {
36
- bouncy: {
37
- frames: [8, 5, 0, 3, 2, 3, 0, 5],
38
- speed: 10,
39
- loop: true,
40
- },
41
- },
42
- },
43
- });
44
-
45
- add([sprite("wizard", { anim: "bouncy" }), pos(100, 100)]);
46
- ```
47
-
48
- ### Fixed
49
-
50
- - Args were not being passed to global `trigger()` - @lajbel
51
- - AreaComp.onClick now returns the correct type, KEventController, instead of
52
- void - @lajbel
53
- - Lifespan was using async - @lajbel
54
- - Wrong calculation in Vector.dot() - @andrenanninga
55
- - Fixed pointer lock undefined catch error for non-promise version - @imaginarny
56
-
57
- ## [3001.0.9] - 2025-01-15
58
-
59
- ### Added
60
-
61
- - **(examples)** Added a new `particle` example! - @lajbel
62
-
63
- ### Changed
64
-
65
- - Improved `lifespan()` explanation - @lajbel
66
- - **(examples)** `particle` example renamed to `lifespan` - @lajbel
67
-
68
- ### Fixed
69
-
70
- - Fixed a bug where `lifespan()` was working incorrectly - @lajbel
71
-
72
- ## [3001.0.8] - 2025-01-15
73
-
74
- ### Fixed
75
-
76
- - Fixed a bug where alpha channel wasn't correctly setted - @mflerackers
77
-
78
- ## [3001.0.7] - 2025-01-15
79
-
80
- ### Added
81
-
82
- - Added `kaplay({ spriteAtlasPadding })` for setting the space between the
83
- sprites in the sprite atlas - @marianyp
84
-
85
- ```js
86
- kaplay({
87
- spriteAtlasPadding: 10, // 10 pixels of space between each sprite
88
- });
89
- ```
90
-
91
- ### Changed
92
-
93
- - Now you cannot pass parameters that are not a component or string to `.use()`.
94
- Otherwise it will throw an error - @lajbel
95
-
96
- ### Fixed
97
-
98
- - Fixed a bug where font atlas were working strange - @mflerackers
99
-
100
- ## [3001.0.6] "Santa Events" - 2024-12-27
101
-
102
- ### Added
103
-
104
- - Added `trigger(event, tag, ...args)` for global triggering events on a
105
- specific tag (**experimental**) - @lajbel
106
-
107
- ```js
108
- trigger("shoot", "target", 140);
109
-
110
- on("shoot", "target", (obj, score) => {
111
- obj.destroy();
112
- debug.log(140); // every bomb was 140 score points!
113
- });
114
- ```
115
-
116
- - Added `{ override?: true }` in `CharTransform` for overridding text styles -
117
- @dragoncoder047
118
-
119
- ```js
120
- add([
121
- pos(100, 150),
122
- text("With override: Hello [foo]styled[/foo] text", {
123
- transform: {
124
- color: BLACK, // Default text color for every character
125
- },
126
- styles: {
127
- foo: {
128
- color: RED, // [foo] will be red
129
- override: true, // will override the black def color
130
- },
131
- },
132
- }),
133
- ]);
134
- ```
135
-
136
- - Added `{ indentAll?: boolean }` in `TextCompOpt` to indent every new line -
137
- @dragoncoder047
138
-
139
- - Added TypeScript definition for all App Events and missing Game Object
140
- Events - @lajbel
141
-
142
- ### Fixed
143
-
144
- - Fixed an incorrect mention to the component in `TextInputComp` type -
145
- @dragoncoder047
146
-
147
- ## [3001.0.5] - 2024-12-18
148
-
149
- ### Added
150
-
151
- - Added tags and components separation in `KAPLAYOpt.tagsAsComponents`
152
- (**experimental**)
153
- - Added `.is()`, `.tag()` and `.untag()` to `GameObjRaw`, check, add and remove
154
- (**experimental**)
155
- - Added `.has()` to `GameObjRaw`, to check if a game object has a component tags
156
- (**experimental**)
157
- - Added events for listen to comps being removed or added `onUse()` and
158
- `onUnused()` (**experimental**)
159
- - Added `k.cancel()` to cancel the current event (**experimental**)
160
- - ```js
161
- onKeyPress("space", () => {
162
- // do something
163
- // cancel the event
164
- return cancel();
165
- });
166
- ```
167
- - Added `getDefaultLayer()` to get the default layer (**experimental**)
168
- - Added `getLayers()` to get the layers list (**experimental**)
169
- - Added many JSDoc specifiers on many functions (@require, @deprecated, @since,
170
- @group, etc)
171
-
172
- ### Changed
173
-
174
- - Added `.use()`, `.unuse()` and `.has()` to `GameObjRaw`, to add, remove and
175
- check components. This only works with `KAPLAYOpt.tagsAsComponents` set to
176
- `true` (**experimental**)
177
-
178
- ### Deprecated
179
-
180
- - Deprecated camera methods `camScale()`, `camPos()` and `camRot()` in favor of
181
- `setCamScale()`, `getCamScale()`, `setCamPos()`, `getCamPos()`, `setCamRot()`
182
- and `getCamRot`.
183
- - Deprecated `camTransform()` in favor of `getCamTransform()`.
184
- - Deprecated `camFlash()` in favor of `flash()`, for a `shake()`-like name.
185
-
186
- ### Fixed
187
-
188
- - Fixed artifacts present in some TrueType fonts.
189
- - Fixed `.use()` and `.unuse()` with area components.
190
-
191
- ## [3001.0.0] "Spooky Beans!" - 2024-10-31
192
-
193
- ### Input
194
-
195
- - Added input bindings, `onButtonPress`, `onButtonRelease`, `onButtonDown`, and
196
- it's corresponding boolean versions, `isButtonPressed`, `isButtonDown` and
197
- `isButtonReleased`.
198
-
199
- ```js
200
- kaplay({
201
- // bind your buttons
202
- buttons: {
203
- jump: {
204
- keyboard: ["space", "up"],
205
- keyboardCode: "Space", // you can also use key codes
206
- gamepad: ["south"],
207
- },
208
- },
209
- });
210
-
211
- onButtonPress("jump", () => {
212
- player.jump();
213
- });
214
- ```
215
-
216
- - added `getButton(btn)` and `setButton(btn)` to get and set button bindings
217
-
218
- ```js
219
- // ["space", "up"]
220
- debug.log(getButton("jump").keyboard);
221
-
222
- // change the jump button in keyboard to "w"
223
- setButton("jump", {
224
- keyboard: ["w"],
225
- // gamepad binding is not changed
226
- });
227
- ```
228
-
229
- - added `getLastInputDeviceType()` to get what was the last pressed device
230
-
231
- ```js
232
- onButtonPress(() => {
233
- const lastInputDevice = getLastInputDeviceType(); // keyboard, mouse or gamepad
234
- // change icons, etc
235
- });
236
- ```
237
-
238
- - added `pressButton(btn)` and `releaseButton(btn)` to simulate button press and
239
- release
240
-
241
- ```js
242
- pressButton("jump"); // triggers onButtonPress and starts onButtonDown
243
- releaseButton("jump"); // triggers onButtonRelease and stops onButtonDown
244
- ```
245
-
246
- - added the possibility of use arrays in all input handlers
247
-
248
- ```js
249
- onKeyPress(["w", "up"], () => {
250
- player.jump();
251
- });
252
- ```
253
-
254
- - now gamepad events return what gamepad triggered the action
255
-
256
- ```js
257
- onGamepadButtonPress("south", (btn, gp) => {
258
- console.log(gp.index); // gamepad number on navigator's gamepad list
259
- });
260
- ```
261
-
262
- ### Physics
263
-
264
- - added effector components: `areaEffector()`, `buoyancyEffector()`,
265
- `pointEffector()`, `surfaceEffector()`.
266
- - added `constantForce()` component.
267
- - added `patrol()` component to move along a list of waypoints.
268
- - added `sentry()` component to notify when certain objects are in sight.
269
- - added `NavMesh` class for pathfinding on a mesh.
270
- - added `pathfinder()` component to calculate a list of waypoints on a graph.
271
- - now collision checks are only done if there's area objects.
272
-
273
- ### Game Object
274
-
275
- - added `getTreeRoot()` to get the game's root object, which is the parent of
276
- all other objects
277
-
278
- ```js
279
- // get the root object
280
- const root = getTreeRoot();
281
- root.add(); // same as add()
282
- root.get(); // same as get()
283
- ```
284
-
285
- - added `GameObjRaw.tags` to get a game object's tags.
286
-
287
- ```js
288
- const obj = add([sprite("bean"), "enemy", "dangerous"]);
289
-
290
- // get the tags
291
- debug.log(obj.tags); // ["enemy", "dangerous"]
292
- ```
293
-
294
- ### Components
295
-
296
- - added support to setters/getters syntax in `ScaleComp` and `SpriteComp`
297
- components
298
-
299
- ```js
300
- const obj = add([sprite("bean"), scale(2)]);
301
-
302
- // set it with = syntax
303
- obj.scale = vec2(3, 4);
304
- obj.sprite = "bag";
305
- ```
306
-
307
- ### Rendering and Animation
308
-
309
- - added the `animate()` component to _animate_ the properties of an object using
310
- keyframes. Check out
311
- [Animation Example](https://play.kaplayjs.com/?example=animation)
312
-
313
- ```js
314
- // prop to animate, frames, options
315
- rotatingBean.animate("angle", [0, 360], {
316
- duration: 2,
317
- direction: "forward",
318
- });
319
- ```
320
-
321
- - added `particles()` component to emit and draw particles.
322
-
323
- - readded `layers()` and the `layer()` component.
324
-
325
- Before the `z()` component, there was a `layer()` component that allowed you
326
- to control the draw order of objects. It was removed in v3000, but now it's
327
- back from the void.
328
-
329
- ```js
330
- // define the layers
331
- layers(
332
- [
333
- "bg",
334
- "game",
335
- "ui",
336
- // the default layer
337
- ],
338
- "game",
339
- );
340
-
341
- // use the layer component
342
- add([sprite("bg"), layer("bg")]);
343
- ```
344
-
345
- - added `SpriteComp.getCurAnim()` to get the current animation data
346
-
347
- ```js
348
- const obj = add([sprite("bean", { anim: "walk" })]);
349
-
350
- // get the current animation name
351
- debug.log(obj.getCurAnim().name); // "walk"
352
- ```
353
-
354
- - added `SpriteComp.getAnim()` for get any animation data
355
-
356
- ```js
357
- loadSprite("bean", "bean.png", {
358
- sliceX: 4,
359
- sliceY: 1,
360
- anims: {
361
- walk: {
362
- from: 0,
363
- to: 3,
364
- },
365
- },
366
- });
367
-
368
- const obj = add([sprite("bean")]);
369
-
370
- // get the animation data
371
- debug.log(obj.getAnim("walk")); // { from: 0, to: 3 }
372
- ```
373
-
374
- - added `SpriteComp.hasAnim()` to check if an animation exists
375
-
376
- ```js
377
- const obj = add([sprite("bean", { anim: "walk" })]);
378
-
379
- // check if an animation exists
380
- debug.log(obj.hasAnim("walk")); // true
381
- ```
382
-
383
- - added `camFlash()` to flash the screen.
384
-
385
- ```js
386
- camFlash(0.5, 0.5, 0.5, 0.5);
387
- ```
388
-
389
- - added support for radius in individual corners for `RectComp` component.
390
-
391
- ```js
392
- add([
393
- rect(100, 100, {
394
- radius: [10, 20, 30, 40],
395
- }),
396
- ]);
397
- ```
398
-
399
- - (**! break**) removed compatibilty to use two KAPLAY frames in the same page,
400
- due to perfomance improvements
401
-
402
- - fix error screen not showing with not Error object
403
-
404
- - Added `SpriteComp.animFrame` to get the frame of the current animation (not on
405
- the spritesheet)
406
-
407
- ### Audio
408
-
409
- - now you can pass an `AudioBuffer` to `loadSound()`
410
- - added `loadMusic()` to load streaming audio (doesn't block in loading screen).
411
-
412
- ```js
413
- loadMusic("bgm", "bgm.mp3");
414
-
415
- // play the music
416
- play("bgm");
417
- ```
418
-
419
- ### Math
420
-
421
- - added `Vec2.fromArray()` to convert an array to a `Vec2`.
422
-
423
- ```js
424
- const point = Vec2.fromArray([100, 200]); // vec2(100, 200);
425
- ```
426
-
427
- - added `Vec2.toArray()` to convert a `Vec2` to an array.
428
-
429
- ```js
430
- const point = vec2(100, 200);
431
- const arr = point.toArray(); // [100, 200]
432
- ```
433
-
434
- - added `chooseMultiple()` to choose a random element from an array.
435
-
436
- ```js
437
- const numbers = [1, 2, 3, 4, 5];
438
- const random = chooseMultiple(numbers, 3); // [3, 1, 5]
439
- ```
440
-
441
- - added `shuffle()` to shuffle an array.
442
-
443
- ```js
444
- const numbers = [1, 2, 3, 4, 5];
445
- shuffle(numbers); // [3, 1, 5, 2, 4]
446
- ```
447
-
448
- ### Debug mode
449
-
450
- - added `outline()`, `shader()`, and `area()` properties to `debug.inspect`.
451
- - added `KAPLAYOpt.debugKey` for customizing the key used to toggle debug mode.
452
-
453
- ```js
454
- kaplay({
455
- debugKey: "l",
456
- });
457
- ```
458
-
459
- - added compatibility with custom properties in debug mode
460
-
461
- ```js
462
- const obj = add([
463
- sprite("bean"),
464
- {
465
- health: 100, // on debug.inspect
466
- damage: 10, // on debug.inspect
467
- hp() {
468
- this.health -= this.damage;
469
- }, // not on debug.inspect
470
- },
471
- ]);
472
-
473
- // see the custom properties in debug mode
474
- debug.inspect = true;
475
- ```
476
-
477
- - Now `debug.log()` accepts multiple argument of any type, like `console.log()`.
478
-
479
- ### Helpers
480
-
481
- - added `getSceneName()` to get the current scene name
482
- - added `Color.toArray()` to convert a color to an array
483
- - added global raycast function and raycast method to level
484
- - added support for textured polygons
485
- - added support for concave polygon drawing
486
- - added support for arrays in uniforms
487
- - added support for texture larger than 2048x2048
488
- - added support for gravity direction
489
- - added line join (bevel, miter, round) and line caps (square, round)
490
- - added quadratic bezier and Catmull-Rom evaluation
491
- - added evaluation of the first and second derivatives for all splines
492
- - added higher order easing functions linear, steps and cubic-bezier
493
-
494
- ### TypeScript
495
-
496
- - Now you can type `get()` with a type parameter and passing component types.
497
- (**v4000**)
498
-
499
- ```ts
500
- const player = get<BodyComp>("player");
501
- ```
502
-
503
- - Now `Key` also accepts a string as an acceptable value.
504
- - Now `text()` component doesn't require to pass a string.
505
- - Now `camScale()` and `camPos()` accept only 1 number as parameter.
506
- - Now `shake()` can be called without args.
507
- - Now `loadShader()` and `loadShaderURL()` accepts null for unused parameters.
508
- - Now `RectCompOpt` accepts a array of numbers for `radius`.
509
-
510
- ### Deprecations
511
-
512
- > All changes applies for both v3001 and v4000
513
-
514
- - deprecated `kaboom()` in favor of `kaplay()` (you can still use `kaboom*`)
515
- - deprecated `SpriteComp.curAnim()` in favor of `SpriteComp.getCurAnim().name`
516
- - deprecated `fadeIn` component in favor of `OpacityComp.fadeIn()`
517
- - deprecated `Event`, `EventHandler` and `EventController` in favor of `KEvent`,
518
- `KEventHandler` and `KEventController`
519
-
520
- ### Bug fixes
521
-
522
- > All changes applies for both v3001 and v4000
523
-
524
- - **(break)** much typescript definitions was fixed, if you use typescript now
525
- maybe you see new errors that make your code strict
526
- - fix error screen not showing with not Error object
527
- - fix error where debug screen was scaling bad the blue rectangles
528
- - fix error where error screen was not showing when the error was thrown in a
529
- input event
530
- - fix error where fonts was cropped in the bottom
531
- - fix an error where `stay()` object loose their input events on scene change
532
-
533
- ### v3000.1.17
534
-
535
- - exposed `vel` property on `BodyComp`
536
-
537
- ### v3000.1.16
538
-
539
- - fixed error not being logged
540
- - fixed error screen scaling error in letterbox mode
541
-
542
- ### v3000.1.15
543
-
544
- - fixed `loadRoot()` not working sometimes
545
- - fixed audio being resumed when the tab is switched on but `debug.paused` is
546
- true
547
-
548
- ### v3000.1.12
549
-
550
- - fixed `color()` and `rgb()` not working
551
-
552
- ### v3000.1.11
553
-
554
- - added option `kaboom({ focus: false })` to disable focus on start
555
- - fixed `rand()` typing for numbers
556
- - fixed mouse position in fullscreen
557
- - added `Color#toHSL()`
558
-
559
- ### v3000.1.10
560
-
561
- - fixed test code accidentally getting shipped (where a screenshot will be
562
- downloaded every time you press space)
563
-
564
- ### v3000.1.9
565
-
566
- - added `fill` option to `rect()`, `circle()` and `sprite()`
567
- - fixed view getting cut off in letterbox mode
568
-
569
- ### v3000.1.8
570
-
571
- - fixed `scale` option acting weird when width and height are defined (by
572
- @hirnsalat)
573
-
574
- ### v3000.1.7
575
-
576
- - fixed `debug.paused` not pausing audio
577
- - added `mask()` component
578
- - added support for colored font outline
579
-
580
- ```js
581
- loadFont("apl386", "/examples/fonts/apl386.ttf", {
582
- outline: {
583
- width: 8,
584
- color: rgb(0, 0, 255),
585
- },
586
- });
587
- ```
588
-
589
- - fixed `wave()` not starting at `0` when time is `0`
590
- - kaboom now only displays error screen for kaboom's own error, instead of
591
- catching all errors in current window
592
- - added `KaboomError` class for errors related to current kaboom instance
593
- - setting `obj.text` with `text()` component now immediately updates `width` and
594
- `height` property
595
-
596
- ```js
597
- const obj = add([text("oh hi"), pos(100, 200)]);
598
-
599
- // before
600
- obj.text = "bye";
601
- console.log(obj.width); // still the width of "oh hi" until next render
602
-
603
- // before
604
- obj.text = "bye";
605
- console.log(obj.width); // will be updated to the width of "bye"
606
- ```
607
-
608
- ### v3000.1.6
609
-
610
- - fixed `loadSound` typing to accept `ArrayBuffer`
611
-
612
- ### v3000.1.5
613
-
614
- - added `Event#clear()` method
615
- - fixed `add()` without argument
616
-
617
- ### v3000.1.4
618
-
619
- - added `audio.stop()` method
620
-
621
- ```js
622
- const music = play("music");
623
- music.stop();
624
- ```
625
-
626
- ### v3000.1.3
627
-
628
- - fixed `onCollideUpdate()` still runs when object is paused
629
- - allow `add()` and `make()` without arguments
630
- - added `debug.numObjects()`
631
- - added `width` and `height` properties to `SpriteData`
632
-
633
- ```js
634
- // get sprite size
635
- getSprite("bean").then((spr) => {
636
- console.log(spr.width, spr.height);
637
- });
638
- ```
639
-
640
- ### v3000.1.2
641
-
642
- - fixed audio not pausing when tab hidden and `backgroundAudio` not set
643
- - fixed `debug.timeScale` not working
644
- - fixed `debug.paused` not able to resume
645
- - fixed `quad` option not working in `sprite()` component
646
- - added `onHide()` and `onShow()` for tab visibility event
647
-
648
- ### v3000.1.1
649
-
650
- - fixed some indirect `fixed` related issues
651
-
652
- ## [3000.1.0] - 2023-08-18 (kaboom.js)
653
-
654
- - added game object level input handling
655
-
656
- ```js
657
- // add a scene game object
658
- const scene = add([]);
659
-
660
- const bean = scene.add([sprite("bean"), pos(100, 200), area(), body()]);
661
-
662
- scene.onKeyPress("space", () => {
663
- bean.jump();
664
- });
665
-
666
- scene.onMousePress(() => {
667
- bean.jump();
668
- });
669
-
670
- // setting scene.paused will pause all the input events
671
- scene.paused = true;
672
-
673
- // destroying scene will cancel all its input events
674
- scene.destroy();
675
-
676
- const ui = add([]);
677
-
678
- ui.add(makeButton());
679
-
680
- // these will only work if ui game object is active
681
- ui.onMousePress(() => {
682
- // ...
683
- });
684
-
685
- // before you'll have to manually clean up events on obj.onDestroy()
686
- const scene = add([]);
687
- const evs = [];
688
- scene.onDestroy(() => {
689
- evs.forEach((ev) => ev.cancel());
690
- });
691
- evs.push(
692
- k.onKeyPress("space", () => {
693
- doSomeSceneSpecificStuff();
694
- }),
695
- );
696
- ```
697
-
698
- - added `make()` to create game object without adding to the scene
699
-
700
- ```js
701
- const obj = make([sprite("bean"), pos(120, 60)]);
702
-
703
- add(obj);
704
- ```
705
-
706
- - fixed children not inheriting `fixed()` from parent
707
-
708
- ```js
709
- // before
710
- const ui = add([fixed()]);
711
-
712
- ui.add([
713
- rect(),
714
- // have to also give all children game objects fixed()
715
- fixed(),
716
- ]);
717
-
718
- // now
719
- const ui = add([fixed()]);
720
-
721
- // you don't have to add fixed() to children
722
- ui.add([rect(100, 100)]);
723
- ```
724
-
725
- - fixed `AreaComp#onClick()` event not getting cleaned up when game object is
726
- destroyed
727
- - fixed typo `isTouchScreen()` -> `isTouchscreen()`
728
- - fixed inspect mode doesn't show the properties box of indirect children game
729
- objects
730
- - fixed some problem causing kaboom to not work with vite
731
- - fixed "destroy" event not run on children game objects
732
- - calling `shake()` when another shake is happening adds to the shake instead of
733
- reset it?
734
- - fixed incorrect touch position when canvas is not at top left of page
735
-
736
- ## [3000.0.0] - 2023-05-25 (kaboom.js)
737
-
738
- ### Game Objects
739
-
740
- - added scene graph, game objects are now stored in a tree-like structure and
741
- can have children with `obj.add()`
742
-
743
- ```js
744
- const bean = add([sprite("bean"), pos(160, 120)]);
745
-
746
- const sword = bean.add([
747
- sprite("sword"),
748
- // transforms will be relative to parent bean object
749
- pos(20, 20),
750
- rotate(20),
751
- ]);
752
-
753
- const hat = bean.add([
754
- sprite("hat"),
755
- // transforms will be relative to parent bean object
756
- pos(0, -10),
757
- ]);
758
-
759
- // children will be moved alongside the parent
760
- bean.moveBy(100, 200);
761
-
762
- // children will be destroyed alongside the parent
763
- bean.destroy();
764
- ```
765
-
766
- - added `recursive` and `liveUpdate` options to `get()`
767
-
768
- ```js
769
- const enemies = get("enemy", {
770
- // get from all children and descendants, instead of only direct children
771
- recursive: true,
772
- // live update the returned list to listen to onAdd and onDestroy events
773
- liveUpdate: true,
774
- });
775
-
776
- console.log(enemies.length); // 3
777
-
778
- add([sprite("bigbird"), "enemy"]);
779
-
780
- console.log(enemies.length); // 4
781
- ```
782
-
783
- - changed object update order from reversed to not reversed
784
- - (**BREAK**) removed `GameObj#every()` and `GameObj#revery()` in favor of
785
- `obj.get("*").forEach()`
786
- - (**BREAK**) renamed `GameObj#_id` to `GameObj#id`
787
- - `addLevel()` now returns a `GameObj` which has all individual grid objects as
788
- its children game objects, with `LevelComp` containing its previous methods
789
- - added `onAdd()` and `onDestroy()` events to listen to added / destroyed game
790
- objects
791
-
792
- ### Components
793
-
794
- - added support for getter and setters in component properties
795
-
796
- #### Area
797
-
798
- - added collision support for rotate shapes and polygons
799
- - added option `collisionIgnore` to `area()` component, which accepts a list of
800
- tags to ignore when checking collision
801
-
802
- ```js
803
- const bean = add([
804
- sprite("bean"),
805
- pos(100, 80),
806
- area({
807
- collisionIgnore: ["cloud", "particle"],
808
- }),
809
- ]);
810
- ```
811
-
812
- - added `Area#getCollisions` to get a list of all current collisions happening
813
-
814
- ```js
815
- for (const col of player.getCollisions()) {
816
- const c = col.target;
817
- if (c.is("chest")) {
818
- c.open();
819
- }
820
- }
821
- ```
822
-
823
- - added `Area#onCollideUpdate()` and `onCollideUpdate()` to register an event
824
- that runs every frame when 2 objects are colliding
825
- - added `Area#onCollideEnd()` and `onCollideEnd()` to register an event that
826
- runs once when 2 objects stop colliding
827
- - added `Area#onHover()` and `onHover()` to register an event that runs once
828
- when an object(s) is hovered over
829
- - added `Area#onHoverEnd()` and `onHoverEnd()` to register an event that runs
830
- once when an object(s) stops being hovered over
831
- - (**BREAK**) renamed `onHover()` to `onHoverUpdate()` (it registers an event
832
- that runs every frame when an object is hovered over)
833
- - (**BREAK**) renamed `pushOut()` to `resolveCollision()`
834
-
835
- #### Body
836
-
837
- - added `Body#onFall()` which fires when object starts falling
838
- - added `Body#onPhysicsResolve()` and `Body#onBeforePhysicsResolve()` to
839
- register events relating to collision resolution
840
-
841
- ```js
842
- // make semi-solid platforms that doesn't block player when player is jumping over it
843
- player.onBeforePhysicsResolve((collision) => {
844
- if (collision.target.is(["platform", "soft"]) && player.isJumping()) {
845
- collision.preventResolution();
846
- }
847
- });
848
- ```
849
-
850
- - (**BREAK**) removed `solid()` in favor of `body({ isStatic: true })`
851
- - added option `body({ mass: 3 })` to define how hard a non-static body is to be
852
- pushed by another non-static body
853
- - added option `body({ stickToPlatform: false })` to turn off object moving with
854
- platform
855
- - (**BREAK**) removed `Body#doubleJump()` in favor of `doubleJump()` component
856
- - (**BREAK**) renamed `Body#weight` to `Body#gravityScale`
857
- - (**BREAK**) renamed `Body#onFall()` to `Body#onFallOff()` which triggers when
858
- object fall off a platform
859
- - (**BREAK**) defining `setGravity()` is now required for enabling gravity,
860
- `body()` by default will only prevent objects from going through each other
861
-
862
- #### Others
863
-
864
- - (**BREAK**) renamed `origin()` to `anchor()`, so it won't mess up typescript
865
- in global mode
866
- - (**BREAK**) `anchor` (previously `origin`) no longer controls text alignment,
867
- use `text({ align: "left" })` option instead
868
- - added `doubleJump()` component to enable double jump (or any number of jumps)
869
- - (**BREAK**) renamed `outview()` to `offscreen()`, and uses a much faster check
870
- (but less accurate) for if object is offscreen
871
- - removed `offset` option in favor of a simpler `distance` option
872
- - renamed `onExitView()` and `onEnterView()` to `onExitScreen()` and
873
- `onEnterScreen()`
874
- - (**BREAK**) removed `cleanup()` component in favor of
875
- `offscreen({ destroy: true })`
876
- - added `OpacityComp#fadeOut()`
877
- - added `fadeIn()` component
878
- - `stay()` now accepts a list of scenes to stay for, like
879
- `stay(["gameover", "menu"])`
880
- - (**BREAK**) changed `SpriteComp#flipX` and `SpriteComp#flipY` to properties
881
- instead of functions
882
- - (**BREAK**) `sprite.onAnimStart()` and `sprite.onAnimEnd()` now triggers on
883
- any animation
884
-
885
- ```js
886
- // before
887
- obj.onAnimEnd("walk", () => {
888
- // do something
889
- });
890
-
891
- // v3000
892
- obj.onAnimEnd((anim) => {
893
- if (anim === "walk") {
894
- // do something
895
- }
896
- });
897
- ```
898
-
899
- - (**BREAK**) `ScaleComp#scale` will always be a `Vec2` not `number`
900
- - `shader()` comp `uniform` parameter now supports a callback that returns the
901
- uniform every frame
902
-
903
- ```js
904
- const player = add([
905
- sprite("bean"),
906
- // will calculate and send u_time every frame
907
- shader("flashy", () => ({
908
- u_time: time(),
909
- })),
910
- ]);
911
- ```
912
-
913
- ### Assets
914
-
915
- - added `loadProgress()` that returns a `0.0 - 1.0` that indicates current asset
916
- loading progress
917
- - added option `loadingScreen` to `kaboom()` where you can turn off the default
918
- loading screen
919
- - added `onLoadUpdate()` to register a custom loading screen (see "loader"
920
- example)
921
-
922
- ```js
923
- // custom loading screen
924
- onLoadUpdate((progress) => {
925
- drawCircle({
926
- pos: center(),
927
- radius: 32,
928
- end: map(progress, 0, 1, 0, 360),
929
- });
930
- });
931
- ```
932
-
933
- - added support for multiple sprite sources as frames in `loadSprite()`
934
-
935
- ```js
936
- loadSprite("player", [
937
- "sprites/player_idle.png",
938
- "sprites/player_run.png",
939
- "sprites/player_jump.png",
940
- ]);
941
- ```
942
-
943
- - (**BREAK**) added `loadShaderURL()`, `loadShader()` now only load shader code
944
- not files
945
-
946
- ### Text
947
-
948
- - added `loadFont()` to load `.ttf`, `.otf`, `.woff2` or any font supported by
949
- browser `FontFace`
950
-
951
- ```js
952
- // Load a custom font from a .ttf file
953
- loadFont("FlowerSketches", "/examples/fonts/FlowerSketches.ttf");
954
-
955
- // Load a custom font with options
956
- loadFont("apl386", "/examples/fonts/apl386.ttf", {
957
- outline: 4,
958
- filter: "linear",
959
- });
960
- ```
961
-
962
- - (**BREAK**) renamed previous `loadFont()` to `loadBitmapFont()`
963
- - (**BREAK**) removed built-in `apl386`, `apl386o`, `sink`, `sinko` (still
964
- available under `examples/fonts`)
965
- - changed default font size to `36`
966
- - (**BREAK**) changed to bbcode syntax for styled text
967
-
968
- ```js
969
- // before
970
- "[oh hi].green here's some [styled].wavy text";
971
- // v3000
972
- "[green]oh hi[/green] here's some [wavy]styled[/wavy] text";
973
- ```
974
-
975
- ### Graphics
976
-
977
- - fixed visual artifacts on text rendering
978
- - added `colors` option to `drawPolygon()` that controls the color of each
979
- corner
980
- - added `gradient` option to `drawRect()` that specifies the start and end color
981
- - added `drawMasked()` and `drawSubtracted()`
982
- - added `pushRotateX()`, `pushRotateY()` and `pushRotateZ()`
983
- - added `pixelDensity` option to `kaboom()`
984
- - (**BREAK**) changed position vertex format from `vec3` to `vec2` (which is
985
- passed in as the first argument of custom `frag` and `vert` shader functions)
986
- - added `usePostEffect()` to add post process shader
987
-
988
- ```js
989
- loadShader(
990
- "invert",
991
- null,
992
- `
993
- vec4 frag(vec2 pos, vec2 uv, vec4 color, sampler2D tex) {
994
- vec4 c = def_frag();
995
- return vec4(1.0 - c.r, 1.0 - c.g, 1.0 - c.b, c.a);
996
- }
997
- `,
998
- );
999
-
1000
- usePostEffect("invert");
1001
- ```
1002
-
1003
- - shader error logs now yields the correct line number
1004
- - added `slice9` option to `loadSprite()` to enable
1005
- [9 slice scaling](https://en.wikipedia.org/wiki/9-slice_scaling)
1006
-
1007
- ```js
1008
- loadSprite("grass", "/sprites/grass.png", {
1009
- slice9: {
1010
- left: 8,
1011
- right: 8,
1012
- top: 8,
1013
- bottom: 8,
1014
- },
1015
- });
1016
-
1017
- const g = add([sprite("grass")]);
1018
-
1019
- onMouseMove(() => {
1020
- const mpos = mousePos();
1021
- // updating width / height will scale the image but not the sliced frame
1022
- g.width = mpos.x;
1023
- g.height = mpos.y;
1024
- });
1025
- ```
1026
-
1027
- ### Audio
1028
-
1029
- - added option `kaboom({ backgroundAudio: false })` to not pause audio when tab
1030
- not active
1031
- - changed `speed`, `detune`, `volume`, `loop` in `AudioPlay` from functions to
1032
- properties
1033
- - added `onEnd()` event for `const pb = play("sound")`
1034
-
1035
- ```js
1036
- // before
1037
- const music = play("song");
1038
- music.speed(2);
1039
- music.volume(0.5);
1040
- music.loop(true);
1041
-
1042
- // v3000
1043
- const music = play("song");
1044
- music.speed = 2;
1045
- music.volume = 0.5;
1046
- music.loop = true;
1047
- ```
1048
-
1049
- ### Input
1050
-
1051
- - added `onScroll(action: (delta: Vec2) => void)` to listen mouse wheel scroll
1052
- - fixed touches not treated as mouse
1053
- - (**BREAK**) changed `onTouchStart()`, `onTouchMove()` and `onTouchEnd()`
1054
- callback signature to `(pos: Vec2, touch: Touch) => void` (exposes the native
1055
- `Touch` object)
1056
- - added `onGamepadButtonPress()`, `onGamepadButtonDown()`,
1057
- `onGamepadButtonRelease()`
1058
- - added `isGamepadButtonPressed()`, `isGamepadButtonDown()`,
1059
- `isGamepadButtonReleased()`
1060
- - added `onGamepadStick()` to handle gamepad axes info for left and right sticks
1061
- - added `getConnectedGamepads()`
1062
- - added `onGamepadConnect()` and `onGamepadDisconnect()`
1063
- - added `gamepads` option to `kaboom()` to define custom gamepads
1064
-
1065
- ### Level
1066
-
1067
- - (**BREAK**) changed `addLevel()` options API
1068
- - renamed `width` and `height` to `tileWidth` and `tileHeight`
1069
- - renamed `any` to `wildcardTile`
1070
- - now all tile symbols are defined in the `tiles` object
1071
-
1072
- ```js
1073
- // before
1074
- addLevel(["@ ^ $$", "======="], {
1075
- width: 32,
1076
- height: 32,
1077
- "=": () => [sprite("grass"), area(), body({ isStatic: true })],
1078
- $: () => [sprite("coin"), area(), "coin"],
1079
- any: (symbol) => {
1080
- if (symbol === "@") {
1081
- return [
1082
- /* ... */
1083
- ];
1084
- }
1085
- },
1086
- });
1087
-
1088
- // v3000
1089
- addLevel(["@ ^ $$", "======="], {
1090
- tileWidth: 32,
1091
- tileHeight: 32,
1092
- tiles: {
1093
- "=": () => [sprite("grass"), area(), body({ isStatic: true })],
1094
- $: () => [sprite("coin"), area(), "coin"],
1095
- },
1096
- wildcardTile: (symbol) => {
1097
- if (symbol === "@") {
1098
- return [
1099
- /* ... */
1100
- ];
1101
- }
1102
- },
1103
- });
1104
- ```
1105
-
1106
- ### Misc
1107
-
1108
- - sprites are now automatically packed, improving performance
1109
- - (**BREAK**) renamed `gravity()` into `getGravity()` and `setGravity()`
1110
- - (**BREAK**) removed all deprecated functions in v2000.2
1111
- - (**BREAK**) raised esbuild target to `esnext`
1112
- - added `setBackground()` and `getBackground()` in addition to `background`
1113
- option in `kaboom()`
1114
- - moved type defs for global functions to `import "kaboom/global"`
1115
-
1116
- ```js
1117
- // if use global functions
1118
- import "kaboom";
1119
- import "kaboom/global"; // required to load global types
1120
-
1121
- kaboom();
1122
-
1123
- // will have definition
1124
- add();
1125
- ```
1126
-
1127
- ```js
1128
- // if don't use global function
1129
- import "kaboom";
1130
-
1131
- kaboom({ global: false });
1132
-
1133
- // type error, won't pollute global namespace if not manually import "kaboom/global"
1134
- add();
1135
- ```
1136
-
1137
- - added `tween()` for tweening, and a set of built-in easing functions in
1138
- `easings`
1139
-
1140
- ```js
1141
- onMousePress(() => {
1142
- tween(
1143
- bean.pos.x,
1144
- mousePos().x,
1145
- 1,
1146
- (val) => (bean.pos.x = val),
1147
- easings.easeOutBounce,
1148
- );
1149
- tween(
1150
- bean.pos.y,
1151
- mousePos().y,
1152
- 1,
1153
- (val) => (bean.pos.y = val),
1154
- easings.easeOutBounce,
1155
- );
1156
- });
1157
- ```
1158
-
1159
- - (**BREAK**) changed all event handlers to return a `EventController` object
1160
- instead of a function to cancel event
1161
-
1162
- ```js
1163
- // before
1164
- const cancel = onUpdate(() => {
1165
- /* ... */
1166
- });
1167
- cancel();
1168
-
1169
- // v3000
1170
- const ev = onUpdate(() => {
1171
- /* ... */
1172
- });
1173
- ev.paused = true;
1174
- ev.cancel();
1175
- ```
1176
-
1177
- - timers can now be paused
1178
-
1179
- ```js
1180
- const timer = wait(4, () => {
1181
- /* ... */
1182
- });
1183
- timer.paused = true;
1184
- timer.resume();
1185
-
1186
- const timer = loop(1, () => {
1187
- /* ... */
1188
- });
1189
- timer.paused = true;
1190
- timer.resume();
1191
- ```
1192
-
1193
- - `kaboom()` now automatically focuses the canvas
1194
- - added `quit()` to end everything
1195
- - added `download()`, `downloadText()`, `downloadJSON()`, `downloadBlob()`
1196
- - added `Recording#stop()` to stop the recording and returns the video data as
1197
- mp4 Blob
1198
- - added `debug.numFrames()` to get the total number of frames elapsed
1199
- - added `onError()` to handle error or even custom error screen
1200
- - added `onResize()` to register an event that runs when canvas resizes
1201
- - added `setCursorLocked()` and `isCursorLocked()`
1202
- - (**BREAK**) renamed `cursor()` to `setCursor()`
1203
- - (**BREAK**) renamed `fullscreen()` to `setFullscreen()`
1204
- - (**BREAK**) renamed `isTouch()` to `isTouchscreen()`
1205
- - (**BREAK**) removed `layers()` in favor of parent game objects (see "layers"
1206
- example)
1207
- - (**BREAK**) removed `load()` event for components, use `onLoad()` in `add()`
1208
- event
1209
- - (**BREAK**) removed `debug.objCount()` in favor of `getAll().length`
1210
- - added `debug.numFrames()` to get the current frame count
1211
-
1212
- ## [2000.2.6] - 2022-01-27 (kaboom.js)
1213
-
1214
- - fixed text always being wrapped if updated
1215
- - fixed text comp properties `letterSpacing`, `charSpacing`, `transform`,
1216
- `styles` not being exposed
1217
-
1218
- ### v2000.2.5
1219
-
1220
- - fixed updating `font` property on gameobj not updating the text font
1221
-
1222
- ### v2000.2.4
1223
-
1224
- - fixed `focus()` not properly exported
1225
- - deprecated `focus()` in favor of `canvas.focus()` due to name collision
1226
-
1227
- ### v2000.2.3
1228
-
1229
- - fixed `kaboom.d.ts` completely messed up
1230
-
1231
- ### v2000.2.2
1232
-
1233
- - fixed doc for `TextCompOpt#styles` and `DrawTextOpt#styles`
1234
-
1235
- ### v2000.2.1
1236
-
1237
- - fixed updates not running at all when `kaboom({ debug: false })`
1238
-
1239
- ## [2000.2.0] "Fancy Text Mode" 2022-01-23 (kaboom.js)
1240
-
1241
- - added `formatText()` and `drawFormattedText()`
1242
- - added `charSpacing` and `lineSpacing` in `TextCompOpt` and `DrawTextOpt`
1243
- - added optional `transitions` argument in `state()` to define allowed
1244
- transitions
1245
- - added `StateComp#onStateTransition` to register event for specific transitions
1246
- - added syntax to style a piece of text `"this is a [styled].wavy text"` and
1247
- `style` option in `TextCompOpt` and `DrawTextOpt` to define the styles with
1248
- `CharTransformFunc`
1249
- - deprecated `dir()` in favor of `Vec2.fromAngle()`
1250
- - fixed `onTouchEnd()` fired on `touchmove`
1251
- - added `outview()` component to control behavior when object leaves visible
1252
- area
1253
- - deprecated `cleanup(delay?: number)` in favor of `cleanup(opt?: CleanupOpt)`
1254
- - deprecated `mouseWorldPos()` in favor of `toWorld(mousePos())`
1255
- - deprecated `rng()` in favor of `new RNG()`
1256
- - added classes `Vec2`, `Color`, `Mat4`, `Timer`, `Quad`, `RNG`, `Line`, `Rect`,
1257
- `Circle`
1258
- - added deprecation warning
1259
- - fixed letterbox view mode
1260
- - allow non-stretch letterbox
1261
- - fixed mouse position malfunction in fullscreen, stretch and letterbox mode
1262
-
1263
- ### [2000.1.8]
1264
-
1265
- - fixed `Color#eq()` not giving correct result
1266
-
1267
- ### v2000.1.7
1268
-
1269
- - fixed not having export if installed from github repo with npm
1270
- - fixed event canceller returned by raw `onUpdate()` and `onDraw()` crashing
1271
-
1272
- ### v2000.1.6
1273
-
1274
- - fixed debug widget scale
1275
-
1276
- ### v2000.1.5
1277
-
1278
- - fixed `enterState()` not passing args to `onStateEnter()` callback
1279
-
1280
- ### v2000.1.4
1281
-
1282
- - fixed `state()` to not require registering `onStateUpdate()` before using any
1283
- state
1284
-
1285
- ### v2000.1.2
1286
-
1287
- - fixed `onKeyRelease()` wrongfully check for key press instead of release
1288
-
1289
- ### v2000.1.1
1290
-
1291
- - fixed `StateComp#enterState()` not accepting any state
1292
-
1293
- ## [2000.1.0] "Record Mode" - 2021-11-04 (kaboom.js)
1294
-
1295
- - added `hsl2rgb()` for converting HSL color to kaboom RGB
1296
- - added `record()` to start a screen recording
1297
- - added F5 to screenshot and F6 to toggle record mode in debug mode
1298
- - added `DrawTextOpt#transform()` and `TextCompOpt#transform()` for defining
1299
- style and transformation for each character
1300
- - added `state()` component for finite state machine
1301
- - added support for multiple tags in `get()` and `every()`
1302
- - added UI indicator for `debug.paused` and `debug.timeScale`
1303
- - changed inspect mode UI style
1304
- - added color constants `WHITE`, `BLACK`, `BLUE`, `GREEN`, `RED`, `MAGENTA`,
1305
- `CYAN`, `YELLOW`
1306
- - added new API style (`on` prefix for all event handler function, `is` prefix
1307
- for all boolean state getters)
1308
- - `onLoad()`
1309
- - `onUpdate()`
1310
- - `onDraw()`
1311
- - `onKeyPress()`
1312
- - `onKeyPressRepeat()`
1313
- - `onKeyDown()`
1314
- - `onKeyRelease()`
1315
- - `onMousePress()`
1316
- - `onMouseDown()`
1317
- - `onMouseRelease()`
1318
- - `onMoueMove()`
1319
- - `onTouchStart()`
1320
- - `onTouchMove()`
1321
- - `onTouchEnd()`
1322
- - `onCollide()`
1323
- - `onClick()`
1324
- - `onHover()`
1325
- - `isFocused()`
1326
- - `isKeyDown()`
1327
- - `isKeyPressed()`
1328
- - `isKeyPressedRepeat()`
1329
- - `isKeyDown()`
1330
- - `isMouseDown()`
1331
- - `isMousePressed()`
1332
- - `isMouseReleased()`
1333
- - `isMouseMoved()`
1334
- - `isMouseMoved()`
1335
- - `GameObj#onUpdate()`
1336
- - `GameObj#onDraw()`
1337
- - `AreaComp#onCollide()`
1338
- - `AreaComp#onHover()`
1339
- - `AreaComp#onClick()`
1340
- - `BodyComp#onGround()`
1341
- - `BodyComp#onFall()`
1342
- - `BodyComp#onHeadbutt()`
1343
- - `BodyComp#onDoubleJump()`
1344
- - `BodyComp#isGrounded()`
1345
- - `BodyComp#isFalling()`
1346
- - `SpriteComp#onAnimEnd()`
1347
- - `SpriteComp#onAnimStart()`
1348
- - `HealthComp#onDeath()`
1349
- - `HealthComp#onHurt()`
1350
- - `HealthComp#onHeal()`
1351
- - `AudioPlay#isStopped()`
1352
- - `AudioPlay#isPaused()`
1353
-
1354
- ## [2000.0.0] "Burp Mode" - 2021-10-20 (kaboom.js)
1355
-
1356
- - version jumped to v2000.0.0 (still semver, just big)
1357
- - added `burp()` for easy burping
1358
- - added decent typescript / autocomplete support and jsdocs
1359
- - introducing new character "bean" ![bean](assets/sprites/bean.png)
1360
- - added `loadBean()` to load `"bean"` as a default sprite
1361
- - changed default font to [APL386](https://abrudz.github.io/APL386/), as
1362
- `"apl386o"` (default outlined version) and `"apl386"`
1363
- - included font
1364
- [kitchen sink](https://polyducks.itch.io/kitchen-sink-textmode-font) as
1365
- `"sinko"` (outlined version) and `"sink"` (standard version with extended
1366
- characters for text-mode games)
1367
- - added `font` field in `KaboomOpt` to set the default font
1368
- - added `loadSpriteAtlas(src, entries)` to load sprite atlas
1369
- - inspect mode now displays every comp's state
1370
- - **BREAK** added continuous collision resolution which checks collision in
1371
- `move()` if 2 objects are both "solid" (objects now won't pass through other
1372
- solid object at high speed or low framerate)
1373
-
1374
- ```js
1375
- // before
1376
- add([sprite("player"), area()]);
1377
-
1378
- add([sprite("rock"), solid()]);
1379
-
1380
- keyDown("left", () => {
1381
- player.move(-120, 0);
1382
- });
1383
-
1384
- player.action(() => {
1385
- player.resolve(); // or pushOutAll() in beta versions
1386
- });
1387
-
1388
- // after
1389
- const player = add([sprite("player"), area(), solid()]);
1390
-
1391
- // both should be solid
1392
- add([sprite("rock"), area(), solid()]);
1393
-
1394
- keyDown("left", () => {
1395
- // this will handle collision resolution for you, if the other obj is also "solid"
1396
- player.move(-120, 0);
1397
- });
1398
- ```
1399
-
1400
- - added comp `opacity()` to set opacity
1401
- - added comp `health()` to manage health related logic
1402
- - added comp `move()` to manage projectile-like behavior
1403
- - added comp `cleanup()` to auto destroy obj when it leaves screen
1404
- - added comp `outline()` to draw a lil outline
1405
- - added comp `timer()` to attach timers to a game obj
1406
- - added comp `fixed()` to make a game obj unaffected by camera
1407
- - added comp `stay()` to make a game obj stay after scene switch
1408
- - added comp `lifespan()` to destroy game obj after certain amount of time
1409
- - added comp `z()` to define draw order for objs on the same layer
1410
- - added `weight` to `BodyComp` and `BodyCompOpt` to control the gravity
1411
- multiplier
1412
- - added `djump()` to `BodyComp` for double jump
1413
- - added `dir()` to calculate directional vector from angle
1414
- - added constants `LEFT`, `RIGHT`, `UP`, `DOWN` for unit directional vector
1415
- - added `fullscreen()` to enable real fullscreen mode
1416
- - **BREAK** separated color and opacity, removed `rgba()` in favor of `rgb`, use
1417
- component `opacity()` to define opacity
1418
- - **BREAK** changed color from 0-1 range to 0-255, angles from radians to
1419
- degrees
1420
-
1421
- ```js
1422
- // before
1423
- add([rotate(Math.PI / 2), color(0, 0.5, 1.0, 0.5)]);
1424
-
1425
- // after
1426
- add([rotate(90), color(0, 127, 255), opacity(0.5)]);
1427
- ```
1428
-
1429
- - `global` and `debug` flag now are enabled by default, need to turn off
1430
- manually if you don't want
1431
- - added input events `touchStart(id, pos)`, `touchMove(id, pos)`,
1432
- `touchEnd(id, pos)`, `mouseMove(pos)`
1433
- - added `mouseDeltaPos()`
1434
- - added `touchToMouse` to control if touch events should be translated to mouse
1435
- events
1436
- - added `mousePos()` now gets the screen mouse pos, use `mouseWorldPos()` to get
1437
- the mouse position affected by camera
1438
- - added `anim` field in `SpriteCompOpt` to play an anim on start
1439
- - better type support for components
1440
- - `scene()` and `start()` (also removed in favor of `go()`) are optional now, if
1441
- you don't need multiple scenes yet you can just go directly
1442
-
1443
- ```js
1444
- kaboom();
1445
- // no mandatory scene() to start kabooming
1446
- add(...);
1447
- keyPress(...);
1448
- ```
1449
-
1450
- - **BREAK** `area()` is now explicit and not automatically added by `sprite()`,
1451
- `rect()`, and `text()`, removed each `noArea` or `area` config field
1452
- - **BREAK** `area()` now takes an `AreaCompOpt`, where you can define the area
1453
- size, scale, and hover cursor
1454
-
1455
- ```js
1456
- add([
1457
- sprite("bean"),
1458
- area(), // empty area will derive from sprite size
1459
- area({ scale: 0.5 }), // 0.5x the sprite size
1460
- area({ offset: vec2(0, 12), width: 4, height: 12 }), // more control over the collider region
1461
- ]);
1462
- ```
1463
-
1464
- - **BREAK** renamed `isCollided()` to `isColliding()`, `isHovered()` to
1465
- `isHovering()`
1466
- - **BREAK** removed `overlaps()` and `isOverlapped()` and replaced with
1467
- `isColliding()` and `collides()` only checks doesn't return true when 2
1468
- objects are just touching each other, use `isTouching()` to check if they're
1469
- not colliding but just touching each other
1470
- - added `isTouching()` to check if 2 objects are collided or just touching other
1471
- - audio is now paused when you leave the tab
1472
- - audio is now paused on `debug.paused = true`
1473
- - added local storage helper `getData(key, default?)` and `setData(key, data)`
1474
- - added `loadShader(id, vert, frag, isUrl)`
1475
- - added `shader()` comp for attaching custom shader to an obj
1476
- - different layers do not prevent collisions now
1477
- - **BREAK** changed last argument of `loadFont()` to `FontLoadOpt`
1478
- - all event handlers like `keyPress()`, `mouseClick()`, `action()`, `collides()`
1479
- now returns a function to cancel that listener
1480
- - added `require` on component definitions, making it possible to declare
1481
- dependencies for components, e.g.
1482
-
1483
- ```js
1484
- function alwaysRight() {
1485
- return {
1486
- // the id of this component
1487
- id: "alwaysRight",
1488
- // list of component ids that this requires
1489
- require: ["pos"],
1490
- update() {
1491
- // so you can use `move()` from pos() component with no worry
1492
- this.move(100, 0);
1493
- },
1494
- };
1495
- }
1496
- ```
1497
-
1498
- - **BREAK** overlapping component fields are not allowed, e.g. you can't have a
1499
- custom comp that has a `collides` field if it already have a `area` component,
1500
- since it already has that
1501
- - **BREAK** changed `text(txt, size, conf)` to `text(txt, conf)` with `size` as
1502
- a field
1503
- - added `obj.c(id)` for getting a specific comp's state (by default all comps'
1504
- states are mounted to the obj by `Object.defineProperty`)
1505
-
1506
- ```js
1507
- // both works
1508
- obj.play("anim");
1509
- obj.c("sprite").play("anim");
1510
- ```
1511
-
1512
- - pedit, aseprite plugins are now included by default
1513
- - added `addKaboom()` for quick kaboom explosion
1514
- - `load*()` now accepts `null` as name and not load into assets manager, instead
1515
- just return the resource data handle
1516
- - **BREAK** renamed event `headbump` to `headbutt`
1517
- - **BREAK** renamed event `grounded` to `ground`
1518
- - added `width`, `height`, and `tiled` attrib to `SpriteCompOpt`, for better
1519
- control over sprite size and tiled sprite support
1520
- - **BREAK** renamed `resolve()` to `pushOutAll()` on `area` comp
1521
- - added `pushOut()` for pushing a single object out from another with `area`
1522
- comp
1523
- - fixed `"add"` event getting called twice for tagged objs
1524
- - added `moveTo(dest: Vec2, speed?: number)` to `pos()` comp
1525
- - added `keyPress()` (and all other key events) with no arg to check for any key
1526
- - **BREAK** renamed `camShake()` to `shake()`
1527
- - added `flipX` and `flipY` on `sprite()` comp configuration, and `flipX()`
1528
- `flipY()` methods
1529
- - **BREAK** remove `flipX()` and `flipY()` on `scale()` comp
1530
- - **BREAK** removed `start()` in favor of `go()`
1531
- - **BREAK** removed `changeSprite()` in favor of `use(sprite("newsprite"))`
1532
- - tags and components are converged, tags are just empty components now
1533
- - added `unuse()` to remove a component or tag
1534
- - **BREAK** removed `rmTag()` in favor of `unuse()`
1535
- - **BREAK** removed `camIgnore()` in favor of `fixed()`
1536
- - **BREAK** renamed `makeRng()` to `rng()`
1537
- - sprite animation now supports defining properties like loop and speed in load
1538
- step and play step
1539
-
1540
- ```js
1541
- loadSprite("hero", "hero.png", {
1542
- sliceX: 9,
1543
- anims: {
1544
- idle: { from: 0, to: 3, speed: 3, loop: true },
1545
- run: { from: 4, to: 7, speed: 10, loop: true },
1546
- hit: 8,
1547
- },
1548
- });
1549
- ```
1550
-
1551
- - **BREAK** changed `.play(anim, ifLoop)` under `sprite()` to accept a dict of
1552
- properties `.play(anim, { loop: true, speed: 60, pingpong: true })`
1553
- - **BREAK** now every symbol definition in `addLevel()` should be a function
1554
- returning the component list, to ensure there's no weird shared states
1555
-
1556
- ```js
1557
- addLevel(["* *", "* *", "======"], {
1558
- "*": () => [sprite("wall"), area(), solid()],
1559
- "=": () => [sprite("floor"), area(), solid()],
1560
- });
1561
- ```
1562
-
1563
- - **BREAK** renamed `clearColor` to `background`
1564
- - added collision detection functions `testLineLine()`, `testRectRect()`,
1565
- `testRectLine()` etc.
1566
- - added drawing functions `drawSprite()`, `drawRect()`, `drawCircle()`,
1567
- `drawPolygon()`, `drawEllipse()`, `drawLine()`, `drawLines()`
1568
- - added transformation functions `pushTransform()`, `popTransform()`,
1569
- `pushTranslate()`, `pushRotate()`, `pushScale()`
1570
- - **BREAK** removed `areaWidth()` and `areaHeight()` since they won't make sense
1571
- if the area shape is not rectangle, use `worldArea()` if you need area data
1572
-
1573
- ```js
1574
- const area = player.worldArea();
1575
- if (area.shape === "rect") {
1576
- const width = area.p2.x - area.p1.x;
1577
- const height = area.p2.y - area.p1.y;
1578
- }
1579
- ```
1580
-
1581
- ### v0.5.1
1582
-
1583
- - added plugins npm package support e.g.
1584
- `import asepritePlugin from "kaboom/plugins/aseprite"`
1585
-
1586
- ## [0.5.0] "Sticky Type" - 2021-05-11 (kaboom.js)
1587
-
1588
- - platforms are now sticky
1589
- - moved to TypeScript
1590
- - improved graphics performance
1591
- - improved inspect drawing performance
1592
- - added on-screen log that catches all kinds of errors
1593
- - added `cursor()`
1594
- - added `curPlatform()` by `body()`
1595
- - added `falling()` by `body()`
1596
- - added `changeSprite()` by `sprite()`
1597
- - added `duration()` and `time()` for the handle returned by `play()`
1598
- - added optional `seek` field to the audio play conf `play([conf])`
1599
- - added `LoopHandle` returned by `loop()` that has a `stop()`
1600
- - added a default background (can be dismissed by setting `clearColor`)
1601
- - fixed `sound.pause()` to work on firefox
1602
- - fixed collisions not treating explicit default layer the same as implicit
1603
- default layer
1604
- - fixed unable to play another anim in `onAnimEnd()`
1605
- - fixed scene switches happen in the middle of a frame
1606
- - fixed `scale(0)` not working
1607
- - fixed `mousePos()` not returning the camera affected pos with no layers
1608
- - **BREAK** changed `dbg()` to plain `debug` object
1609
- - **BREAK** moved `fps()`, `objCount()`, `stepFrame()`, `log()`, `error()` under
1610
- `debug`
1611
- - **BREAK** removed `debug.logTime`
1612
- - **BREAK** changed component `debugInfo()` hook to `inspect()`
1613
- - **BREAK** removed `timer()` component
1614
- - **BREAK** renamed `removeTag()` to `rmTag()`
1615
- - **BREAK** changed `SpriteAnim` from `[ from, to ]` to
1616
- `{ from: number, to: number }`
1617
- - **BREAK** removed `onAnimPlay()` and `onAnimEnd()` in favor of generic event
1618
- `on("animEnd", (anim: string) => {})`
1619
- - **BREAK** removed `obj.addTag()` in favor of `obj.use()`
1620
- - **BREAK** merged `debug.hoverInfo` and `debug.showArea` into `debug.inspect`
1621
- - **BREAK** removed `sound.resume()` in favor of `sound.play()`
1622
-
1623
- ### v0.4.1
1624
-
1625
- - fixed `on("destroy")` handler getting called twice
1626
- - fixed sprite `play()` not playing
1627
-
1628
- ## [0.4.0] "Multiboom" - UNKNOWN (kaboom.js)
1629
-
1630
- - **BREAK** removed `init()` and `kaboom.global()`, in favor of `kaboom()`, also
1631
- allows multiple kaboom games on one page
1632
-
1633
- ```js
1634
- // replaces init(), and added a 'global' flag for previous kaboom.global()
1635
- kaboom({
1636
- global: true,
1637
- width: 480,
1638
- height: 480,
1639
- });
1640
- ```
1641
-
1642
- or not global
1643
-
1644
- ```js
1645
- const k = kaboom();
1646
- k.scene();
1647
- k.start();
1648
- k.vec2();
1649
- ```
1650
-
1651
- - **BREAK** changed `clearColor` on `kaboom(conf)` to accept a 4 number array
1652
- instead of `rgba()`
1653
- - added a plugin system, see the `multiboom` example and `src/plugins`
1654
- - **BREAK** removed support for `.kbmsprite`, supports newer version of `.pedit`
1655
- through pedit plugin
1656
- - **BREAK** `loadAseprite()` and made it an external plugin under
1657
- `plugins/aseprite.js`
1658
- - added `sceneData()` for custom scene data kv store
1659
- - fixed `mouseClick` doesn't work on mobile
1660
- - disabled context menu on canvas
1661
- - prevented default behavior for 'tab' and function keys
1662
- - added `numFrames()` by `sprite()`
1663
- - added `screenshot()` that returns of a png base64 data url for a screenshot
1664
-
1665
- ## [0.3.0] "King Dedede...Bug!" - UNKNOWN
1666
-
1667
- - **BREAK** removed `pause()` and `paused()` in favor to `kaboom.debug.paused`
1668
- - **BREAK** removed `velY`, `curPlatform` and `maxVel` fields by `body()`
1669
- - **BREAK** changed `curAnim` by `sprite()` to method `curAnim()`
1670
- - fixed `dt()` surge on page visibility change (#20)
1671
- - pause audio when page is not visible
1672
- - added built in debug control with `init({ debug: true, })`
1673
- - `` ` ``: toggle `showLog` (default on with `debug: true`)
1674
- - `f1`: toggle `showArea`
1675
- - `f2`: toggle `hoverInfo`
1676
- - `f8`: toggle `paused`
1677
- - `f7`: decrease `timeScale`
1678
- - `f9`: increase `timeScale`
1679
- - `f10`: `stepFrame()`
1680
- - added on screen logging with `log()` and `error()`
1681
- - fixed `loadRoot()` sometimes doesn't work in async tasks
1682
-
1683
- ## [0.2.0] "Hear the Tremble" - UNKNOWN
1684
-
1685
- - **BREAK** removed `aseSpriteSheet` conf field from
1686
- `loadSprite(name, src, conf)`
1687
- - added `pause()`, `resume()`, `stop()`, `loop()`, `unloop()`, `volume()`,
1688
- `detune()`, `speed()` methods to the handle returned by `play()`
1689
- - added `camShake()` for built in camera shake
1690
- - added `loadAseprite(name, imgSrc, jsonSrc)`
1691
- - added area component generation for `text()`
1692
- - added `noArea` to conf field of `sprite()`, `rect()` and `text()`, allowing to
1693
- disable auto area component generation
1694
- - added a `quad` field to sprite comp creation config
1695
- `sprite(id, { quad: quad(0, 0, 0.5, 0.5) })`
1696
- - fixed `resolve()` not working if the obj also has `solid`, so it does not
1697
- check for itself (#8)
1698
- - `mousePos()` accepts a layer argument, which returns the mouse position
1699
- affected by camera transform if that layer is not `camIgnore()`-ed
1700
- - fixed camera position getting calculated before completing every object's
1701
- update (#14)
1702
- - fixed some cases `on("grounded", f)` called multiple times when moving on a
1703
- smooth platform
1704
- - added `revery()` to iterate objects in reverse order
1705
- - added `readd()` to re-add an object to the scene without triggering events
1706
- - added `level.spawn()`
1707
-
1708
- ## [0.1.0] "Oh Hi Mark" -
1709
-
1710
- - **BREAK** changed default origin point to `"topleft"`, so if you want object
1711
- origin point to be at center you'll need to manual `origin("center")`
1712
- - **BREAK** integrated `kit/physics` and `kit/level` to main lib
1713
- - **BREAK** makes `collides()` only run on first collision, not run every frame
1714
- during the same collision
1715
- - **BREAK** `camPos()` by default focuses to center, so `camPos(player.pos)`
1716
- puts player in the center of the screen
1717
- - **BREAK** renamed `kaboom.import()` to `kaboom.global()`
1718
- - added an arg field to `start(scene, ...)` to forward args to start scene
1719
- - added `camScale()`, `camRot()` and `camIgnore()`
1720
- - added `obj.overlaps()` by `area()`, and `overlaps()`
1721
- - added 3 ext fonts under `ext/fonts`
3
+ The changelog of this project can be found
4
+ (here)[https://github.com/kaplayjs/kaplay/blob/master/CHANGELOG.md]