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