@combos-fun/plugin-renderer-sprite-animation 0.0.33 → 0.0.35

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.
@@ -89,17 +89,41 @@ let SpriteAnimation$1 = class SpriteAnimation extends engine.Component {
89
89
  }
90
90
  };
91
91
  tslib.__decorate([
92
- inspectorDecorator.type('string')
92
+ inspectorDecorator.Field({
93
+ type: 'string',
94
+ group: 'SpriteAnimation',
95
+ label: 'resource',
96
+ description: 'Sprite animation resource id.',
97
+ editor: 'text',
98
+ })
93
99
  ], SpriteAnimation$1.prototype, "resource", void 0);
94
100
  tslib.__decorate([
95
- inspectorDecorator.type('boolean')
101
+ inspectorDecorator.Field({
102
+ type: 'boolean',
103
+ group: 'SpriteAnimation',
104
+ label: 'autoPlay',
105
+ description: 'Start playing automatically when the animation loads.',
106
+ editor: 'toggle',
107
+ })
96
108
  ], SpriteAnimation$1.prototype, "autoPlay", void 0);
97
109
  tslib.__decorate([
98
- inspectorDecorator.type('number'),
99
- inspectorDecorator.step(10)
110
+ inspectorDecorator.Field({
111
+ type: 'number',
112
+ step: 10,
113
+ group: 'SpriteAnimation',
114
+ label: 'speed',
115
+ description: 'Playback speed in milliseconds per frame.',
116
+ editor: 'number-stepper',
117
+ })
100
118
  ], SpriteAnimation$1.prototype, "speed", void 0);
101
119
  tslib.__decorate([
102
- inspectorDecorator.type('boolean')
120
+ inspectorDecorator.Field({
121
+ type: 'boolean',
122
+ group: 'SpriteAnimation',
123
+ label: 'forwards',
124
+ description: 'When the loop ends, stop on the last frame instead of resetting.',
125
+ editor: 'toggle',
126
+ })
103
127
  ], SpriteAnimation$1.prototype, "forwards", void 0);
104
128
 
105
129
  const resourceKeySplit = pluginRenderer.RESOURCE_KEY_SPLIT;
@@ -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 { type, step } 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 @type('string') resource: string = '';\n @type('boolean') autoPlay: boolean = true;\n @type('number') @step(10) speed: number = 100;\n @type('boolean') forwards: boolean = false;\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 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 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 stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\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 get animate() {\n return this._animate;\n }\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame\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","type","SpriteAnimation","step","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;;QAEkB,IAAA,CAAA,QAAQ,GAAW,EAAE;QACpB,IAAA,CAAA,QAAQ,GAAY,IAAI;QACf,IAAA,CAAA,KAAK,GAAW,GAAG;QAC5B,IAAA,CAAA,QAAQ,GAAY,KAAK;QAElC,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;IAgEnC;aA1ES,IAAA,CAAA,aAAa,GAAW,iBAAX,CAA6B;AAWjD,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,CA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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,GAAAZ,gBAAA,CAAA;IAHnCa,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 } 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,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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I,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 +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.type("string")],r.prototype,"resource",void 0),e.__decorate([i.type("boolean")],r.prototype,"autoPlay",void 0),e.__decorate([i.type("number"),i.step(10)],r.prototype,"speed",void 0),e.__decorate([i.type("boolean")],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 c=new o.Spritesheet(a,i),p=await c.parse(),h=[];for(const e in p)h.push(p[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: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 c=m;exports.SpriteAnimation=r,exports.SpriteAnimationSystem=c;
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,6 +1,6 @@
1
1
  import { __decorate } from 'tslib';
2
2
  import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
3
- import { type, step } from '@combos-fun/inspector-decorator';
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';
6
6
  import { Texture, Spritesheet } from 'pixi.js';
@@ -87,17 +87,41 @@ let SpriteAnimation$1 = class SpriteAnimation extends Component {
87
87
  }
88
88
  };
89
89
  __decorate([
90
- type('string')
90
+ Field({
91
+ type: 'string',
92
+ group: 'SpriteAnimation',
93
+ label: 'resource',
94
+ description: 'Sprite animation resource id.',
95
+ editor: 'text',
96
+ })
91
97
  ], SpriteAnimation$1.prototype, "resource", void 0);
92
98
  __decorate([
93
- type('boolean')
99
+ Field({
100
+ type: 'boolean',
101
+ group: 'SpriteAnimation',
102
+ label: 'autoPlay',
103
+ description: 'Start playing automatically when the animation loads.',
104
+ editor: 'toggle',
105
+ })
94
106
  ], SpriteAnimation$1.prototype, "autoPlay", void 0);
95
107
  __decorate([
96
- type('number'),
97
- step(10)
108
+ Field({
109
+ type: 'number',
110
+ step: 10,
111
+ group: 'SpriteAnimation',
112
+ label: 'speed',
113
+ description: 'Playback speed in milliseconds per frame.',
114
+ editor: 'number-stepper',
115
+ })
98
116
  ], SpriteAnimation$1.prototype, "speed", void 0);
99
117
  __decorate([
100
- type('boolean')
118
+ Field({
119
+ type: 'boolean',
120
+ group: 'SpriteAnimation',
121
+ label: 'forwards',
122
+ description: 'When the loop ends, stop on the last frame instead of resetting.',
123
+ editor: 'toggle',
124
+ })
101
125
  ], SpriteAnimation$1.prototype, "forwards", void 0);
102
126
 
103
127
  const resourceKeySplit = RESOURCE_KEY_SPLIT;
@@ -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 { type, step } 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 @type('string') resource: string = '';\n @type('boolean') autoPlay: boolean = true;\n @type('number') @step(10) speed: number = 100;\n @type('boolean') forwards: boolean = false;\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 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 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 stop() {\n if (!this.animate) {\n this.waitStop = true;\n } else {\n this.animate.stop();\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 get animate() {\n return this._animate;\n }\n gotoAndPlay(frameNumber) {\n this.animate.gotoAndPlay(frameNumber);\n }\n gotoAndStop(frameNumber) {\n this.animate.gotoAndStop(frameNumber);\n }\n get currentFrame() {\n return this.animate?.animatedSprite?.currentFrame\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":";;;;;;;wBAYc,MAAO,eAAgB,SAAQ,SAAgC,CAAA;AAA7E,IAAA,WAAA,GAAA;;QAEkB,IAAA,CAAA,QAAQ,GAAW,EAAE;QACpB,IAAA,CAAA,QAAQ,GAAY,IAAI;QACf,IAAA,CAAA,KAAK,GAAW,GAAG;QAC5B,IAAA,CAAA,QAAQ,GAAY,KAAK;QAElC,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;IAgEnC;aA1ES,IAAA,CAAA,aAAa,GAAW,iBAAX,CAA6B;AAWjD,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;IACJ;IACA,IAAI,CAAC,KAAK,GAAG,QAAQ,EAAA;AACnB,QAAA,IAAI,KAAK,KAAK,CAAC,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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,GAAA,UAAA,CAAA;IAHnC,UAAU,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.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":";;;;;;;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,gBAAA,IAAI,CAAC,QAAQ,GAAG,IAAI;AACpB,gBAAA,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YACvB;AACF,QAAA,CAAC,CAAC;IACJ;IAEA,I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C,QAAQ,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,QAAQ,EAAE;AACb,YAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B;IACF;;AA7FmB,eAAe,GAAA,UAAA,CAAA;IAHnC,UAAU,CAAC,iBAAiB,CAAC;AAC5B,QAAA,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;KACvC;AACoB,CAAA,EAAA,eAAe,CA8FnC;8BA9FoB,eAAe;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer-sprite-animation",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
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.33",
41
- "@combos-fun/renderer-adapter": "0.0.33",
42
- "@combos-fun/engine": "0.0.33",
43
- "@combos-fun/inspector-decorator": "0.0.33"
40
+ "@combos-fun/plugin-renderer": "0.0.35",
41
+ "@combos-fun/engine": "0.0.35",
42
+ "@combos-fun/renderer-adapter": "0.0.35",
43
+ "@combos-fun/inspector-decorator": "0.0.35"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "node ../../scripts/build-package.mjs"