@combos-fun/plugin-renderer-sprite-animation 0.0.1

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @combos-fun/plugin-renderer-sprite-animation
2
+
3
+ Internal workspace package (Combos Fun monorepo).
@@ -0,0 +1,250 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var engine = require('@combos-fun/engine');
5
+ var inspectorDecorator = require('@combos-fun/inspector-decorator');
6
+ var pluginRenderer = require('@combos-fun/plugin-renderer');
7
+ var rendererAdapter = require('@combos-fun/renderer-adapter');
8
+ var pixi_js = require('pixi.js');
9
+
10
+ let SpriteAnimation$1 = class SpriteAnimation extends engine.Component {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.resource = '';
14
+ this.autoPlay = true;
15
+ this.speed = 100;
16
+ this.forwards = false;
17
+ this.waitPlay = false;
18
+ this.waitStop = false;
19
+ this.times = Infinity;
20
+ this.count = 0;
21
+ this.complete = false;
22
+ }
23
+ static { this.componentName = 'SpriteAnimation'; }
24
+ init(obj) {
25
+ obj && Object.assign(this, obj);
26
+ this.on('loop', () => {
27
+ if (++this.count >= this.times) {
28
+ if (this.forwards) {
29
+ this.gotoAndStop(this.totalFrames - 1);
30
+ }
31
+ else {
32
+ this.animate.stop();
33
+ }
34
+ this.complete = true;
35
+ this.emit('complete');
36
+ }
37
+ });
38
+ }
39
+ play(times = Infinity) {
40
+ if (times === 0) {
41
+ return;
42
+ }
43
+ this.times = times;
44
+ if (!this.animate) {
45
+ this.waitPlay = true;
46
+ }
47
+ else {
48
+ if (this.complete) {
49
+ this.gotoAndStop(0);
50
+ }
51
+ this.animate.play();
52
+ this.count = 0;
53
+ this.complete = false;
54
+ }
55
+ }
56
+ stop() {
57
+ if (!this.animate) {
58
+ this.waitStop = true;
59
+ }
60
+ else {
61
+ this.animate.stop();
62
+ }
63
+ }
64
+ set animate(val) {
65
+ this._animate = val;
66
+ if (this.waitPlay) {
67
+ this.waitPlay = false;
68
+ this.play(this.times);
69
+ }
70
+ if (this.waitStop) {
71
+ this.waitStop = false;
72
+ this.stop();
73
+ }
74
+ }
75
+ get animate() {
76
+ return this._animate;
77
+ }
78
+ gotoAndPlay(frameNumber) {
79
+ this.animate.gotoAndPlay(frameNumber);
80
+ }
81
+ gotoAndStop(frameNumber) {
82
+ this.animate.gotoAndStop(frameNumber);
83
+ }
84
+ get currentFrame() {
85
+ return this.animate?.animatedSprite?.currentFrame;
86
+ }
87
+ get totalFrames() {
88
+ return this.animate?.animatedSprite?.totalFrames;
89
+ }
90
+ };
91
+ tslib.__decorate([
92
+ inspectorDecorator.type('string')
93
+ ], SpriteAnimation$1.prototype, "resource", void 0);
94
+ tslib.__decorate([
95
+ inspectorDecorator.type('boolean')
96
+ ], SpriteAnimation$1.prototype, "autoPlay", void 0);
97
+ tslib.__decorate([
98
+ inspectorDecorator.type('number'),
99
+ inspectorDecorator.step(10)
100
+ ], SpriteAnimation$1.prototype, "speed", void 0);
101
+ tslib.__decorate([
102
+ inspectorDecorator.type('boolean')
103
+ ], SpriteAnimation$1.prototype, "forwards", void 0);
104
+
105
+ const resourceKeySplit = '_s|r|c_';
106
+ engine.resource.registerInstance(engine.RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {
107
+ const textureObj = data.json;
108
+ const texture = pixi_js.Texture.from(data.image);
109
+ const frames = textureObj.frames || {};
110
+ const animations = textureObj.animations || {};
111
+ const newFrames = {};
112
+ for (const key in frames) {
113
+ const newKey = name + resourceKeySplit + key;
114
+ newFrames[newKey] = frames[key];
115
+ }
116
+ for (const key in animations) {
117
+ const spriteList = [];
118
+ if (animations[key] && animations[key].length >= 0) {
119
+ for (const spriteName of animations[key]) {
120
+ const newSpriteName = name + resourceKeySplit + spriteName;
121
+ spriteList.push(newSpriteName);
122
+ }
123
+ }
124
+ animations[key] = spriteList;
125
+ }
126
+ textureObj.frames = newFrames;
127
+ const spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
128
+ const textures = await spriteSheet.parse();
129
+ const spriteFrames = [];
130
+ for (const key in textures) {
131
+ spriteFrames.push(textures[key]);
132
+ }
133
+ return spriteFrames;
134
+ });
135
+ engine.resource.registerDestroy(engine.RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {
136
+ if (!instance)
137
+ return;
138
+ for (const texture of instance) {
139
+ texture.destroy(true);
140
+ }
141
+ });
142
+ let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
143
+ constructor() {
144
+ super(...arguments);
145
+ this.name = 'SpriteAnimation';
146
+ this.animates = {};
147
+ this.autoPlay = {};
148
+ }
149
+ static { this.systemName = 'SpriteAnimation'; }
150
+ init() {
151
+ this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
152
+ this.renderSystem.rendererManager.register(this);
153
+ }
154
+ rendererUpdate(gameObject) {
155
+ const { width, height } = gameObject.transform.size;
156
+ if (this.animates[gameObject.id]) {
157
+ this.animates[gameObject.id].animatedSprite.width = width;
158
+ this.animates[gameObject.id].animatedSprite.height = height;
159
+ }
160
+ }
161
+ async componentChanged(changed) {
162
+ const gameObjectId = changed.gameObject.id;
163
+ if (changed.componentName === 'SpriteAnimation') {
164
+ const component = changed.component;
165
+ this.autoPlay[changed.gameObject.id] = component.autoPlay;
166
+ if (changed.type === engine.OBSERVER_TYPE.ADD) {
167
+ const asyncId = this.increaseAsyncId(gameObjectId);
168
+ const { instance: frames } = await engine.resource.getResource(component.resource);
169
+ if (!this.validateAsyncId(gameObjectId, asyncId))
170
+ return;
171
+ if (!frames) {
172
+ console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
173
+ }
174
+ this.add({
175
+ frames: frames,
176
+ id: changed.gameObject.id,
177
+ component,
178
+ });
179
+ }
180
+ else if (changed.type === engine.OBSERVER_TYPE.CHANGE) {
181
+ if (changed.prop && changed.prop.prop[0] === 'speed') {
182
+ this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
183
+ }
184
+ else {
185
+ const asyncId = this.increaseAsyncId(gameObjectId);
186
+ const { instance: frames } = await engine.resource.getResource(component.resource);
187
+ if (!this.validateAsyncId(gameObjectId, asyncId))
188
+ return;
189
+ if (!frames) {
190
+ console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
191
+ }
192
+ this.change({
193
+ frames: frames,
194
+ id: changed.gameObject.id,
195
+ component,
196
+ });
197
+ }
198
+ }
199
+ else if (changed.type === engine.OBSERVER_TYPE.REMOVE) {
200
+ this.increaseAsyncId(gameObjectId);
201
+ this.remove(changed.gameObject.id);
202
+ }
203
+ }
204
+ }
205
+ add({ frames, id, component }) {
206
+ const animate = new rendererAdapter.SpriteAnimation({ frames });
207
+ this.animates[id] = animate;
208
+ this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
209
+ animate.animatedSprite.onComplete = () => {
210
+ component.emit('complete');
211
+ };
212
+ animate.animatedSprite.onFrameChange = () => {
213
+ component.emit('frameChange');
214
+ };
215
+ animate.animatedSprite.onLoop = () => {
216
+ component.emit('loop');
217
+ };
218
+ component.animate = this.animates[id];
219
+ this.animates[id].speed = 1000 / 60 / component.speed;
220
+ if (this.autoPlay[id]) {
221
+ animate.animatedSprite.play();
222
+ }
223
+ }
224
+ change({ frames, id, component }) {
225
+ this.remove(id, true);
226
+ this.add({ frames, id, component });
227
+ }
228
+ remove(id, isChange) {
229
+ const animate = this.animates[id];
230
+ if (!animate)
231
+ return;
232
+ this.autoPlay[id] = animate.animatedSprite.playing;
233
+ this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
234
+ animate.animatedSprite.destroy({ children: true });
235
+ delete this.animates[id];
236
+ if (!isChange) {
237
+ delete this.autoPlay[id];
238
+ }
239
+ }
240
+ };
241
+ SpriteAnimation = tslib.__decorate([
242
+ engine.decorators.componentObserver({
243
+ SpriteAnimation: ['speed', 'resource'],
244
+ })
245
+ ], SpriteAnimation);
246
+ var SpriteAnimation_default = SpriteAnimation;
247
+
248
+ exports.SpriteAnimation = SpriteAnimation$1;
249
+ exports.SpriteAnimationSystem = SpriteAnimation_default;
250
+ //# sourceMappingURL=plugin-renderer-sprite-animation.cjs.js.map
@@ -0,0 +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 } 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 = '_s|r|c_';\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","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,CA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orator"),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.type("string")],o.prototype,"resource",void 0),e.__decorate([i.type("boolean")],o.prototype,"autoPlay",void 0),e.__decorate([i.type("number"),i.step(10)],o.prototype,"speed",void 0),e.__decorate([i.type("boolean")],o.prototype,"forwards",void 0);const n="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,async({name:e,data:t})=>{const i=t.json,a=r.Texture.from(t.image),s=i.frames||{},o=i.animations||{},m={};for(const t in s){m[e+n+t]=s[t]}for(const t in o){const i=[];if(o[t]&&o[t].length>=0)for(const a of o[t]){const t=e+n+a;i.push(t)}o[t]=i}i.frames=m;const c=new r.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:r}=await t.resource.getResource(a.resource);if(!this.validateAsyncId(i,s))return;r||console.error(`GameObject:${e.gameObject.name}'s Img 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;r||console.error(`GameObject:${e.gameObject.name}'s Img 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 c=m;exports.SpriteAnimation=o,exports.SpriteAnimationSystem=c;
@@ -0,0 +1,64 @@
1
+ import { Component, GameObject, ComponentChanged } from '@combos-fun/engine';
2
+ import { SpriteAnimation as SpriteAnimation$2 } from '@combos-fun/renderer-adapter';
3
+ import { Renderer, RendererSystem, RendererManager, ContainerManager } from '@combos-fun/plugin-renderer';
4
+
5
+ interface SpriteAnimationParams {
6
+ resource: string;
7
+ autoPlay?: boolean;
8
+ speed?: number;
9
+ /** Stop at last frame */
10
+ forwards?: boolean;
11
+ }
12
+ declare class SpriteAnimation$1 extends Component<SpriteAnimationParams> {
13
+ static componentName: string;
14
+ resource: string;
15
+ autoPlay: boolean;
16
+ speed: number;
17
+ forwards: boolean;
18
+ _animate: SpriteAnimation$2;
19
+ private waitPlay;
20
+ private waitStop;
21
+ private times;
22
+ private count;
23
+ private complete;
24
+ init(obj?: SpriteAnimationParams): void;
25
+ play(times?: number): void;
26
+ stop(): void;
27
+ set animate(val: SpriteAnimation$2);
28
+ get animate(): SpriteAnimation$2;
29
+ gotoAndPlay(frameNumber: any): void;
30
+ gotoAndStop(frameNumber: any): void;
31
+ get currentFrame(): number;
32
+ get totalFrames(): number;
33
+ }
34
+
35
+ declare class SpriteAnimation extends Renderer {
36
+ static systemName: string;
37
+ name: string;
38
+ animates: {
39
+ [propName: number]: SpriteAnimation$2;
40
+ };
41
+ autoPlay: {
42
+ [propName: number]: boolean;
43
+ };
44
+ renderSystem: RendererSystem;
45
+ rendererManager: RendererManager;
46
+ containerManager: ContainerManager;
47
+ init(): void;
48
+ rendererUpdate(gameObject: GameObject): void;
49
+ componentChanged(changed: ComponentChanged): Promise<void>;
50
+ add({ frames, id, component }: {
51
+ frames: any;
52
+ id: any;
53
+ component: any;
54
+ }): void;
55
+ change({ frames, id, component }: {
56
+ frames: any;
57
+ id: any;
58
+ component: any;
59
+ }): void;
60
+ remove(id: any, isChange?: boolean): void;
61
+ }
62
+
63
+ export { SpriteAnimation$1 as SpriteAnimation, SpriteAnimation as SpriteAnimationSystem };
64
+ export type { SpriteAnimationParams };
@@ -0,0 +1,247 @@
1
+ import { __decorate } from 'tslib';
2
+ import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@combos-fun/engine';
3
+ import { type, step } from '@combos-fun/inspector-decorator';
4
+ import { Renderer, RendererSystem } from '@combos-fun/plugin-renderer';
5
+ import { SpriteAnimation as SpriteAnimation$2 } from '@combos-fun/renderer-adapter';
6
+ import { Texture, Spritesheet } from 'pixi.js';
7
+
8
+ let SpriteAnimation$1 = class SpriteAnimation extends Component {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.resource = '';
12
+ this.autoPlay = true;
13
+ this.speed = 100;
14
+ this.forwards = false;
15
+ this.waitPlay = false;
16
+ this.waitStop = false;
17
+ this.times = Infinity;
18
+ this.count = 0;
19
+ this.complete = false;
20
+ }
21
+ static { this.componentName = 'SpriteAnimation'; }
22
+ init(obj) {
23
+ obj && Object.assign(this, obj);
24
+ this.on('loop', () => {
25
+ if (++this.count >= this.times) {
26
+ if (this.forwards) {
27
+ this.gotoAndStop(this.totalFrames - 1);
28
+ }
29
+ else {
30
+ this.animate.stop();
31
+ }
32
+ this.complete = true;
33
+ this.emit('complete');
34
+ }
35
+ });
36
+ }
37
+ play(times = Infinity) {
38
+ if (times === 0) {
39
+ return;
40
+ }
41
+ this.times = times;
42
+ if (!this.animate) {
43
+ this.waitPlay = true;
44
+ }
45
+ else {
46
+ if (this.complete) {
47
+ this.gotoAndStop(0);
48
+ }
49
+ this.animate.play();
50
+ this.count = 0;
51
+ this.complete = false;
52
+ }
53
+ }
54
+ stop() {
55
+ if (!this.animate) {
56
+ this.waitStop = true;
57
+ }
58
+ else {
59
+ this.animate.stop();
60
+ }
61
+ }
62
+ set animate(val) {
63
+ this._animate = val;
64
+ if (this.waitPlay) {
65
+ this.waitPlay = false;
66
+ this.play(this.times);
67
+ }
68
+ if (this.waitStop) {
69
+ this.waitStop = false;
70
+ this.stop();
71
+ }
72
+ }
73
+ get animate() {
74
+ return this._animate;
75
+ }
76
+ gotoAndPlay(frameNumber) {
77
+ this.animate.gotoAndPlay(frameNumber);
78
+ }
79
+ gotoAndStop(frameNumber) {
80
+ this.animate.gotoAndStop(frameNumber);
81
+ }
82
+ get currentFrame() {
83
+ return this.animate?.animatedSprite?.currentFrame;
84
+ }
85
+ get totalFrames() {
86
+ return this.animate?.animatedSprite?.totalFrames;
87
+ }
88
+ };
89
+ __decorate([
90
+ type('string')
91
+ ], SpriteAnimation$1.prototype, "resource", void 0);
92
+ __decorate([
93
+ type('boolean')
94
+ ], SpriteAnimation$1.prototype, "autoPlay", void 0);
95
+ __decorate([
96
+ type('number'),
97
+ step(10)
98
+ ], SpriteAnimation$1.prototype, "speed", void 0);
99
+ __decorate([
100
+ type('boolean')
101
+ ], SpriteAnimation$1.prototype, "forwards", void 0);
102
+
103
+ const resourceKeySplit = '_s|r|c_';
104
+ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, async ({ name, data }) => {
105
+ const textureObj = data.json;
106
+ const texture = Texture.from(data.image);
107
+ const frames = textureObj.frames || {};
108
+ const animations = textureObj.animations || {};
109
+ const newFrames = {};
110
+ for (const key in frames) {
111
+ const newKey = name + resourceKeySplit + key;
112
+ newFrames[newKey] = frames[key];
113
+ }
114
+ for (const key in animations) {
115
+ const spriteList = [];
116
+ if (animations[key] && animations[key].length >= 0) {
117
+ for (const spriteName of animations[key]) {
118
+ const newSpriteName = name + resourceKeySplit + spriteName;
119
+ spriteList.push(newSpriteName);
120
+ }
121
+ }
122
+ animations[key] = spriteList;
123
+ }
124
+ textureObj.frames = newFrames;
125
+ const spriteSheet = new Spritesheet(texture, textureObj);
126
+ const textures = await spriteSheet.parse();
127
+ const spriteFrames = [];
128
+ for (const key in textures) {
129
+ spriteFrames.push(textures[key]);
130
+ }
131
+ return spriteFrames;
132
+ });
133
+ resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, ({ instance }) => {
134
+ if (!instance)
135
+ return;
136
+ for (const texture of instance) {
137
+ texture.destroy(true);
138
+ }
139
+ });
140
+ let SpriteAnimation = class SpriteAnimation extends Renderer {
141
+ constructor() {
142
+ super(...arguments);
143
+ this.name = 'SpriteAnimation';
144
+ this.animates = {};
145
+ this.autoPlay = {};
146
+ }
147
+ static { this.systemName = 'SpriteAnimation'; }
148
+ init() {
149
+ this.renderSystem = this.game.getSystem(RendererSystem);
150
+ this.renderSystem.rendererManager.register(this);
151
+ }
152
+ rendererUpdate(gameObject) {
153
+ const { width, height } = gameObject.transform.size;
154
+ if (this.animates[gameObject.id]) {
155
+ this.animates[gameObject.id].animatedSprite.width = width;
156
+ this.animates[gameObject.id].animatedSprite.height = height;
157
+ }
158
+ }
159
+ async componentChanged(changed) {
160
+ const gameObjectId = changed.gameObject.id;
161
+ if (changed.componentName === 'SpriteAnimation') {
162
+ const component = changed.component;
163
+ this.autoPlay[changed.gameObject.id] = component.autoPlay;
164
+ if (changed.type === OBSERVER_TYPE.ADD) {
165
+ const asyncId = this.increaseAsyncId(gameObjectId);
166
+ const { instance: frames } = await resource.getResource(component.resource);
167
+ if (!this.validateAsyncId(gameObjectId, asyncId))
168
+ return;
169
+ if (!frames) {
170
+ console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
171
+ }
172
+ this.add({
173
+ frames: frames,
174
+ id: changed.gameObject.id,
175
+ component,
176
+ });
177
+ }
178
+ else if (changed.type === OBSERVER_TYPE.CHANGE) {
179
+ if (changed.prop && changed.prop.prop[0] === 'speed') {
180
+ this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
181
+ }
182
+ else {
183
+ const asyncId = this.increaseAsyncId(gameObjectId);
184
+ const { instance: frames } = await resource.getResource(component.resource);
185
+ if (!this.validateAsyncId(gameObjectId, asyncId))
186
+ return;
187
+ if (!frames) {
188
+ console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
189
+ }
190
+ this.change({
191
+ frames: frames,
192
+ id: changed.gameObject.id,
193
+ component,
194
+ });
195
+ }
196
+ }
197
+ else if (changed.type === OBSERVER_TYPE.REMOVE) {
198
+ this.increaseAsyncId(gameObjectId);
199
+ this.remove(changed.gameObject.id);
200
+ }
201
+ }
202
+ }
203
+ add({ frames, id, component }) {
204
+ const animate = new SpriteAnimation$2({ frames });
205
+ this.animates[id] = animate;
206
+ this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
207
+ animate.animatedSprite.onComplete = () => {
208
+ component.emit('complete');
209
+ };
210
+ animate.animatedSprite.onFrameChange = () => {
211
+ component.emit('frameChange');
212
+ };
213
+ animate.animatedSprite.onLoop = () => {
214
+ component.emit('loop');
215
+ };
216
+ component.animate = this.animates[id];
217
+ this.animates[id].speed = 1000 / 60 / component.speed;
218
+ if (this.autoPlay[id]) {
219
+ animate.animatedSprite.play();
220
+ }
221
+ }
222
+ change({ frames, id, component }) {
223
+ this.remove(id, true);
224
+ this.add({ frames, id, component });
225
+ }
226
+ remove(id, isChange) {
227
+ const animate = this.animates[id];
228
+ if (!animate)
229
+ return;
230
+ this.autoPlay[id] = animate.animatedSprite.playing;
231
+ this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
232
+ animate.animatedSprite.destroy({ children: true });
233
+ delete this.animates[id];
234
+ if (!isChange) {
235
+ delete this.autoPlay[id];
236
+ }
237
+ }
238
+ };
239
+ SpriteAnimation = __decorate([
240
+ decorators.componentObserver({
241
+ SpriteAnimation: ['speed', 'resource'],
242
+ })
243
+ ], SpriteAnimation);
244
+ var SpriteAnimation_default = SpriteAnimation;
245
+
246
+ export { SpriteAnimation$1 as SpriteAnimation, SpriteAnimation_default as SpriteAnimationSystem };
247
+ //# sourceMappingURL=plugin-renderer-sprite-animation.esm.js.map
@@ -0,0 +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 } 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 = '_s|r|c_';\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({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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;;;;"}
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.prod.js');
5
+ } else {
6
+ module.exports = require('./dist/plugin-renderer-sprite-animation.cjs.js');
7
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@combos-fun/plugin-renderer-sprite-animation",
3
+ "version": "0.0.1",
4
+ "description": "@combos-fun/plugin-renderer-sprite-animation",
5
+ "main": "index.js",
6
+ "module": "dist/plugin-renderer-sprite-animation.esm.js",
7
+ "bundle": "CombosFun.plugin.renderer.spriteAnimation",
8
+ "unpkg": "dist/CombosFun.plugin.renderer.spriteAnimation.min.js",
9
+ "files": [
10
+ "index.js",
11
+ "dist"
12
+ ],
13
+ "types": "dist/plugin-renderer-sprite-animation.d.ts",
14
+ "keywords": [
15
+ "combos-fun",
16
+ "game"
17
+ ],
18
+ "author": "sun668 <q947692259@gmail.com>",
19
+ "dependencies": {
20
+ "pixi.js": "^8.18.1",
21
+ "@combos-fun/renderer-adapter": "0.0.1",
22
+ "@combos-fun/engine": "0.0.1",
23
+ "@combos-fun/inspector-decorator": "0.0.1",
24
+ "@combos-fun/plugin-renderer": "0.0.1"
25
+ },
26
+ "scripts": {
27
+ "build": "node ../../scripts/build-package.mjs"
28
+ }
29
+ }