create-dreamer-app 1.0.11 → 1.0.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Disco Dreamer reference
|
|
2
2
|
|
|
3
|
-
A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.
|
|
3
|
+
A practical guide to building browser games with `discodreamer`. Examples use the public API in version 1.0.9 and TypeScript with JSX.
|
|
4
4
|
|
|
5
5
|
## How a game runs
|
|
6
6
|
|
|
@@ -432,10 +432,12 @@ Creates an animation descriptor for `Sprite`. `animations` is an ordered array o
|
|
|
432
432
|
|
|
433
433
|
Config requires `src` and `size` (the square frame size in source pixels). Optional `fps` defaults to `24`; `loop` defaults to `true`. A frame group's `{ loop }` overrides that default. Switching the selected group restarts its timing.
|
|
434
434
|
|
|
435
|
+
Each frame group's optional third item also accepts `fps`, for example `{ fps: 12 }` or `{ fps: 12, loop: false }`. A group's `fps` overrides the config's `fps`; when omitted, the group inherits the config rate (or the default of `24`). Use a positive FPS for normal playback. The group's rate controls both frame progression and completion timing.
|
|
436
|
+
|
|
435
437
|
```tsx
|
|
436
438
|
function AnimatedPlayer({ moving }: { moving: boolean }) {
|
|
437
439
|
const animation = gameAnimation("player.animation", [
|
|
438
|
-
[moving, [4, 5, 6, 7]],
|
|
440
|
+
[moving, [4, 5, 6, 7], { fps: 12 }],
|
|
439
441
|
[true, [0, 1, 2, 3]],
|
|
440
442
|
], { src: "/player-sheet.png", size: 32, fps: 8 });
|
|
441
443
|
|
|
@@ -443,6 +445,8 @@ function AnimatedPlayer({ moving }: { moving: boolean }) {
|
|
|
443
445
|
}
|
|
444
446
|
```
|
|
445
447
|
|
|
448
|
+
The moving group plays at 12 FPS; the fallback group inherits 8 FPS from config. Switching groups restarts playback at the newly selected group's rate.
|
|
449
|
+
|
|
446
450
|
Use a final `true` condition as a fallback. A non-looping group holds its final frame. Call `animation.onAnimationFinish(handler)` each frame to handle its completion transition; it is not a persistent listener. Keep the source URL unchanged for an animation key, and use a positive frame size that fits the sheet.
|
|
447
451
|
|
|
448
452
|
### `gameImage(src)`
|