@combos-fun/plugin-renderer-sprite-animation 0.1.16 → 0.1.18
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 +4 -2
- package/dist/plugin-renderer-sprite-animation.cjs.js +95 -15
- package/dist/plugin-renderer-sprite-animation.cjs.js.map +1 -1
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js +1 -1
- package/dist/plugin-renderer-sprite-animation.d.ts +19 -4
- package/dist/plugin-renderer-sprite-animation.esm.js +96 -16
- package/dist/plugin-renderer-sprite-animation.esm.js.map +1 -1
- package/package.json +5 -5
package/agent-skill.md
CHANGED
|
@@ -11,12 +11,14 @@ import { SpriteAnimation, SpriteAnimationSystem } from '@combos-fun/plugin-rende
|
|
|
11
11
|
| Field | Default |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `resource` | required `SPRITE_ANIMATION` name |
|
|
14
|
+
| `animation` | `''` — clip name. Empty plays every frame in atlas order |
|
|
14
15
|
| `autoPlay` | `true` |
|
|
15
16
|
| `speed` | `100` ms/frame |
|
|
16
17
|
| `forwards` | `false` |
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Clip names come from a frame path prefix (`idle/frame0000` → `idle`) or a Pixi `animations` map. TexturePacker `textures[].frames` is accepted. `_animators.json` is not read. After load, `animationNames` lists the clips. Set `animation` or call `playAnimation('walk')` / `playAnimation('walk', 1)`. An unknown name logs the available clips and leaves the current clip in place; the first load falls back to every frame. `play()` / `play(Infinity)` loops the active clip. `play(n)` runs n loops. `play(0)` does nothing. Finite playback with `forwards: true` stops on the last frame. `play` and `stop` queue while the atlas loads. `gotoAndPlay` / `gotoAndStop` do not; wait for `totalFrames > 0`. Getters: `currentFrame`, `totalFrames`. Events `loop`, `frameChange`, `complete` carry no payload. `complete` does not fire during infinite playback. Size follows `Transform2D.size`. Observes `resource`, `animation`, and `speed`, not `autoPlay` or `forwards`.
|
|
19
20
|
|
|
20
21
|
```ts
|
|
21
|
-
hero.addComponent(new SpriteAnimation({ resource: 'hero
|
|
22
|
+
const heroAnim = hero.addComponent(new SpriteAnimation({ resource: 'hero', animation: 'idle', speed: 80 }));
|
|
23
|
+
heroAnim.playAnimation('walk');
|
|
22
24
|
```
|
|
@@ -11,6 +11,9 @@ let SpriteAnimation$1 = class SpriteAnimation extends engine.Component {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.resource = '';
|
|
14
|
+
this.animation = '';
|
|
15
|
+
/** Clip names from the loaded sheet. Empty until the resource loads. */
|
|
16
|
+
this.animationNames = [];
|
|
14
17
|
this.autoPlay = true;
|
|
15
18
|
this.speed = 100;
|
|
16
19
|
this.forwards = false;
|
|
@@ -36,6 +39,10 @@ let SpriteAnimation$1 = class SpriteAnimation extends engine.Component {
|
|
|
36
39
|
}
|
|
37
40
|
});
|
|
38
41
|
}
|
|
42
|
+
playAnimation(name, times = Infinity) {
|
|
43
|
+
this.animation = name;
|
|
44
|
+
this.play(times);
|
|
45
|
+
}
|
|
39
46
|
play(times = Infinity) {
|
|
40
47
|
if (times === 0) {
|
|
41
48
|
return;
|
|
@@ -97,6 +104,15 @@ tslib.__decorate([
|
|
|
97
104
|
editor: 'text',
|
|
98
105
|
})
|
|
99
106
|
], SpriteAnimation$1.prototype, "resource", void 0);
|
|
107
|
+
tslib.__decorate([
|
|
108
|
+
inspectorDecorator.Field({
|
|
109
|
+
type: 'string',
|
|
110
|
+
group: 'SpriteAnimation',
|
|
111
|
+
label: 'animation',
|
|
112
|
+
description: 'Clip name from the frame path prefix, such as idle. Empty plays every frame in atlas order.',
|
|
113
|
+
editor: 'text',
|
|
114
|
+
})
|
|
115
|
+
], SpriteAnimation$1.prototype, "animation", void 0);
|
|
100
116
|
tslib.__decorate([
|
|
101
117
|
inspectorDecorator.Field({
|
|
102
118
|
type: 'boolean',
|
|
@@ -157,20 +173,42 @@ engine.resource.registerInstance(engine.RESOURCE_TYPE.SPRITE_ANIMATION, async (r
|
|
|
157
173
|
for (const key in textures) {
|
|
158
174
|
spriteFrames.push(textures[key]);
|
|
159
175
|
}
|
|
160
|
-
|
|
176
|
+
const clipTextures = {};
|
|
177
|
+
const parsedAnimations = spriteSheet.animations || {};
|
|
178
|
+
for (const key in parsedAnimations) {
|
|
179
|
+
const clip = [];
|
|
180
|
+
for (const frameTexture of parsedAnimations[key]) {
|
|
181
|
+
if (frameTexture)
|
|
182
|
+
clip.push(frameTexture);
|
|
183
|
+
}
|
|
184
|
+
if (clip.length)
|
|
185
|
+
clipTextures[key] = clip;
|
|
186
|
+
}
|
|
187
|
+
return { frames: spriteFrames, animations: clipTextures };
|
|
161
188
|
});
|
|
162
189
|
engine.resource.registerDestroy(engine.RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {
|
|
163
|
-
|
|
190
|
+
const frames = Array.isArray(instance) ? instance : instance?.frames;
|
|
191
|
+
if (!Array.isArray(frames))
|
|
164
192
|
return;
|
|
165
|
-
for (const texture of
|
|
166
|
-
texture
|
|
193
|
+
for (const texture of frames) {
|
|
194
|
+
texture?.destroy?.(true);
|
|
167
195
|
}
|
|
168
196
|
});
|
|
197
|
+
function coerceSheet(instance) {
|
|
198
|
+
if (Array.isArray(instance))
|
|
199
|
+
return { frames: instance, animations: {} };
|
|
200
|
+
if (instance && typeof instance === 'object' && Array.isArray(instance.frames)) {
|
|
201
|
+
const sheet = instance;
|
|
202
|
+
return { frames: sheet.frames, animations: sheet.animations || {} };
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
169
206
|
let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
170
207
|
constructor() {
|
|
171
208
|
super(...arguments);
|
|
172
209
|
this.name = 'SpriteAnimation';
|
|
173
210
|
this.animates = {};
|
|
211
|
+
this.sheets = {};
|
|
174
212
|
this.autoPlay = {};
|
|
175
213
|
}
|
|
176
214
|
static { this.systemName = 'SpriteAnimation'; }
|
|
@@ -192,34 +230,40 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
|
192
230
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
193
231
|
if (changed.type === engine.OBSERVER_TYPE.ADD) {
|
|
194
232
|
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
195
|
-
const { instance
|
|
233
|
+
const { instance } = await engine.resource.getResource(component.resource);
|
|
196
234
|
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
197
235
|
return;
|
|
198
|
-
|
|
236
|
+
const sheet = coerceSheet(instance);
|
|
237
|
+
if (!sheet || sheet.frames.length === 0) {
|
|
199
238
|
console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
|
|
200
239
|
return;
|
|
201
240
|
}
|
|
202
241
|
this.add({
|
|
203
|
-
|
|
242
|
+
sheet,
|
|
204
243
|
id: changed.gameObject.id,
|
|
205
244
|
component,
|
|
206
245
|
});
|
|
207
246
|
}
|
|
208
247
|
else if (changed.type === engine.OBSERVER_TYPE.CHANGE) {
|
|
209
|
-
|
|
248
|
+
const prop = changed.prop && changed.prop.prop[0];
|
|
249
|
+
if (prop === 'speed') {
|
|
210
250
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
211
251
|
}
|
|
252
|
+
else if (prop === 'animation') {
|
|
253
|
+
this.applyClip(changed.gameObject.id, component);
|
|
254
|
+
}
|
|
212
255
|
else {
|
|
213
256
|
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
214
|
-
const { instance
|
|
257
|
+
const { instance } = await engine.resource.getResource(component.resource);
|
|
215
258
|
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
216
259
|
return;
|
|
217
|
-
|
|
260
|
+
const sheet = coerceSheet(instance);
|
|
261
|
+
if (!sheet || sheet.frames.length === 0) {
|
|
218
262
|
console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
|
|
219
263
|
return;
|
|
220
264
|
}
|
|
221
265
|
this.change({
|
|
222
|
-
|
|
266
|
+
sheet,
|
|
223
267
|
id: changed.gameObject.id,
|
|
224
268
|
component,
|
|
225
269
|
});
|
|
@@ -231,7 +275,14 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
|
231
275
|
}
|
|
232
276
|
}
|
|
233
277
|
}
|
|
234
|
-
add({
|
|
278
|
+
add({ sheet, id, component }) {
|
|
279
|
+
this.sheets[id] = sheet;
|
|
280
|
+
component.animationNames = Object.keys(sheet.animations);
|
|
281
|
+
const frames = this.framesFor(id, component, true);
|
|
282
|
+
if (!frames) {
|
|
283
|
+
console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation resource load error`);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
235
286
|
const animate = new rendererAdapter.SpriteAnimation({ frames });
|
|
236
287
|
this.animates[id] = animate;
|
|
237
288
|
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
@@ -250,12 +301,41 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
|
250
301
|
animate.animatedSprite.play();
|
|
251
302
|
}
|
|
252
303
|
}
|
|
253
|
-
change({
|
|
304
|
+
change({ sheet, id, component }) {
|
|
254
305
|
this.remove(id, true);
|
|
255
|
-
this.add({
|
|
306
|
+
this.add({ sheet, id, component });
|
|
307
|
+
}
|
|
308
|
+
applyClip(id, component) {
|
|
309
|
+
if (!this.sheets[id] || !this.animates[id])
|
|
310
|
+
return;
|
|
311
|
+
const frames = this.framesFor(id, component, false);
|
|
312
|
+
if (!frames)
|
|
313
|
+
return;
|
|
314
|
+
const sprite = this.animates[id].animatedSprite;
|
|
315
|
+
const playing = sprite.playing;
|
|
316
|
+
sprite.textures = frames;
|
|
317
|
+
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
318
|
+
if (playing)
|
|
319
|
+
sprite.play();
|
|
320
|
+
}
|
|
321
|
+
framesFor(id, component, fallback) {
|
|
322
|
+
const sheet = this.sheets[id];
|
|
323
|
+
if (!sheet)
|
|
324
|
+
return null;
|
|
325
|
+
const selected = engine.resolveSpriteClip(sheet.frames, sheet.animations, component.animation);
|
|
326
|
+
if (!selected.missing && selected.frames.length > 0)
|
|
327
|
+
return selected.frames;
|
|
328
|
+
if (selected.missing) {
|
|
329
|
+
const available = Object.keys(sheet.animations);
|
|
330
|
+
console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation has no clip "${selected.clip}". Available clips: ${available.length ? available.join(', ') : 'none'}.`);
|
|
331
|
+
}
|
|
332
|
+
if (fallback && sheet.frames.length > 0)
|
|
333
|
+
return sheet.frames;
|
|
334
|
+
return null;
|
|
256
335
|
}
|
|
257
336
|
remove(id, isChange) {
|
|
258
337
|
const animate = this.animates[id];
|
|
338
|
+
delete this.sheets[id];
|
|
259
339
|
if (!animate)
|
|
260
340
|
return;
|
|
261
341
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
@@ -269,7 +349,7 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
|
269
349
|
};
|
|
270
350
|
SpriteAnimation = tslib.__decorate([
|
|
271
351
|
engine.decorators.componentObserver({
|
|
272
|
-
SpriteAnimation: ['speed', 'resource'],
|
|
352
|
+
SpriteAnimation: ['speed', 'resource', 'animation'],
|
|
273
353
|
})
|
|
274
354
|
], SpriteAnimation);
|
|
275
355
|
var SpriteAnimation_default = SpriteAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-sprite-animation.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n autoPlay?: boolean;\n speed?: number;\n /** Stop at last frame */\n forwards?: boolean;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'resource',\n description: 'Sprite animation resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'autoPlay',\n description: 'Start playing automatically when the animation loads.',\n editor: 'toggle',\n })\n autoPlay: boolean = true;\n\n @Field({\n type: 'number',\n step: 10,\n group: 'SpriteAnimation',\n label: 'speed',\n description: 'Playback speed in milliseconds per frame.',\n editor: 'number-stepper',\n })\n speed: number = 100;\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'forwards',\n description: 'When the loop ends, stop on the last frame instead of resetting.',\n editor: 'toggle',\n })\n forwards: boolean = false;\n\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n private complete: boolean = false;\n\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n if (this.forwards) {\n this.gotoAndStop(this.totalFrames - 1);\n } else {\n this.animate.stop();\n }\n this.complete = true;\n this.emit('complete');\n }\n });\n }\n\n play(times = Infinity) {\n if (times === 0) {\n return;\n }\n this.times = times;\n if (!this.animate) {\n this.waitPlay = true;\n } else {\n if (this.complete) {\n this.gotoAndStop(0);\n }\n this.animate.play();\n this.count = 0;\n this.complete = false;\n }\n }\n\n stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\n }\n }\n\n set animate(val) {\n this._animate = val;\n if (this.waitPlay) {\n this.waitPlay = false;\n this.play(this.times);\n }\n if (this.waitStop) {\n this.waitStop = false;\n this.stop();\n }\n }\n\n get animate() {\n return this._animate;\n }\n\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame;\n }\n\n get totalFrames() {\n return this.animate?.animatedSprite?.totalFrames;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE, normalizeSpritesheetData } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT, Transform2D, createImageTexture } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async (res) => {\n const { name, data } = res;\n const texture = await createImageTexture(res);\n if (!texture) return;\n const textureObj = normalizeSpritesheetData(data.json);\n const frames = textureObj.frames || {};\n const animations = textureObj.animations || {};\n const newFrames = {};\n for (const key in frames) {\n const newKey = name + resourceKeySplit + key;\n newFrames[newKey] = frames[key];\n }\n for (const key in animations) {\n const spriteList = [];\n if (animations[key] && animations[key].length >= 0) {\n for (const spriteName of animations[key]) {\n const newSpriteName = name + resourceKeySplit + spriteName;\n spriteList.push(newSpriteName);\n }\n }\n animations[key] = spriteList;\n }\n textureObj.frames = newFrames;\n const spriteSheet = new Spritesheet(texture, textureObj);\n const textures = await spriteSheet.parse();\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n return spriteFrames;\n});\nresource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {\n if (!instance) return;\n for (const texture of instance) {\n texture.destroy(true);\n }\n});\n\n@decorators.componentObserver({\n SpriteAnimation: ['speed', 'resource'],\n})\nexport default class SpriteAnimation extends Renderer {\n static systemName = 'SpriteAnimation';\n name: string = 'SpriteAnimation';\n animates: { [propName: number]: SpriteAnimationEngine } = {};\n autoPlay: { [propName: number]: boolean } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n if (this.animates[gameObject.id]) {\n this.animates[gameObject.id].animatedSprite.width = width;\n this.animates[gameObject.id].animatedSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'SpriteAnimation') {\n const component: SpriteAnimationComponent = changed.component as SpriteAnimationComponent;\n this.autoPlay[changed.gameObject.id] = component.autoPlay;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance: frames } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!Array.isArray(frames) || frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.add({\n frames: frames,\n id: changed.gameObject.id,\n component,\n });\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n if (changed.prop && changed.prop.prop[0] === 'speed') {\n this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;\n } else {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance: frames } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!Array.isArray(frames) || frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.change({\n frames: frames,\n id: changed.gameObject.id,\n component,\n });\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n this.remove(changed.gameObject.id);\n }\n }\n }\n add({ frames, id, component }) {\n const animate = new SpriteAnimationEngine({ frames });\n this.animates[id] = animate;\n this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);\n\n animate.animatedSprite.onComplete = () => {\n component.emit('complete');\n };\n animate.animatedSprite.onFrameChange = () => {\n component.emit('frameChange');\n };\n animate.animatedSprite.onLoop = () => {\n component.emit('loop');\n };\n\n component.animate = this.animates[id];\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (this.autoPlay[id]) {\n animate.animatedSprite.play();\n }\n }\n change({ frames, id, component }) {\n this.remove(id, true);\n this.add({ frames, id, component });\n }\n remove(id, isChange?: boolean) {\n const animate = this.animates[id];\n if (!animate) return;\n this.autoPlay[id] = animate.animatedSprite.playing;\n this.containerManager.getContainer(id).removeChild(animate.animatedSprite);\n animate.animatedSprite.destroy({ children: true });\n delete this.animates[id];\n if (!isChange) {\n delete this.autoPlay[id];\n }\n }\n}\n"],"names":["Component","__decorate","Field","SpriteAnimation","RESOURCE_KEY_SPLIT","resource","RESOURCE_TYPE","createImageTexture","normalizeSpritesheetData","Spritesheet","Renderer","RendererSystem","Transform2D","OBSERVER_TYPE","SpriteAnimationEngine","decorators"],"mappings":";;;;;;;;;wBAYc,MAAO,eAAgB,SAAQA,gBAAgC,CAAA;AAA7E,IAAA,WAAA,GAAA;;QAUE,IAAA,CAAA,QAAQ,GAAW,EAAE;QASrB,IAAA,CAAA,QAAQ,GAAY,IAAI;QAUxB,IAAA,CAAA,KAAK,GAAW,GAAG;QASnB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGjB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,KAAK,GAAW,QAAQ;QACxB,IAAA,CAAA,KAAK,GAAW,CAAC;QACjB,IAAA,CAAA,QAAQ,GAAY,KAAK;IAyEnC;aArHS,IAAA,CAAA,aAAa,GAAW,iBAAX,CAA6B;AA8CjD,IAAA,IAAI,CAAC,GAA2B,EAAA;QAC9B,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;AAC/B,QAAA,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAK;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAA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CAAC,cAAc,CAAC,IAAI,EAAE;QAC/B;IACF;AACA,IAAA,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAA;AAC9B,QAAA,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IACrC;IACA,MAAM,CAAC,EAAE,EAAE,QAAkB,EAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AACjC,QAAA,IAAI,CAAC,OAAO;YAAE;QACd,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO;AAClD,QAAA,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC;QAC1E,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAClD,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B;IACF;;AA/FmB,eAAe,GAAAb,gBAAA,CAAA;IAHnCc,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CAgGnC;8BAhGoB,eAAe;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin-renderer-sprite-animation.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n /** Clip name from the frame path prefix, such as `idle`. Empty plays every frame. */\n animation?: string;\n autoPlay?: boolean;\n speed?: number;\n /** Stop at last frame */\n forwards?: boolean;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'resource',\n description: 'Sprite animation resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'animation',\n description: 'Clip name from the frame path prefix, such as idle. Empty plays every frame in atlas order.',\n editor: 'text',\n })\n animation: string = '';\n\n /** Clip names from the loaded sheet. Empty until the resource loads. */\n animationNames: string[] = [];\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'autoPlay',\n description: 'Start playing automatically when the animation loads.',\n editor: 'toggle',\n })\n autoPlay: boolean = true;\n\n @Field({\n type: 'number',\n step: 10,\n group: 'SpriteAnimation',\n label: 'speed',\n description: 'Playback speed in milliseconds per frame.',\n editor: 'number-stepper',\n })\n speed: number = 100;\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'forwards',\n description: 'When the loop ends, stop on the last frame instead of resetting.',\n editor: 'toggle',\n })\n forwards: boolean = false;\n\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n private complete: boolean = false;\n\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n if (this.forwards) {\n this.gotoAndStop(this.totalFrames - 1);\n } else {\n this.animate.stop();\n }\n this.complete = true;\n this.emit('complete');\n }\n });\n }\n\n playAnimation(name: string, times = Infinity) {\n this.animation = name;\n this.play(times);\n }\n\n play(times = Infinity) {\n if (times === 0) {\n return;\n }\n this.times = times;\n if (!this.animate) {\n this.waitPlay = true;\n } else {\n if (this.complete) {\n this.gotoAndStop(0);\n }\n this.animate.play();\n this.count = 0;\n this.complete = false;\n }\n }\n\n stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\n }\n }\n\n set animate(val) {\n this._animate = val;\n if (this.waitPlay) {\n this.waitPlay = false;\n this.play(this.times);\n }\n if (this.waitStop) {\n this.waitStop = false;\n this.stop();\n }\n }\n\n get animate() {\n return this._animate;\n }\n\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame;\n }\n\n get totalFrames() {\n return this.animate?.animatedSprite?.totalFrames;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE, normalizeSpritesheetData, resolveSpriteClip } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT, Transform2D, createImageTexture } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async (res) => {\n const { name, data } = res;\n const texture = await createImageTexture(res);\n if (!texture) return;\n const textureObj = normalizeSpritesheetData(data.json);\n const frames = textureObj.frames || {};\n const animations = textureObj.animations || {};\n const newFrames = {};\n for (const key in frames) {\n const newKey = name + resourceKeySplit + key;\n newFrames[newKey] = frames[key];\n }\n for (const key in animations) {\n const spriteList = [];\n if (animations[key] && animations[key].length >= 0) {\n for (const spriteName of animations[key]) {\n const newSpriteName = name + resourceKeySplit + spriteName;\n spriteList.push(newSpriteName);\n }\n }\n animations[key] = spriteList;\n }\n textureObj.frames = newFrames;\n const spriteSheet = new Spritesheet(texture, textureObj);\n const textures = await spriteSheet.parse();\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n const clipTextures = {};\n const parsedAnimations = spriteSheet.animations || {};\n for (const key in parsedAnimations) {\n const clip = [];\n for (const frameTexture of parsedAnimations[key]) {\n if (frameTexture) clip.push(frameTexture);\n }\n if (clip.length) clipTextures[key] = clip;\n }\n return { frames: spriteFrames, animations: clipTextures };\n});\nresource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {\n const frames = Array.isArray(instance) ? instance : instance?.frames;\n if (!Array.isArray(frames)) return;\n for (const texture of frames) {\n texture?.destroy?.(true);\n }\n});\n\ninterface SpriteAnimationSheet {\n frames: any[];\n animations: Record<string, any[]>;\n}\n\nfunction coerceSheet(instance: unknown): SpriteAnimationSheet | null {\n if (Array.isArray(instance)) return { frames: instance, animations: {} };\n if (instance && typeof instance === 'object' && Array.isArray((instance as SpriteAnimationSheet).frames)) {\n const sheet = instance as SpriteAnimationSheet;\n return { frames: sheet.frames, animations: sheet.animations || {} };\n }\n return null;\n}\n\n@decorators.componentObserver({\n SpriteAnimation: ['speed', 'resource', 'animation'],\n})\nexport default class SpriteAnimation extends Renderer {\n static systemName = 'SpriteAnimation';\n name: string = 'SpriteAnimation';\n animates: { [propName: number]: SpriteAnimationEngine } = {};\n sheets: { [propName: number]: SpriteAnimationSheet } = {};\n autoPlay: { [propName: number]: boolean } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n if (this.animates[gameObject.id]) {\n this.animates[gameObject.id].animatedSprite.width = width;\n this.animates[gameObject.id].animatedSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'SpriteAnimation') {\n const component: SpriteAnimationComponent = changed.component as SpriteAnimationComponent;\n this.autoPlay[changed.gameObject.id] = component.autoPlay;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n const sheet = coerceSheet(instance);\n if (!sheet || sheet.frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.add({\n sheet,\n id: changed.gameObject.id,\n component,\n });\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n const prop = changed.prop && changed.prop.prop[0];\n if (prop === 'speed') {\n this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;\n } else if (prop === 'animation') {\n this.applyClip(changed.gameObject.id, component);\n } else {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n const sheet = coerceSheet(instance);\n if (!sheet || sheet.frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.change({\n sheet,\n id: changed.gameObject.id,\n component,\n });\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n this.remove(changed.gameObject.id);\n }\n }\n }\n add({ sheet, id, component }) {\n this.sheets[id] = sheet;\n component.animationNames = Object.keys(sheet.animations);\n const frames = this.framesFor(id, component, true);\n if (!frames) {\n console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation resource load error`);\n return;\n }\n const animate = new SpriteAnimationEngine({ frames });\n this.animates[id] = animate;\n this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);\n\n animate.animatedSprite.onComplete = () => {\n component.emit('complete');\n };\n animate.animatedSprite.onFrameChange = () => {\n component.emit('frameChange');\n };\n animate.animatedSprite.onLoop = () => {\n component.emit('loop');\n };\n\n component.animate = this.animates[id];\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (this.autoPlay[id]) {\n animate.animatedSprite.play();\n }\n }\n change({ sheet, id, component }) {\n this.remove(id, true);\n this.add({ sheet, id, component });\n }\n applyClip(id, component: SpriteAnimationComponent) {\n if (!this.sheets[id] || !this.animates[id]) return;\n const frames = this.framesFor(id, component, false);\n if (!frames) return;\n const sprite = this.animates[id].animatedSprite;\n const playing = sprite.playing;\n sprite.textures = frames;\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (playing) sprite.play();\n }\n framesFor(id, component: SpriteAnimationComponent, fallback: boolean) {\n const sheet = this.sheets[id];\n if (!sheet) return null;\n const selected = resolveSpriteClip(sheet.frames, sheet.animations, component.animation);\n if (!selected.missing && selected.frames.length > 0) return selected.frames;\n if (selected.missing) {\n const available = Object.keys(sheet.animations);\n console.error(\n `GameObject:${component.gameObject?.name}'s SpriteAnimation has no clip \"${selected.clip}\". Available clips: ${available.length ? available.join(', ') : 'none'}.`,\n );\n }\n if (fallback && sheet.frames.length > 0) return sheet.frames;\n return null;\n }\n remove(id, isChange?: boolean) {\n const animate = this.animates[id];\n delete this.sheets[id];\n if (!animate) return;\n this.autoPlay[id] = animate.animatedSprite.playing;\n this.containerManager.getContainer(id).removeChild(animate.animatedSprite);\n animate.animatedSprite.destroy({ children: true });\n delete this.animates[id];\n if (!isChange) {\n delete this.autoPlay[id];\n }\n }\n}\n"],"names":["Component","__decorate","Field","SpriteAnimation","RESOURCE_KEY_SPLIT","resource","RESOURCE_TYPE","createImageTexture","normalizeSpritesheetData","Spritesheet","Renderer","RendererSystem","Transform2D","OBSERVER_TYPE","SpriteAnimationEngine","resolveSpriteClip","decorators"],"mappings":";;;;;;;;;wBAcc,MAAO,eAAgB,SAAQA,gBAAgC,CAAA;AAA7E,IAAA,WAAA,GAAA;;QAUE,IAAA,CAAA,QAAQ,GAAW,EAAE;QASrB,IAAA,CAAA,SAAS,GAAW,EAAE;;QAGtB,IAAA,CAAA,cAAc,GAAa,EAAE;QAS7B,IAAA,CAAA,QAAQ,G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IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B;IACF;;AArImB,eAAe,GAAAd,gBAAA,CAAA;IAHnCe,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC;KACpD;AACoB,CAAA,EAAA,eAAe,CAsInC;8BAtIoB,eAAe;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),i=require("@combos-fun/inspector-decorator"),a=require("@combos-fun/plugin-renderer"),
|
|
1
|
+
"use strict";var e=require("tslib"),t=require("@combos-fun/engine"),i=require("@combos-fun/inspector-decorator"),a=require("@combos-fun/plugin-renderer"),s=require("@combos-fun/renderer-adapter"),n=require("pixi.js");let r=class extends t.Component{constructor(){super(...arguments),this.resource="",this.animation="",this.animationNames=[],this.autoPlay=!0,this.speed=100,this.forwards=!1,this.waitPlay=!1,this.waitStop=!1,this.times=1/0,this.count=0,this.complete=!1}static{this.componentName="SpriteAnimation"}init(e){e&&Object.assign(this,e),this.on("loop",()=>{++this.count>=this.times&&(this.forwards?this.gotoAndStop(this.totalFrames-1):this.animate.stop(),this.complete=!0,this.emit("complete"))})}playAnimation(e,t=1/0){this.animation=e,this.play(t)}play(e=1/0){0!==e&&(this.times=e,this.animate?(this.complete&&this.gotoAndStop(0),this.animate.play(),this.count=0,this.complete=!1):this.waitPlay=!0)}stop(){this.animate?this.animate.stop():this.waitStop=!0}set animate(e){this._animate=e,this.waitPlay&&(this.waitPlay=!1,this.play(this.times)),this.waitStop&&(this.waitStop=!1,this.stop())}get animate(){return this._animate}gotoAndPlay(e){this.animate.gotoAndPlay(e)}gotoAndStop(e){this.animate.gotoAndStop(e)}get currentFrame(){return this.animate?.animatedSprite?.currentFrame}get totalFrames(){return this.animate?.animatedSprite?.totalFrames}};e.__decorate([i.Field({type:"string",group:"SpriteAnimation",label:"resource",description:"Sprite animation resource id.",editor:"text"})],r.prototype,"resource",void 0),e.__decorate([i.Field({type:"string",group:"SpriteAnimation",label:"animation",description:"Clip name from the frame path prefix, such as idle. Empty plays every frame in atlas order.",editor:"text"})],r.prototype,"animation",void 0),e.__decorate([i.Field({type:"boolean",group:"SpriteAnimation",label:"autoPlay",description:"Start playing automatically when the animation loads.",editor:"toggle"})],r.prototype,"autoPlay",void 0),e.__decorate([i.Field({type:"number",step:10,group:"SpriteAnimation",label:"speed",description:"Playback speed in milliseconds per frame.",editor:"number-stepper"})],r.prototype,"speed",void 0),e.__decorate([i.Field({type:"boolean",group:"SpriteAnimation",label:"forwards",description:"When the loop ends, stop on the last frame instead of resetting.",editor:"toggle"})],r.prototype,"forwards",void 0);const o=a.RESOURCE_KEY_SPLIT;function m(e){if(Array.isArray(e))return{frames:e,animations:{}};if(e&&"object"==typeof e&&Array.isArray(e.frames)){const t=e;return{frames:t.frames,animations:t.animations||{}}}return null}t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,async e=>{const{name:i,data:s}=e,r=await a.createImageTexture(e);if(!r)return;const m=t.normalizeSpritesheetData(s.json),p=m.frames||{},c=m.animations||{},h={};for(const e in p){h[i+o+e]=p[e]}for(const e in c){const t=[];if(c[e]&&c[e].length>=0)for(const a of c[e]){const e=i+o+a;t.push(e)}c[e]=t}m.frames=h;const d=new n.Spritesheet(r,m),l=await d.parse(),u=[];for(const e in l)u.push(l[e]);const y={},g=d.animations||{};for(const e in g){const t=[];for(const i of g[e])i&&t.push(i);t.length&&(y[e]=t)}return{frames:u,animations:y}}),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,({instance:e})=>{const t=Array.isArray(e)?e:e?.frames;if(Array.isArray(t))for(const e of t)e?.destroy?.(!0)});let p=class extends a.Renderer{constructor(){super(...arguments),this.name="SpriteAnimation",this.animates={},this.sheets={},this.autoPlay={}}static{this.systemName="SpriteAnimation"}init(){this.renderSystem=this.game.getSystem(a.RendererSystem),this.renderSystem.rendererManager.register(this)}rendererUpdate(e){const{width:t,height:i}=e.getComponent(a.Transform2D)?.size??{width:0,height:0};this.animates[e.id]&&(this.animates[e.id].animatedSprite.width=t,this.animates[e.id].animatedSprite.height=i)}async componentChanged(e){const i=e.gameObject.id;if("SpriteAnimation"===e.componentName){const a=e.component;if(this.autoPlay[e.gameObject.id]=a.autoPlay,e.type===t.OBSERVER_TYPE.ADD){const s=this.increaseAsyncId(i),{instance:n}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;const r=m(n);if(!r||0===r.frames.length)return void console.error(`GameObject:${e.gameObject.name}'s SpriteAnimation resource load error`);this.add({sheet:r,id:e.gameObject.id,component:a})}else if(e.type===t.OBSERVER_TYPE.CHANGE){const s=e.prop&&e.prop.prop[0];if("speed"===s)this.animates[e.gameObject.id].speed=1e3/60/a.speed;else if("animation"===s)this.applyClip(e.gameObject.id,a);else{const s=this.increaseAsyncId(i),{instance:n}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;const r=m(n);if(!r||0===r.frames.length)return void console.error(`GameObject:${e.gameObject.name}'s SpriteAnimation resource load error`);this.change({sheet:r,id:e.gameObject.id,component:a})}}else e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(i),this.remove(e.gameObject.id))}}add({sheet:e,id:t,component:i}){this.sheets[t]=e,i.animationNames=Object.keys(e.animations);const a=this.framesFor(t,i,!0);if(!a)return void console.error(`GameObject:${i.gameObject?.name}'s SpriteAnimation resource load error`);const n=new s.SpriteAnimation({frames:a});this.animates[t]=n,this.containerManager.getContainer(t).addChildAt(n.animatedSprite,0),n.animatedSprite.onComplete=()=>{i.emit("complete")},n.animatedSprite.onFrameChange=()=>{i.emit("frameChange")},n.animatedSprite.onLoop=()=>{i.emit("loop")},i.animate=this.animates[t],this.animates[t].speed=1e3/60/i.speed,this.autoPlay[t]&&n.animatedSprite.play()}change({sheet:e,id:t,component:i}){this.remove(t,!0),this.add({sheet:e,id:t,component:i})}applyClip(e,t){if(!this.sheets[e]||!this.animates[e])return;const i=this.framesFor(e,t,!1);if(!i)return;const a=this.animates[e].animatedSprite,s=a.playing;a.textures=i,this.animates[e].speed=1e3/60/t.speed,s&&a.play()}framesFor(e,i,a){const s=this.sheets[e];if(!s)return null;const n=t.resolveSpriteClip(s.frames,s.animations,i.animation);if(!n.missing&&n.frames.length>0)return n.frames;if(n.missing){const e=Object.keys(s.animations);console.error(`GameObject:${i.gameObject?.name}'s SpriteAnimation has no clip "${n.clip}". Available clips: ${e.length?e.join(", "):"none"}.`)}return a&&s.frames.length>0?s.frames:null}remove(e,t){const i=this.animates[e];delete this.sheets[e],i&&(this.autoPlay[e]=i.animatedSprite.playing,this.containerManager.getContainer(e).removeChild(i.animatedSprite),i.animatedSprite.destroy({children:!0}),delete this.animates[e],t||delete this.autoPlay[e])}};p=e.__decorate([t.decorators.componentObserver({SpriteAnimation:["speed","resource","animation"]})],p);var c=p;exports.SpriteAnimation=r,exports.SpriteAnimationSystem=c;
|
|
@@ -4,6 +4,8 @@ import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@co
|
|
|
4
4
|
|
|
5
5
|
interface SpriteAnimationParams {
|
|
6
6
|
resource: string;
|
|
7
|
+
/** Clip name from the frame path prefix, such as `idle`. Empty plays every frame. */
|
|
8
|
+
animation?: string;
|
|
7
9
|
autoPlay?: boolean;
|
|
8
10
|
speed?: number;
|
|
9
11
|
/** Stop at last frame */
|
|
@@ -12,6 +14,9 @@ interface SpriteAnimationParams {
|
|
|
12
14
|
declare class SpriteAnimation$1 extends Component<SpriteAnimationParams> {
|
|
13
15
|
static componentName: string;
|
|
14
16
|
resource: string;
|
|
17
|
+
animation: string;
|
|
18
|
+
/** Clip names from the loaded sheet. Empty until the resource loads. */
|
|
19
|
+
animationNames: string[];
|
|
15
20
|
autoPlay: boolean;
|
|
16
21
|
speed: number;
|
|
17
22
|
forwards: boolean;
|
|
@@ -22,6 +27,7 @@ declare class SpriteAnimation$1 extends Component<SpriteAnimationParams> {
|
|
|
22
27
|
private count;
|
|
23
28
|
private complete;
|
|
24
29
|
init(obj?: SpriteAnimationParams): void;
|
|
30
|
+
playAnimation(name: string, times?: number): void;
|
|
25
31
|
play(times?: number): void;
|
|
26
32
|
stop(): void;
|
|
27
33
|
set animate(val: SpriteAnimation$2);
|
|
@@ -32,12 +38,19 @@ declare class SpriteAnimation$1 extends Component<SpriteAnimationParams> {
|
|
|
32
38
|
get totalFrames(): number;
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
interface SpriteAnimationSheet {
|
|
42
|
+
frames: any[];
|
|
43
|
+
animations: Record<string, any[]>;
|
|
44
|
+
}
|
|
35
45
|
declare class SpriteAnimation extends Renderer {
|
|
36
46
|
static systemName: string;
|
|
37
47
|
name: string;
|
|
38
48
|
animates: {
|
|
39
49
|
[propName: number]: SpriteAnimation$2;
|
|
40
50
|
};
|
|
51
|
+
sheets: {
|
|
52
|
+
[propName: number]: SpriteAnimationSheet;
|
|
53
|
+
};
|
|
41
54
|
autoPlay: {
|
|
42
55
|
[propName: number]: boolean;
|
|
43
56
|
};
|
|
@@ -47,16 +60,18 @@ declare class SpriteAnimation extends Renderer {
|
|
|
47
60
|
init(): void;
|
|
48
61
|
rendererUpdate(gameObject: GameObject): void;
|
|
49
62
|
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
50
|
-
add({
|
|
51
|
-
|
|
63
|
+
add({ sheet, id, component }: {
|
|
64
|
+
sheet: any;
|
|
52
65
|
id: any;
|
|
53
66
|
component: any;
|
|
54
67
|
}): void;
|
|
55
|
-
change({
|
|
56
|
-
|
|
68
|
+
change({ sheet, id, component }: {
|
|
69
|
+
sheet: any;
|
|
57
70
|
id: any;
|
|
58
71
|
component: any;
|
|
59
72
|
}): void;
|
|
73
|
+
applyClip(id: any, component: SpriteAnimation$1): void;
|
|
74
|
+
framesFor(id: any, component: SpriteAnimation$1, fallback: boolean): any[];
|
|
60
75
|
remove(id: any, isChange?: boolean): void;
|
|
61
76
|
}
|
|
62
77
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __decorate } from 'tslib';
|
|
2
|
-
import { Component, resource, RESOURCE_TYPE, normalizeSpritesheetData, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
|
|
2
|
+
import { Component, resource, RESOURCE_TYPE, normalizeSpritesheetData, OBSERVER_TYPE, resolveSpriteClip, decorators } from '@combos-fun/engine';
|
|
3
3
|
import { Field } from '@combos-fun/inspector-decorator';
|
|
4
4
|
import { createImageTexture, Renderer, RendererSystem, Transform2D, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';
|
|
5
5
|
import { SpriteAnimation as SpriteAnimation$2 } from '@combos-fun/renderer-adapter';
|
|
@@ -9,6 +9,9 @@ let SpriteAnimation$1 = class SpriteAnimation extends Component {
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
11
|
this.resource = '';
|
|
12
|
+
this.animation = '';
|
|
13
|
+
/** Clip names from the loaded sheet. Empty until the resource loads. */
|
|
14
|
+
this.animationNames = [];
|
|
12
15
|
this.autoPlay = true;
|
|
13
16
|
this.speed = 100;
|
|
14
17
|
this.forwards = false;
|
|
@@ -34,6 +37,10 @@ let SpriteAnimation$1 = class SpriteAnimation extends Component {
|
|
|
34
37
|
}
|
|
35
38
|
});
|
|
36
39
|
}
|
|
40
|
+
playAnimation(name, times = Infinity) {
|
|
41
|
+
this.animation = name;
|
|
42
|
+
this.play(times);
|
|
43
|
+
}
|
|
37
44
|
play(times = Infinity) {
|
|
38
45
|
if (times === 0) {
|
|
39
46
|
return;
|
|
@@ -95,6 +102,15 @@ __decorate([
|
|
|
95
102
|
editor: 'text',
|
|
96
103
|
})
|
|
97
104
|
], SpriteAnimation$1.prototype, "resource", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
Field({
|
|
107
|
+
type: 'string',
|
|
108
|
+
group: 'SpriteAnimation',
|
|
109
|
+
label: 'animation',
|
|
110
|
+
description: 'Clip name from the frame path prefix, such as idle. Empty plays every frame in atlas order.',
|
|
111
|
+
editor: 'text',
|
|
112
|
+
})
|
|
113
|
+
], SpriteAnimation$1.prototype, "animation", void 0);
|
|
98
114
|
__decorate([
|
|
99
115
|
Field({
|
|
100
116
|
type: 'boolean',
|
|
@@ -155,20 +171,42 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async (res) => {
|
|
|
155
171
|
for (const key in textures) {
|
|
156
172
|
spriteFrames.push(textures[key]);
|
|
157
173
|
}
|
|
158
|
-
|
|
174
|
+
const clipTextures = {};
|
|
175
|
+
const parsedAnimations = spriteSheet.animations || {};
|
|
176
|
+
for (const key in parsedAnimations) {
|
|
177
|
+
const clip = [];
|
|
178
|
+
for (const frameTexture of parsedAnimations[key]) {
|
|
179
|
+
if (frameTexture)
|
|
180
|
+
clip.push(frameTexture);
|
|
181
|
+
}
|
|
182
|
+
if (clip.length)
|
|
183
|
+
clipTextures[key] = clip;
|
|
184
|
+
}
|
|
185
|
+
return { frames: spriteFrames, animations: clipTextures };
|
|
159
186
|
});
|
|
160
187
|
resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {
|
|
161
|
-
|
|
188
|
+
const frames = Array.isArray(instance) ? instance : instance?.frames;
|
|
189
|
+
if (!Array.isArray(frames))
|
|
162
190
|
return;
|
|
163
|
-
for (const texture of
|
|
164
|
-
texture
|
|
191
|
+
for (const texture of frames) {
|
|
192
|
+
texture?.destroy?.(true);
|
|
165
193
|
}
|
|
166
194
|
});
|
|
195
|
+
function coerceSheet(instance) {
|
|
196
|
+
if (Array.isArray(instance))
|
|
197
|
+
return { frames: instance, animations: {} };
|
|
198
|
+
if (instance && typeof instance === 'object' && Array.isArray(instance.frames)) {
|
|
199
|
+
const sheet = instance;
|
|
200
|
+
return { frames: sheet.frames, animations: sheet.animations || {} };
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
167
204
|
let SpriteAnimation = class SpriteAnimation extends Renderer {
|
|
168
205
|
constructor() {
|
|
169
206
|
super(...arguments);
|
|
170
207
|
this.name = 'SpriteAnimation';
|
|
171
208
|
this.animates = {};
|
|
209
|
+
this.sheets = {};
|
|
172
210
|
this.autoPlay = {};
|
|
173
211
|
}
|
|
174
212
|
static { this.systemName = 'SpriteAnimation'; }
|
|
@@ -190,34 +228,40 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
|
|
|
190
228
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
191
229
|
if (changed.type === OBSERVER_TYPE.ADD) {
|
|
192
230
|
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
193
|
-
const { instance
|
|
231
|
+
const { instance } = await resource.getResource(component.resource);
|
|
194
232
|
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
195
233
|
return;
|
|
196
|
-
|
|
234
|
+
const sheet = coerceSheet(instance);
|
|
235
|
+
if (!sheet || sheet.frames.length === 0) {
|
|
197
236
|
console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
|
|
198
237
|
return;
|
|
199
238
|
}
|
|
200
239
|
this.add({
|
|
201
|
-
|
|
240
|
+
sheet,
|
|
202
241
|
id: changed.gameObject.id,
|
|
203
242
|
component,
|
|
204
243
|
});
|
|
205
244
|
}
|
|
206
245
|
else if (changed.type === OBSERVER_TYPE.CHANGE) {
|
|
207
|
-
|
|
246
|
+
const prop = changed.prop && changed.prop.prop[0];
|
|
247
|
+
if (prop === 'speed') {
|
|
208
248
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
209
249
|
}
|
|
250
|
+
else if (prop === 'animation') {
|
|
251
|
+
this.applyClip(changed.gameObject.id, component);
|
|
252
|
+
}
|
|
210
253
|
else {
|
|
211
254
|
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
212
|
-
const { instance
|
|
255
|
+
const { instance } = await resource.getResource(component.resource);
|
|
213
256
|
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
214
257
|
return;
|
|
215
|
-
|
|
258
|
+
const sheet = coerceSheet(instance);
|
|
259
|
+
if (!sheet || sheet.frames.length === 0) {
|
|
216
260
|
console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
|
|
217
261
|
return;
|
|
218
262
|
}
|
|
219
263
|
this.change({
|
|
220
|
-
|
|
264
|
+
sheet,
|
|
221
265
|
id: changed.gameObject.id,
|
|
222
266
|
component,
|
|
223
267
|
});
|
|
@@ -229,7 +273,14 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
|
|
|
229
273
|
}
|
|
230
274
|
}
|
|
231
275
|
}
|
|
232
|
-
add({
|
|
276
|
+
add({ sheet, id, component }) {
|
|
277
|
+
this.sheets[id] = sheet;
|
|
278
|
+
component.animationNames = Object.keys(sheet.animations);
|
|
279
|
+
const frames = this.framesFor(id, component, true);
|
|
280
|
+
if (!frames) {
|
|
281
|
+
console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation resource load error`);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
233
284
|
const animate = new SpriteAnimation$2({ frames });
|
|
234
285
|
this.animates[id] = animate;
|
|
235
286
|
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
@@ -248,12 +299,41 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
|
|
|
248
299
|
animate.animatedSprite.play();
|
|
249
300
|
}
|
|
250
301
|
}
|
|
251
|
-
change({
|
|
302
|
+
change({ sheet, id, component }) {
|
|
252
303
|
this.remove(id, true);
|
|
253
|
-
this.add({
|
|
304
|
+
this.add({ sheet, id, component });
|
|
305
|
+
}
|
|
306
|
+
applyClip(id, component) {
|
|
307
|
+
if (!this.sheets[id] || !this.animates[id])
|
|
308
|
+
return;
|
|
309
|
+
const frames = this.framesFor(id, component, false);
|
|
310
|
+
if (!frames)
|
|
311
|
+
return;
|
|
312
|
+
const sprite = this.animates[id].animatedSprite;
|
|
313
|
+
const playing = sprite.playing;
|
|
314
|
+
sprite.textures = frames;
|
|
315
|
+
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
316
|
+
if (playing)
|
|
317
|
+
sprite.play();
|
|
318
|
+
}
|
|
319
|
+
framesFor(id, component, fallback) {
|
|
320
|
+
const sheet = this.sheets[id];
|
|
321
|
+
if (!sheet)
|
|
322
|
+
return null;
|
|
323
|
+
const selected = resolveSpriteClip(sheet.frames, sheet.animations, component.animation);
|
|
324
|
+
if (!selected.missing && selected.frames.length > 0)
|
|
325
|
+
return selected.frames;
|
|
326
|
+
if (selected.missing) {
|
|
327
|
+
const available = Object.keys(sheet.animations);
|
|
328
|
+
console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation has no clip "${selected.clip}". Available clips: ${available.length ? available.join(', ') : 'none'}.`);
|
|
329
|
+
}
|
|
330
|
+
if (fallback && sheet.frames.length > 0)
|
|
331
|
+
return sheet.frames;
|
|
332
|
+
return null;
|
|
254
333
|
}
|
|
255
334
|
remove(id, isChange) {
|
|
256
335
|
const animate = this.animates[id];
|
|
336
|
+
delete this.sheets[id];
|
|
257
337
|
if (!animate)
|
|
258
338
|
return;
|
|
259
339
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
@@ -267,7 +347,7 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
|
|
|
267
347
|
};
|
|
268
348
|
SpriteAnimation = __decorate([
|
|
269
349
|
decorators.componentObserver({
|
|
270
|
-
SpriteAnimation: ['speed', 'resource'],
|
|
350
|
+
SpriteAnimation: ['speed', 'resource', 'animation'],
|
|
271
351
|
})
|
|
272
352
|
], SpriteAnimation);
|
|
273
353
|
var SpriteAnimation_default = SpriteAnimation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-renderer-sprite-animation.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n autoPlay?: boolean;\n speed?: number;\n /** Stop at last frame */\n forwards?: boolean;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'resource',\n description: 'Sprite animation resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'autoPlay',\n description: 'Start playing automatically when the animation loads.',\n editor: 'toggle',\n })\n autoPlay: boolean = true;\n\n @Field({\n type: 'number',\n step: 10,\n group: 'SpriteAnimation',\n label: 'speed',\n description: 'Playback speed in milliseconds per frame.',\n editor: 'number-stepper',\n })\n speed: number = 100;\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'forwards',\n description: 'When the loop ends, stop on the last frame instead of resetting.',\n editor: 'toggle',\n })\n forwards: boolean = false;\n\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n private complete: boolean = false;\n\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n if (this.forwards) {\n this.gotoAndStop(this.totalFrames - 1);\n } else {\n this.animate.stop();\n }\n this.complete = true;\n this.emit('complete');\n }\n });\n }\n\n play(times = Infinity) {\n if (times === 0) {\n return;\n }\n this.times = times;\n if (!this.animate) {\n this.waitPlay = true;\n } else {\n if (this.complete) {\n this.gotoAndStop(0);\n }\n this.animate.play();\n this.count = 0;\n this.complete = false;\n }\n }\n\n stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\n }\n }\n\n set animate(val) {\n this._animate = val;\n if (this.waitPlay) {\n this.waitPlay = false;\n this.play(this.times);\n }\n if (this.waitStop) {\n this.waitStop = false;\n this.stop();\n }\n }\n\n get animate() {\n return this._animate;\n }\n\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame;\n }\n\n get totalFrames() {\n return this.animate?.animatedSprite?.totalFrames;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE, normalizeSpritesheetData } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT, Transform2D, createImageTexture } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async (res) => {\n const { name, data } = res;\n const texture = await createImageTexture(res);\n if (!texture) return;\n const textureObj = normalizeSpritesheetData(data.json);\n const frames = textureObj.frames || {};\n const animations = textureObj.animations || {};\n const newFrames = {};\n for (const key in frames) {\n const newKey = name + resourceKeySplit + key;\n newFrames[newKey] = frames[key];\n }\n for (const key in animations) {\n const spriteList = [];\n if (animations[key] && animations[key].length >= 0) {\n for (const spriteName of animations[key]) {\n const newSpriteName = name + resourceKeySplit + spriteName;\n spriteList.push(newSpriteName);\n }\n }\n animations[key] = spriteList;\n }\n textureObj.frames = newFrames;\n const spriteSheet = new Spritesheet(texture, textureObj);\n const textures = await spriteSheet.parse();\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n return spriteFrames;\n});\nresource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {\n if (!instance) return;\n for (const texture of instance) {\n texture.destroy(true);\n }\n});\n\n@decorators.componentObserver({\n SpriteAnimation: ['speed', 'resource'],\n})\nexport default class SpriteAnimation extends Renderer {\n static systemName = 'SpriteAnimation';\n name: string = 'SpriteAnimation';\n animates: { [propName: number]: SpriteAnimationEngine } = {};\n autoPlay: { [propName: number]: boolean } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n if (this.animates[gameObject.id]) {\n this.animates[gameObject.id].animatedSprite.width = width;\n this.animates[gameObject.id].animatedSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'SpriteAnimation') {\n const component: SpriteAnimationComponent = changed.component as SpriteAnimationComponent;\n this.autoPlay[changed.gameObject.id] = component.autoPlay;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance: frames } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!Array.isArray(frames) || frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.add({\n frames: frames,\n id: changed.gameObject.id,\n component,\n });\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n if (changed.prop && changed.prop.prop[0] === 'speed') {\n this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;\n } else {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance: frames } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n if (!Array.isArray(frames) || frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.change({\n frames: frames,\n id: changed.gameObject.id,\n component,\n });\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n this.remove(changed.gameObject.id);\n }\n }\n }\n add({ frames, id, component }) {\n const animate = new SpriteAnimationEngine({ frames });\n this.animates[id] = animate;\n this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);\n\n animate.animatedSprite.onComplete = () => {\n component.emit('complete');\n };\n animate.animatedSprite.onFrameChange = () => {\n component.emit('frameChange');\n };\n animate.animatedSprite.onLoop = () => {\n component.emit('loop');\n };\n\n component.animate = this.animates[id];\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (this.autoPlay[id]) {\n animate.animatedSprite.play();\n }\n }\n change({ frames, id, component }) {\n this.remove(id, true);\n this.add({ frames, id, component });\n }\n remove(id, isChange?: boolean) {\n const animate = this.animates[id];\n if (!animate) return;\n this.autoPlay[id] = animate.animatedSprite.playing;\n this.containerManager.getContainer(id).removeChild(animate.animatedSprite);\n animate.animatedSprite.destroy({ children: true });\n delete this.animates[id];\n if (!isChange) {\n delete this.autoPlay[id];\n }\n }\n}\n"],"names":["SpriteAnimation","SpriteAnimationEngine"],"mappings":";;;;;;;wBAYc,MAAO,eAAgB,SAAQ,SAAgC,CAAA;AAA7E,IAAA,WAAA,GAAA;;QAUE,IAAA,CAAA,QAAQ,GAAW,EAAE;QASrB,IAAA,CAAA,QAAQ,GAAY,IAAI;QAUxB,IAAA,CAAA,KAAK,GAAW,GAAG;QASnB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGjB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,KAAK,GAAW,QAAQ;QACxB,IAAA,CAAA,KAAK,GAAW,CAAC;QACjB,IAAA,CAAA,QAAQ,GAAY,KAAK;IAyEnC;aArHS,IAAA,CAAA,aAAa,GAAW,iBAAX,CAA6B;AA8CjD,IAAA,IAAI,CAAC,GAA2B,EAAA;QAC9B,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;AAC/B,QAAA,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAK;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK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AAA,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAA;AAC9B,QAAA,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IACrC;IACA,MAAM,CAAC,EAAE,EAAE,QAAkB,EAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AACjC,QAAA,IAAI,CAAC,OAAO;YAAE;QACd,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO;AAClD,QAAA,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC;QAC1E,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAClD,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B;IACF;;AA/FmB,eAAe,GAAA,UAAA,CAAA;IAHnC,UAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CAgGnC;8BAhGoB,eAAe;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin-renderer-sprite-animation.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component } from '@combos-fun/engine';\nimport { Field } from '@combos-fun/inspector-decorator';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n /** Clip name from the frame path prefix, such as `idle`. Empty plays every frame. */\n animation?: string;\n autoPlay?: boolean;\n speed?: number;\n /** Stop at last frame */\n forwards?: boolean;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'resource',\n description: 'Sprite animation resource id.',\n editor: 'text',\n })\n resource: string = '';\n\n @Field({\n type: 'string',\n group: 'SpriteAnimation',\n label: 'animation',\n description: 'Clip name from the frame path prefix, such as idle. Empty plays every frame in atlas order.',\n editor: 'text',\n })\n animation: string = '';\n\n /** Clip names from the loaded sheet. Empty until the resource loads. */\n animationNames: string[] = [];\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'autoPlay',\n description: 'Start playing automatically when the animation loads.',\n editor: 'toggle',\n })\n autoPlay: boolean = true;\n\n @Field({\n type: 'number',\n step: 10,\n group: 'SpriteAnimation',\n label: 'speed',\n description: 'Playback speed in milliseconds per frame.',\n editor: 'number-stepper',\n })\n speed: number = 100;\n\n @Field({\n type: 'boolean',\n group: 'SpriteAnimation',\n label: 'forwards',\n description: 'When the loop ends, stop on the last frame instead of resetting.',\n editor: 'toggle',\n })\n forwards: boolean = false;\n\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n private complete: boolean = false;\n\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n if (this.forwards) {\n this.gotoAndStop(this.totalFrames - 1);\n } else {\n this.animate.stop();\n }\n this.complete = true;\n this.emit('complete');\n }\n });\n }\n\n playAnimation(name: string, times = Infinity) {\n this.animation = name;\n this.play(times);\n }\n\n play(times = Infinity) {\n if (times === 0) {\n return;\n }\n this.times = times;\n if (!this.animate) {\n this.waitPlay = true;\n } else {\n if (this.complete) {\n this.gotoAndStop(0);\n }\n this.animate.play();\n this.count = 0;\n this.complete = false;\n }\n }\n\n stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\n }\n }\n\n set animate(val) {\n this._animate = val;\n if (this.waitPlay) {\n this.waitPlay = false;\n this.play(this.times);\n }\n if (this.waitStop) {\n this.waitStop = false;\n this.stop();\n }\n }\n\n get animate() {\n return this._animate;\n }\n\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame;\n }\n\n get totalFrames() {\n return this.animate?.animatedSprite?.totalFrames;\n }\n}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE, normalizeSpritesheetData, resolveSpriteClip } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT, Transform2D, createImageTexture } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async (res) => {\n const { name, data } = res;\n const texture = await createImageTexture(res);\n if (!texture) return;\n const textureObj = normalizeSpritesheetData(data.json);\n const frames = textureObj.frames || {};\n const animations = textureObj.animations || {};\n const newFrames = {};\n for (const key in frames) {\n const newKey = name + resourceKeySplit + key;\n newFrames[newKey] = frames[key];\n }\n for (const key in animations) {\n const spriteList = [];\n if (animations[key] && animations[key].length >= 0) {\n for (const spriteName of animations[key]) {\n const newSpriteName = name + resourceKeySplit + spriteName;\n spriteList.push(newSpriteName);\n }\n }\n animations[key] = spriteList;\n }\n textureObj.frames = newFrames;\n const spriteSheet = new Spritesheet(texture, textureObj);\n const textures = await spriteSheet.parse();\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n const clipTextures = {};\n const parsedAnimations = spriteSheet.animations || {};\n for (const key in parsedAnimations) {\n const clip = [];\n for (const frameTexture of parsedAnimations[key]) {\n if (frameTexture) clip.push(frameTexture);\n }\n if (clip.length) clipTextures[key] = clip;\n }\n return { frames: spriteFrames, animations: clipTextures };\n});\nresource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {\n const frames = Array.isArray(instance) ? instance : instance?.frames;\n if (!Array.isArray(frames)) return;\n for (const texture of frames) {\n texture?.destroy?.(true);\n }\n});\n\ninterface SpriteAnimationSheet {\n frames: any[];\n animations: Record<string, any[]>;\n}\n\nfunction coerceSheet(instance: unknown): SpriteAnimationSheet | null {\n if (Array.isArray(instance)) return { frames: instance, animations: {} };\n if (instance && typeof instance === 'object' && Array.isArray((instance as SpriteAnimationSheet).frames)) {\n const sheet = instance as SpriteAnimationSheet;\n return { frames: sheet.frames, animations: sheet.animations || {} };\n }\n return null;\n}\n\n@decorators.componentObserver({\n SpriteAnimation: ['speed', 'resource', 'animation'],\n})\nexport default class SpriteAnimation extends Renderer {\n static systemName = 'SpriteAnimation';\n name: string = 'SpriteAnimation';\n animates: { [propName: number]: SpriteAnimationEngine } = {};\n sheets: { [propName: number]: SpriteAnimationSheet } = {};\n autoPlay: { [propName: number]: boolean } = {};\n renderSystem: RendererSystem;\n rendererManager: RendererManager;\n containerManager: ContainerManager;\n init() {\n this.renderSystem = this.game.getSystem(RendererSystem) as RendererSystem;\n this.renderSystem.rendererManager.register(this);\n }\n rendererUpdate(gameObject: GameObject) {\n const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };\n if (this.animates[gameObject.id]) {\n this.animates[gameObject.id].animatedSprite.width = width;\n this.animates[gameObject.id].animatedSprite.height = height;\n }\n }\n async componentChanged(changed: ComponentChanged) {\n const gameObjectId = changed.gameObject.id;\n if (changed.componentName === 'SpriteAnimation') {\n const component: SpriteAnimationComponent = changed.component as SpriteAnimationComponent;\n this.autoPlay[changed.gameObject.id] = component.autoPlay;\n if (changed.type === OBSERVER_TYPE.ADD) {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n const sheet = coerceSheet(instance);\n if (!sheet || sheet.frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.add({\n sheet,\n id: changed.gameObject.id,\n component,\n });\n } else if (changed.type === OBSERVER_TYPE.CHANGE) {\n const prop = changed.prop && changed.prop.prop[0];\n if (prop === 'speed') {\n this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;\n } else if (prop === 'animation') {\n this.applyClip(changed.gameObject.id, component);\n } else {\n const asyncId = this.increaseAsyncId(gameObjectId);\n const { instance } = await resource.getResource(component.resource);\n if (!this.validateAsyncId(gameObjectId, asyncId)) return;\n const sheet = coerceSheet(instance);\n if (!sheet || sheet.frames.length === 0) {\n console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);\n return;\n }\n this.change({\n sheet,\n id: changed.gameObject.id,\n component,\n });\n }\n } else if (changed.type === OBSERVER_TYPE.REMOVE) {\n this.increaseAsyncId(gameObjectId);\n this.remove(changed.gameObject.id);\n }\n }\n }\n add({ sheet, id, component }) {\n this.sheets[id] = sheet;\n component.animationNames = Object.keys(sheet.animations);\n const frames = this.framesFor(id, component, true);\n if (!frames) {\n console.error(`GameObject:${component.gameObject?.name}'s SpriteAnimation resource load error`);\n return;\n }\n const animate = new SpriteAnimationEngine({ frames });\n this.animates[id] = animate;\n this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);\n\n animate.animatedSprite.onComplete = () => {\n component.emit('complete');\n };\n animate.animatedSprite.onFrameChange = () => {\n component.emit('frameChange');\n };\n animate.animatedSprite.onLoop = () => {\n component.emit('loop');\n };\n\n component.animate = this.animates[id];\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (this.autoPlay[id]) {\n animate.animatedSprite.play();\n }\n }\n change({ sheet, id, component }) {\n this.remove(id, true);\n this.add({ sheet, id, component });\n }\n applyClip(id, component: SpriteAnimationComponent) {\n if (!this.sheets[id] || !this.animates[id]) return;\n const frames = this.framesFor(id, component, false);\n if (!frames) return;\n const sprite = this.animates[id].animatedSprite;\n const playing = sprite.playing;\n sprite.textures = frames;\n this.animates[id].speed = 1000 / 60 / component.speed;\n if (playing) sprite.play();\n }\n framesFor(id, component: SpriteAnimationComponent, fallback: boolean) {\n const sheet = this.sheets[id];\n if (!sheet) return null;\n const selected = resolveSpriteClip(sheet.frames, sheet.animations, component.animation);\n if (!selected.missing && selected.frames.length > 0) return selected.frames;\n if (selected.missing) {\n const available = Object.keys(sheet.animations);\n console.error(\n `GameObject:${component.gameObject?.name}'s SpriteAnimation has no clip \"${selected.clip}\". Available clips: ${available.length ? available.join(', ') : 'none'}.`,\n );\n }\n if (fallback && sheet.frames.length > 0) return sheet.frames;\n return null;\n }\n remove(id, isChange?: boolean) {\n const animate = this.animates[id];\n delete this.sheets[id];\n if (!animate) return;\n this.autoPlay[id] = animate.animatedSprite.playing;\n this.containerManager.getContainer(id).removeChild(animate.animatedSprite);\n animate.animatedSprite.destroy({ children: true });\n delete this.animates[id];\n if (!isChange) {\n delete this.autoPlay[id];\n }\n }\n}\n"],"names":["SpriteAnimation","SpriteAnimationEngine"],"mappings":";;;;;;;wBAcc,MAAO,eAAgB,SAAQ,SAAgC,CAAA;AAA7E,IAAA,WAAA,GAAA;;QAUE,IAAA,CAAA,QAAQ,GAAW,EAAE;QASrB,IAAA,CAAA,SAAS,GAAW,EAAE;;QAGtB,IAAA,CAAA,cAAc,GAAa,EAAE;QAS7B,IAAA,CAAA,QAAQ,GAAY,IAAI;QAUxB,IAAA,CAAA,KAAK,GAAW,GAAG;QASnB,IAAA,CAAA,QAAQ,GAAY,KAAK;QAGjB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,QAAQ,GAAY,KAAK;QACzB,IAAA,CAAA,KAAK,GAAW,QAA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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combos-fun/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
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/plugin-renderer": "0.1.
|
|
41
|
-
"@combos-fun/
|
|
42
|
-
"@combos-fun/renderer-adapter": "0.1.
|
|
43
|
-
"@combos-fun/
|
|
40
|
+
"@combos-fun/plugin-renderer": "0.1.18",
|
|
41
|
+
"@combos-fun/engine": "0.1.18",
|
|
42
|
+
"@combos-fun/renderer-adapter": "0.1.18",
|
|
43
|
+
"@combos-fun/inspector-decorator": "0.1.18"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "node ../../scripts/build-package.mjs"
|