@combos-fun/plugin-renderer-sprite-animation 0.0.54 → 0.1.0

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
@@ -35,4 +35,4 @@ hero.addComponent(new SpriteAnimation({
35
35
  }));
36
36
  ```
37
37
 
38
- Display width and height follow `Transform.size`, not frame pixels. Resource or speed changes are observed; `autoPlay` and `forwards` are not observer fields.
38
+ Display width and height follow `Transform2D.size`, not frame pixels. Resource or speed changes are observed; `autoPlay` and `forwards` are not observer fields.
@@ -176,7 +176,7 @@ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
176
176
  this.renderSystem.rendererManager.register(this);
177
177
  }
178
178
  rendererUpdate(gameObject) {
179
- const { width, height } = gameObject.transform.size;
179
+ const { width, height } = gameObject.getComponent(pluginRenderer.Transform2D)?.size ?? { width: 0, height: 0 };
180
180
  if (this.animates[gameObject.id]) {
181
181
  this.animates[gameObject.id].animatedSprite.width = width;
182
182
  this.animates[gameObject.id].animatedSprite.height = height;
@@ -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 } 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,MAAM,EAAE,MAAK;YACnB,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE;AAC9B,gBAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;gBACxC;qBAAO;AACL,oBAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACrB;AACA,gBAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,gBAAA,IAAI,CAAC,IAAI,CAA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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
+ {"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 } 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.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","normalizeSpritesheetData","Texture","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,KAAK,EAAE;AAC9B,gBAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;gBACxC;qBAAO;AACL,oBAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACrB;AACA,gBAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,gBAAA,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YACvB;AACF,QAAA,CAAC,CAAC;I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AI,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 +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"),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
+ "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.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: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,7 +1,7 @@
1
1
  import { __decorate } from 'tslib';
2
2
  import { Component, resource, RESOURCE_TYPE, normalizeSpritesheetData, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
3
3
  import { Field } from '@combos-fun/inspector-decorator';
4
- import { Renderer, RendererSystem, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';
4
+ import { Renderer, RendererSystem, Transform2D, RESOURCE_KEY_SPLIT } from '@combos-fun/plugin-renderer';
5
5
  import { SpriteAnimation as SpriteAnimation$2 } from '@combos-fun/renderer-adapter';
6
6
  import { Texture, Spritesheet } from 'pixi.js';
7
7
 
@@ -174,7 +174,7 @@ let SpriteAnimation = class SpriteAnimation extends Renderer {
174
174
  this.renderSystem.rendererManager.register(this);
175
175
  }
176
176
  rendererUpdate(gameObject) {
177
- const { width, height } = gameObject.transform.size;
177
+ const { width, height } = gameObject.getComponent(Transform2D)?.size ?? { width: 0, height: 0 };
178
178
  if (this.animates[gameObject.id]) {
179
179
  this.animates[gameObject.id].animatedSprite.width = width;
180
180
  this.animates[gameObject.id].animatedSprite.height = height;
@@ -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 } 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,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,I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AAC;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 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 } 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.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,EAAE;AAC9B,gBAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;oBACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;gBACxC;qBAAO;AACL,oBAAA,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;gBACrB;AACA,gBA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AM,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.54",
3
+ "version": "0.1.0",
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.0.54",
41
- "@combos-fun/engine": "0.0.54",
42
- "@combos-fun/renderer-adapter": "0.0.54",
43
- "@combos-fun/inspector-decorator": "0.0.54"
40
+ "@combos-fun/plugin-renderer": "0.1.0",
41
+ "@combos-fun/engine": "0.1.0",
42
+ "@combos-fun/inspector-decorator": "0.1.0",
43
+ "@combos-fun/renderer-adapter": "0.1.0"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "node ../../scripts/build-package.mjs"