@combos-fun/plugin-renderer-sprite 0.0.45 → 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 +13 -45
- package/package.json +5 -5
package/agent-skill.md
CHANGED
|
@@ -1,63 +1,31 @@
|
|
|
1
1
|
# `@combos-fun/plugin-renderer-sprite` — Agent notes
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## When to read
|
|
6
|
-
|
|
7
|
-
Read when you have a packed sprite atlas and need to draw a single named frame (UI icons grouped in a sheet, character portraits, item icons).
|
|
8
|
-
|
|
9
|
-
## Public API
|
|
3
|
+
Read only for one named frame from a packed atlas. Use `Img` for a standalone image and `SpriteAnimation` to play atlas frames.
|
|
10
4
|
|
|
11
5
|
```ts
|
|
12
6
|
import { Sprite, SpriteSystem, type SpriteParams } from '@combos-fun/plugin-renderer-sprite';
|
|
13
7
|
```
|
|
14
8
|
|
|
15
|
-
`componentName = 'Sprite'
|
|
16
|
-
|
|
17
|
-
### `SpriteParams`
|
|
18
|
-
|
|
19
|
-
| Field | Type | Notes |
|
|
20
|
-
|-------|------|-------|
|
|
21
|
-
| `resource` | `string` | Engine resource name registered with `RESOURCE_TYPE.SPRITE`. Source must include both `image` and `json`. |
|
|
22
|
-
| `spriteName` | `string` | Frame name from the atlas JSON |
|
|
23
|
-
|
|
24
|
-
Side effect: importing this package registers `SPRITE` resource handlers on the engine `resource` singleton.
|
|
25
|
-
|
|
26
|
-
Internal cache key: `resource + '_s|r|c_' + spriteName`.
|
|
27
|
-
|
|
28
|
-
## Required setup
|
|
29
|
-
|
|
30
|
-
`RendererSystem` then `SpriteSystem`. Resource must be registered with both `image` and `json` URLs:
|
|
9
|
+
`Sprite.componentName = 'Sprite'`; `SpriteSystem.systemName = 'Sprite'`.
|
|
31
10
|
|
|
32
11
|
```ts
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: RESOURCE_TYPE.SPRITE,
|
|
38
|
-
src: {
|
|
39
|
-
image: { type: 'png', url: 'https://cdn.example/icons.png' },
|
|
40
|
-
json: { type: 'json', url: 'https://cdn.example/icons.json' },
|
|
41
|
-
},
|
|
42
|
-
preload: true,
|
|
43
|
-
}]);
|
|
12
|
+
interface SpriteParams {
|
|
13
|
+
resource: string; // RESOURCE_TYPE.SPRITE name
|
|
14
|
+
spriteName: string; // exact atlas frames key
|
|
15
|
+
}
|
|
44
16
|
```
|
|
45
17
|
|
|
46
|
-
|
|
18
|
+
Importing the package registers the SPRITE instance and destroy handlers. The resource must supply atlas image and JSON data. Frame keys are prefixed as:
|
|
47
19
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| Wrong frame | `spriteName` must exactly match a key in the atlas JSON |
|
|
52
|
-
| Tearing / wrong size | Atlas frame may have padding; trim padding in the export tool |
|
|
20
|
+
```ts
|
|
21
|
+
resource + RESOURCE_KEY_SPLIT + spriteName
|
|
22
|
+
```
|
|
53
23
|
|
|
54
|
-
|
|
24
|
+
Pixi `Spritesheet.parse()` also registers these keys in the Texture cache, so
|
|
25
|
+
`Texture.from(cacheKey)` consumers such as NinePatch can resolve them.
|
|
55
26
|
|
|
56
27
|
```ts
|
|
57
|
-
const icon = new GameObject('coin-icon', { position: { x: 50, y: 50 }, size: { width: 64, height: 64 } });
|
|
58
28
|
icon.addComponent(new Sprite({ resource: 'icons', spriteName: 'coin' }));
|
|
59
29
|
```
|
|
60
30
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
`pnpm --filter @combos-fun/plugin-renderer-sprite run build`.
|
|
31
|
+
Display dimensions follow `Transform.size`, not the source frame. The system observes `spriteName`, not `resource`; treat `resource` as construction-time configuration rather than expecting assignment to it alone to redraw.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-sprite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"description": "Sprite atlas rendering",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite.esm.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"author": "sun668 <q947692259@gmail.com>",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"pixi.js": "^8.18.1",
|
|
39
|
-
"@combos-fun/renderer-adapter": "0.0.
|
|
40
|
-
"@combos-fun/plugin-renderer": "0.0.
|
|
41
|
-
"@combos-fun/
|
|
42
|
-
"@combos-fun/
|
|
39
|
+
"@combos-fun/renderer-adapter": "0.0.46",
|
|
40
|
+
"@combos-fun/plugin-renderer": "0.0.46",
|
|
41
|
+
"@combos-fun/inspector-decorator": "0.0.46",
|
|
42
|
+
"@combos-fun/engine": "0.0.46"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "node ../../scripts/build-package.mjs"
|