@combos-fun/plugin-renderer-sprite-animation 0.0.38 → 0.0.39

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 CHANGED
@@ -12,7 +12,7 @@ Read for any frame-by-frame animation: character idle / run / attack loops, FX,
12
12
  import { SpriteAnimation, SpriteAnimationSystem, type SpriteAnimationParams } from '@combos-fun/plugin-renderer-sprite-animation';
13
13
  ```
14
14
 
15
- `componentName = 'SpriteAnimation'`, `systemName = 'SpriteAnimationSystem'`.
15
+ `componentName = 'SpriteAnimation'`, `systemName = 'SpriteAnimation'` (class is `SpriteAnimationSystem` — use `game.getSystem(SpriteAnimationSystem)`, not the string).
16
16
 
17
17
  ### `SpriteAnimationParams`
18
18
 
@@ -32,28 +32,37 @@ Side effect: importing this package registers `SPRITE_ANIMATION` resource handle
32
32
  `RendererSystem` then `SpriteAnimationSystem`. Resource:
33
33
 
34
34
  ```ts
35
+ import { RESOURCE_TYPE, resource } from '@combos-fun/engine';
36
+
35
37
  resource.addResource([{
36
38
  name: 'hero-run',
37
- src: { image: 'hero-run.png', json: 'hero-run.json' },
39
+ type: RESOURCE_TYPE.SPRITE_ANIMATION,
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
+ },
38
44
  preload: true,
39
45
  }]);
40
46
  ```
41
47
 
48
+ JSON should be a Pixi spritesheet hash (`frames` name map + `meta.scale`).
49
+
42
50
  ## Common pitfalls
43
51
 
44
52
  | Symptom | Fix |
45
53
  |---------|-----|
46
54
  | Animation doesn't start | `autoPlay: false` is the default — call `play()` from a Component lifecycle hook, or set `autoPlay: true` |
47
55
  | Imperative `play()` from bootstrap | ECS violation — wire the call from a Component's `start()` |
48
- | Stuck on first frame | Frames may be a single image; check JSON has multiple frame entries |
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 |
49
59
  | Animation never completes | `play(0)` (or omitted `times`) loops forever; pass a positive integer for finite plays |
50
60
  | `'complete'` doesn't fire | Only fires when `play(N)` finishes N iterations; not when looping forever |
51
61
 
52
62
  ## Minimal example
53
63
 
54
64
  ```ts
55
- const hero = new GameObject('hero');
56
- hero.addComponent(new Transform({ position: { x: 200, y: 400 } }));
65
+ const hero = new GameObject('hero', { position: { x: 200, y: 400 }, size: { width: 108, height: 108 }, origin: { x: 0.5, y: 0.5 } });
57
66
  hero.addComponent(new SpriteAnimation({ resource: 'hero-run', autoPlay: true, speed: 80 }));
58
67
  ```
59
68
 
@@ -128,7 +128,7 @@ tslib.__decorate([
128
128
 
129
129
  const resourceKeySplit = pluginRenderer.RESOURCE_KEY_SPLIT;
130
130
  engine.resource.registerInstance(engine.RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {
131
- const textureObj = data.json;
131
+ const textureObj = engine.normalizeSpritesheetData(data.json);
132
132
  const texture = pixi_js.Texture.from(data.image);
133
133
  const frames = textureObj.frames || {};
134
134
  const animations = textureObj.animations || {};
@@ -192,8 +192,9 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
192
192
  const { instance: frames } = await engine.resource.getResource(component.resource);
193
193
  if (!this.validateAsyncId(gameObjectId, asyncId))
194
194
  return;
195
- if (!frames) {
196
- console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
195
+ if (!Array.isArray(frames) || frames.length === 0) {
196
+ console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
197
+ return;
197
198
  }
198
199
  this.add({
199
200
  frames: frames,
@@ -210,8 +211,9 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
210
211
  const { instance: frames } = await engine.resource.getResource(component.resource);
211
212
  if (!this.validateAsyncId(gameObjectId, asyncId))
212
213
  return;
213
- if (!frames) {
214
- console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
214
+ if (!Array.isArray(frames) || frames.length === 0) {
215
+ console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
216
+ return;
215
217
  }
216
218
  this.change({
217
219
  frames: frames,
@@ -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 } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet, Texture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {\n const textureObj = data.json;\n const texture = Texture.from(data.image);\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.transform.size;\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 (!frames) {\n console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);\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 (!frames) {\n console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);\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","Texture","Spritesheet","Renderer","RendererSystem","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,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ACrB,YAAA,OAAO,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;;AA7FmB,eAAe,GAAAX,gBAAA,CAAA;IAHnCY,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CA8FnC;8BA9FoB,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 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 } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet, Texture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {\n const textureObj = normalizeSpritesheetData(data.json);\n const texture = Texture.from(data.image);\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.transform.size;\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","normalizeSpritesheetData","Texture","Spritesheet","Renderer","RendererSystem","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,M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AAM,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,GAAAZ,gBAAA,CAAA;IAHnCa,iBAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CAgGnC;8BAhGoB,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"),s=require("@combos-fun/renderer-adapter"),o=require("pixi.js");let r=class extends t.Component{constructor(){super(...arguments),this.resource="",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"))})}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:"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 n=a.RESOURCE_KEY_SPLIT;t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,async({name:e,data:t})=>{const i=t.json,a=o.Texture.from(t.image),s=i.frames||{},r=i.animations||{},m={};for(const t in s){m[e+n+t]=s[t]}for(const t in r){const i=[];if(r[t]&&r[t].length>=0)for(const a of r[t]){const t=e+n+a;i.push(t)}r[t]=i}i.frames=m;const p=new o.Spritesheet(a,i),d=await p.parse(),c=[];for(const e in d)c.push(d[e]);return c}),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,({instance:e})=>{if(e)for(const t of e)t.destroy(!0)});let m=class extends a.Renderer{constructor(){super(...arguments),this.name="SpriteAnimation",this.animates={},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.transform.size;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:o}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;o||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.add({frames:o,id:e.gameObject.id,component:a})}else if(e.type===t.OBSERVER_TYPE.CHANGE)if(e.prop&&"speed"===e.prop.prop[0])this.animates[e.gameObject.id].speed=1e3/60/a.speed;else{const s=this.increaseAsyncId(i),{instance:o}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;o||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.change({frames:o,id:e.gameObject.id,component:a})}else e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(i),this.remove(e.gameObject.id))}}add({frames:e,id:t,component:i}){const a=new s.SpriteAnimation({frames:e});this.animates[t]=a,this.containerManager.getContainer(t).addChildAt(a.animatedSprite,0),a.animatedSprite.onComplete=()=>{i.emit("complete")},a.animatedSprite.onFrameChange=()=>{i.emit("frameChange")},a.animatedSprite.onLoop=()=>{i.emit("loop")},i.animate=this.animates[t],this.animates[t].speed=1e3/60/i.speed,this.autoPlay[t]&&a.animatedSprite.play()}change({frames:e,id:t,component:i}){this.remove(t,!0),this.add({frames:e,id:t,component:i})}remove(e,t){const i=this.animates[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])}};m=e.__decorate([t.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],m);var p=m;exports.SpriteAnimation=r,exports.SpriteAnimationSystem=p;
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"),r=require("pixi.js");let o=class extends t.Component{constructor(){super(...arguments),this.resource="",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"))})}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"})],o.prototype,"resource",void 0),e.__decorate([i.Field({type:"boolean",group:"SpriteAnimation",label:"autoPlay",description:"Start playing automatically when the animation loads.",editor:"toggle"})],o.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"})],o.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"})],o.prototype,"forwards",void 0);const n=a.RESOURCE_KEY_SPLIT;t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,async({name:e,data:i})=>{const a=t.normalizeSpritesheetData(i.json),s=r.Texture.from(i.image),o=a.frames||{},m=a.animations||{},p={};for(const t in o){p[e+n+t]=o[t]}for(const t in m){const i=[];if(m[t]&&m[t].length>=0)for(const a of m[t]){const t=e+n+a;i.push(t)}m[t]=i}a.frames=p;const d=new r.Spritesheet(s,a),c=await d.parse(),h=[];for(const e in c)h.push(c[e]);return h}),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,({instance:e})=>{if(e)for(const t of e)t.destroy(!0)});let m=class extends a.Renderer{constructor(){super(...arguments),this.name="SpriteAnimation",this.animates={},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.transform.size;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:r}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;if(!Array.isArray(r)||0===r.length)return void console.error(`GameObject:${e.gameObject.name}'s SpriteAnimation resource load error`);this.add({frames:r,id:e.gameObject.id,component:a})}else if(e.type===t.OBSERVER_TYPE.CHANGE)if(e.prop&&"speed"===e.prop.prop[0])this.animates[e.gameObject.id].speed=1e3/60/a.speed;else{const s=this.increaseAsyncId(i),{instance:r}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;if(!Array.isArray(r)||0===r.length)return void console.error(`GameObject:${e.gameObject.name}'s SpriteAnimation resource load error`);this.change({frames:r,id:e.gameObject.id,component:a})}else e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(i),this.remove(e.gameObject.id))}}add({frames:e,id:t,component:i}){const a=new s.SpriteAnimation({frames:e});this.animates[t]=a,this.containerManager.getContainer(t).addChildAt(a.animatedSprite,0),a.animatedSprite.onComplete=()=>{i.emit("complete")},a.animatedSprite.onFrameChange=()=>{i.emit("frameChange")},a.animatedSprite.onLoop=()=>{i.emit("loop")},i.animate=this.animates[t],this.animates[t].speed=1e3/60/i.speed,this.autoPlay[t]&&a.animatedSprite.play()}change({frames:e,id:t,component:i}){this.remove(t,!0),this.add({frames:e,id:t,component:i})}remove(e,t){const i=this.animates[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])}};m=e.__decorate([t.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],m);var p=m;exports.SpriteAnimation=o,exports.SpriteAnimationSystem=p;
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from 'tslib';
2
- import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
2
+ import { Component, resource, RESOURCE_TYPE, normalizeSpritesheetData, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
3
3
  import { Field } from '@combos-fun/inspector-decorator';
4
4
  import { Renderer, RendererSystem, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';
5
5
  import { SpriteAnimation as SpriteAnimation$2 } from '@combos-fun/renderer-adapter';
@@ -126,7 +126,7 @@ __decorate([
126
126
 
127
127
  const resourceKeySplit = RESOURCE_KEY_SPLIT;
128
128
  resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {
129
- const textureObj = data.json;
129
+ const textureObj = normalizeSpritesheetData(data.json);
130
130
  const texture = Texture.from(data.image);
131
131
  const frames = textureObj.frames || {};
132
132
  const animations = textureObj.animations || {};
@@ -190,8 +190,9 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
190
190
  const { instance: frames } = await resource.getResource(component.resource);
191
191
  if (!this.validateAsyncId(gameObjectId, asyncId))
192
192
  return;
193
- if (!frames) {
194
- console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
193
+ if (!Array.isArray(frames) || frames.length === 0) {
194
+ console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
195
+ return;
195
196
  }
196
197
  this.add({
197
198
  frames: frames,
@@ -208,8 +209,9 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
208
209
  const { instance: frames } = await resource.getResource(component.resource);
209
210
  if (!this.validateAsyncId(gameObjectId, asyncId))
210
211
  return;
211
- if (!frames) {
212
- console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
212
+ if (!Array.isArray(frames) || frames.length === 0) {
213
+ console.error(`GameObject:${changed.gameObject.name}'s SpriteAnimation resource load error`);
214
+ return;
213
215
  }
214
216
  this.change({
215
217
  frames: frames,
@@ -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 } from '@combos-fun/engine';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet, Texture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {\n const textureObj = data.json;\n const texture = Texture.from(data.image);\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.transform.size;\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 (!frames) {\n console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);\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 (!frames) {\n console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);\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":";;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OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CA8FnC;8BA9FoB,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 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 } from '@combos-fun/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@combos-fun/renderer-adapter';\nimport { Spritesheet, Texture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = RESOURCE_KEY_SPLIT;\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {\n const textureObj = normalizeSpritesheetData(data.json);\n const texture = Texture.from(data.image);\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.transform.size;\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,C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IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;AACrB,YAAA,OAAO,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,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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer-sprite-animation",
3
- "version": "0.0.38",
3
+ "version": "0.0.39",
4
4
  "description": "Frame-based sprite animation",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-sprite-animation.esm.js",
@@ -36,11 +36,11 @@
36
36
  ],
37
37
  "author": "sun668 <q947692259@gmail.com>",
38
38
  "dependencies": {
39
- "@combos-fun/plugin-renderer": "0.0.38",
40
- "@combos-fun/renderer-adapter": "0.0.38",
41
- "@combos-fun/engine": "0.0.38",
39
+ "@combos-fun/plugin-renderer": "0.0.39",
40
+ "@combos-fun/renderer-adapter": "0.0.39",
41
+ "@combos-fun/engine": "0.0.39",
42
42
  "pixi.js": "^8.18.1",
43
- "@combos-fun/inspector-decorator": "0.0.38"
43
+ "@combos-fun/inspector-decorator": "0.0.39"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "node ../../scripts/build-package.mjs"