@combos-fun/plugin-renderer-sprite-animation 0.0.44 → 0.0.46
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/agent-skill.md +23 -56
- package/package.json +5 -5
package/agent-skill.md
CHANGED
|
@@ -1,71 +1,38 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-sprite-animation` — Agent notes
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## When to read
|
|
6
|
-
|
|
7
|
-
Read for any frame-by-frame animation: character idle / run / attack loops, FX, particle bursts.
|
|
8
|
-
|
|
9
|
-
## Public API
|
|
3
|
+
Read only for flipbook playback of atlas frames. Use `Sprite` when exactly one atlas frame should be shown.
|
|
10
4
|
|
|
11
5
|
```ts
|
|
12
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
SpriteAnimation,
|
|
8
|
+
SpriteAnimationSystem,
|
|
9
|
+
type SpriteAnimationParams,
|
|
10
|
+
} from '@combos-fun/plugin-renderer-sprite-animation';
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
`componentName = 'SpriteAnimation'
|
|
16
|
-
|
|
17
|
-
### `SpriteAnimationParams`
|
|
13
|
+
`SpriteAnimation.componentName = 'SpriteAnimation'`; `SpriteAnimationSystem.systemName = 'SpriteAnimation'`.
|
|
18
14
|
|
|
19
|
-
| Field | Type | Default |
|
|
20
|
-
|
|
21
|
-
| `resource` | `string` |
|
|
22
|
-
| `autoPlay` | `boolean?` | `
|
|
23
|
-
| `speed` | `number?` | `100`
|
|
24
|
-
| `forwards` | `boolean?` | `
|
|
15
|
+
| Field | Type | Default |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `resource` | `string` | required SPRITE_ANIMATION name |
|
|
18
|
+
| `autoPlay` | `boolean?` | `true` |
|
|
19
|
+
| `speed` | `number?` | `100` ms/frame |
|
|
20
|
+
| `forwards` | `boolean?` | `false` |
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
Importing the package registers SPRITE_ANIMATION atlas parsing. The implementation parses **all** entries in JSON `frames` and plays the resulting frame-key order. It rewrites JSON `animations` keys but does not expose a clip selector and does not choose an animation by clip name. Use separate resources if distinct clips need independent playback.
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
Methods are `play(times?)`, `stop()`, `gotoAndPlay(frame)`, and `gotoAndStop(frame)`; getters are `currentFrame` and `totalFrames`. `play()`/`play(Infinity)` loops, `play(N > 0)` completes after N loops, and `play(0)` is a no-op. With finite playback, `forwards: true` stops on the last frame; otherwise it resets.
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
`play()` and `stop()` safely queue while the atlas loads. **`gotoAndPlay()` and `gotoAndStop()` do not queue and dereference the animation immediately, so calling them before async atlas readiness is unsafe.** Wait until the component has an animation/positive `totalFrames`.
|
|
31
27
|
|
|
32
|
-
`
|
|
28
|
+
Events are `'loop'`, `'frameChange'`, and `'complete'` (no payload is forwarded). `'complete'` from the Component's finite-loop logic does not occur during infinite playback.
|
|
33
29
|
|
|
34
30
|
```ts
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
src: {
|
|
41
|
-
image: { type: 'png', url: 'https://cdn.example/hero-run.png' },
|
|
42
|
-
json: { type: 'json', url: 'https://cdn.example/hero-run.json' },
|
|
43
|
-
},
|
|
44
|
-
preload: true,
|
|
45
|
-
}]);
|
|
31
|
+
hero.addComponent(new SpriteAnimation({
|
|
32
|
+
resource: 'hero-run',
|
|
33
|
+
autoPlay: true,
|
|
34
|
+
speed: 80,
|
|
35
|
+
}));
|
|
46
36
|
```
|
|
47
37
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Common pitfalls
|
|
51
|
-
|
|
52
|
-
| Symptom | Fix |
|
|
53
|
-
|---------|-----|
|
|
54
|
-
| Animation doesn't start | `autoPlay: false` is the default — call `play()` from a Component lifecycle hook, or set `autoPlay: true` |
|
|
55
|
-
| Imperative `play()` from bootstrap | ECS violation — wire the call from a Component's `start()` |
|
|
56
|
-
| `src.<slot>.url is required` | That slot has no url |
|
|
57
|
-
| `SpriteAnimation resource load error` | Files loaded but no frames after parse |
|
|
58
|
-
| Stuck on first frame | Frames may be a single image; check JSON has multiple **named** `frames` entries |
|
|
59
|
-
| Animation never completes | `play(0)` (or omitted `times`) loops forever; pass a positive integer for finite plays |
|
|
60
|
-
| `'complete'` doesn't fire | Only fires when `play(N)` finishes N iterations; not when looping forever |
|
|
61
|
-
|
|
62
|
-
## Minimal example
|
|
63
|
-
|
|
64
|
-
```ts
|
|
65
|
-
const hero = new GameObject('hero', { position: { x: 200, y: 400 }, size: { width: 108, height: 108 }, origin: { x: 0.5, y: 0.5 } });
|
|
66
|
-
hero.addComponent(new SpriteAnimation({ resource: 'hero-run', autoPlay: true, speed: 80 }));
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Verification
|
|
70
|
-
|
|
71
|
-
`pnpm --filter @combos-fun/plugin-renderer-sprite-animation run build`.
|
|
38
|
+
Display width and height follow `Transform.size`, not frame pixels. Resource or speed changes are observed; `autoPlay` and `forwards` are not observer fields.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Frame-based sprite animation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite-animation.esm.js",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "sun668 <q947692259@gmail.com>",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"pixi.js": "^8.18.1",
|
|
40
|
-
"@combos-fun/
|
|
41
|
-
"@combos-fun/
|
|
42
|
-
"@combos-fun/inspector-decorator": "0.0.
|
|
43
|
-
"@combos-fun/
|
|
40
|
+
"@combos-fun/engine": "0.0.46",
|
|
41
|
+
"@combos-fun/renderer-adapter": "0.0.46",
|
|
42
|
+
"@combos-fun/inspector-decorator": "0.0.46",
|
|
43
|
+
"@combos-fun/plugin-renderer": "0.0.46"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node ../../scripts/build-package.mjs"
|