@eva/plugin-renderer-sprite-animation 2.0.0-beta.1 → 2.0.0-beta.11
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/dist/EVA.plugin.renderer.spriteAnimation.js +168 -347
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js +1 -1
- package/dist/plugin-renderer-sprite-animation.cjs.js +158 -271
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js +16 -1
- package/dist/plugin-renderer-sprite-animation.esm.js +160 -273
- package/package.json +5 -5
|
@@ -4,23 +4,6 @@ window.EVA.plugin = window.EVA.plugin || {};
|
|
|
4
4
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
5
5
|
var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
|
|
6
6
|
'use strict';
|
|
7
|
-
var extendStatics = function (d, b) {
|
|
8
|
-
extendStatics = Object.setPrototypeOf || {
|
|
9
|
-
__proto__: []
|
|
10
|
-
} instanceof Array && function (d, b) {
|
|
11
|
-
d.__proto__ = b;
|
|
12
|
-
} || function (d, b) {
|
|
13
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
16
|
-
};
|
|
17
|
-
function __extends(d, b) {
|
|
18
|
-
extendStatics(d, b);
|
|
19
|
-
function __() {
|
|
20
|
-
this.constructor = d;
|
|
21
|
-
}
|
|
22
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
23
|
-
}
|
|
24
7
|
function __decorate(decorators, target, key, desc) {
|
|
25
8
|
var c = arguments.length,
|
|
26
9
|
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
@@ -55,110 +38,6 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
55
38
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
56
39
|
});
|
|
57
40
|
}
|
|
58
|
-
function __generator(thisArg, body) {
|
|
59
|
-
var _ = {
|
|
60
|
-
label: 0,
|
|
61
|
-
sent: function () {
|
|
62
|
-
if (t[0] & 1) throw t[1];
|
|
63
|
-
return t[1];
|
|
64
|
-
},
|
|
65
|
-
trys: [],
|
|
66
|
-
ops: []
|
|
67
|
-
},
|
|
68
|
-
f,
|
|
69
|
-
y,
|
|
70
|
-
t,
|
|
71
|
-
g;
|
|
72
|
-
return g = {
|
|
73
|
-
next: verb(0),
|
|
74
|
-
"throw": verb(1),
|
|
75
|
-
"return": verb(2)
|
|
76
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
77
|
-
return this;
|
|
78
|
-
}), g;
|
|
79
|
-
function verb(n) {
|
|
80
|
-
return function (v) {
|
|
81
|
-
return step([n, v]);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function step(op) {
|
|
85
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
86
|
-
while (_) try {
|
|
87
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
88
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
89
|
-
switch (op[0]) {
|
|
90
|
-
case 0:
|
|
91
|
-
case 1:
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
case 4:
|
|
95
|
-
_.label++;
|
|
96
|
-
return {
|
|
97
|
-
value: op[1],
|
|
98
|
-
done: false
|
|
99
|
-
};
|
|
100
|
-
case 5:
|
|
101
|
-
_.label++;
|
|
102
|
-
y = op[1];
|
|
103
|
-
op = [0];
|
|
104
|
-
continue;
|
|
105
|
-
case 7:
|
|
106
|
-
op = _.ops.pop();
|
|
107
|
-
_.trys.pop();
|
|
108
|
-
continue;
|
|
109
|
-
default:
|
|
110
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
111
|
-
_ = 0;
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
115
|
-
_.label = op[1];
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
119
|
-
_.label = t[1];
|
|
120
|
-
t = op;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (t && _.label < t[2]) {
|
|
124
|
-
_.label = t[2];
|
|
125
|
-
_.ops.push(op);
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
if (t[2]) _.ops.pop();
|
|
129
|
-
_.trys.pop();
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
op = body.call(thisArg, _);
|
|
133
|
-
} catch (e) {
|
|
134
|
-
op = [6, e];
|
|
135
|
-
y = 0;
|
|
136
|
-
} finally {
|
|
137
|
-
f = t = 0;
|
|
138
|
-
}
|
|
139
|
-
if (op[0] & 5) throw op[1];
|
|
140
|
-
return {
|
|
141
|
-
value: op[0] ? op[1] : void 0,
|
|
142
|
-
done: true
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
function __values(o) {
|
|
147
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
148
|
-
m = s && o[s],
|
|
149
|
-
i = 0;
|
|
150
|
-
if (m) return m.call(o);
|
|
151
|
-
if (o && typeof o.length === "number") return {
|
|
152
|
-
next: function () {
|
|
153
|
-
if (o && i >= o.length) o = void 0;
|
|
154
|
-
return {
|
|
155
|
-
value: o && o[i++],
|
|
156
|
-
done: !o
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
161
|
-
}
|
|
162
41
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
163
42
|
if (!target.constructor.IDEProps) {
|
|
164
43
|
target.constructor.IDEProps = {};
|
|
@@ -182,40 +61,34 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
182
61
|
prop.step = step;
|
|
183
62
|
};
|
|
184
63
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
_this.complete = false;
|
|
198
|
-
return _this;
|
|
64
|
+
class SpriteAnimation$2 extends eva_js.Component {
|
|
65
|
+
constructor() {
|
|
66
|
+
super(...arguments);
|
|
67
|
+
this.resource = '';
|
|
68
|
+
this.autoPlay = true;
|
|
69
|
+
this.speed = 100;
|
|
70
|
+
this.forwards = false;
|
|
71
|
+
this.waitPlay = false;
|
|
72
|
+
this.waitStop = false;
|
|
73
|
+
this.times = Infinity;
|
|
74
|
+
this.count = 0;
|
|
75
|
+
this.complete = false;
|
|
199
76
|
}
|
|
200
|
-
|
|
201
|
-
var _this = this;
|
|
77
|
+
init(obj) {
|
|
202
78
|
obj && _extends(this, obj);
|
|
203
|
-
this.on('loop',
|
|
204
|
-
if (++
|
|
205
|
-
if (
|
|
206
|
-
|
|
79
|
+
this.on('loop', () => {
|
|
80
|
+
if (++this.count >= this.times) {
|
|
81
|
+
if (this.forwards) {
|
|
82
|
+
this.gotoAndStop(this.totalFrames - 1);
|
|
207
83
|
} else {
|
|
208
|
-
|
|
84
|
+
this.animate.stop();
|
|
209
85
|
}
|
|
210
|
-
|
|
211
|
-
|
|
86
|
+
this.complete = true;
|
|
87
|
+
this.emit('complete');
|
|
212
88
|
}
|
|
213
89
|
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (times === void 0) {
|
|
217
|
-
times = Infinity;
|
|
218
|
-
}
|
|
90
|
+
}
|
|
91
|
+
play(times = Infinity) {
|
|
219
92
|
if (times === 0) {
|
|
220
93
|
return;
|
|
221
94
|
}
|
|
@@ -230,230 +103,178 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
230
103
|
this.count = 0;
|
|
231
104
|
this.complete = false;
|
|
232
105
|
}
|
|
233
|
-
}
|
|
234
|
-
|
|
106
|
+
}
|
|
107
|
+
stop() {
|
|
235
108
|
if (!this.animate) {
|
|
236
109
|
this.waitStop = true;
|
|
237
110
|
} else {
|
|
238
111
|
this.animate.stop();
|
|
239
112
|
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
enumerable: false,
|
|
257
|
-
configurable: true
|
|
258
|
-
});
|
|
259
|
-
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
113
|
+
}
|
|
114
|
+
set animate(val) {
|
|
115
|
+
this._animate = val;
|
|
116
|
+
if (this.waitPlay) {
|
|
117
|
+
this.waitPlay = false;
|
|
118
|
+
this.play(this.times);
|
|
119
|
+
}
|
|
120
|
+
if (this.waitStop) {
|
|
121
|
+
this.waitStop = false;
|
|
122
|
+
this.stop();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
get animate() {
|
|
126
|
+
return this._animate;
|
|
127
|
+
}
|
|
128
|
+
gotoAndPlay(frameNumber) {
|
|
260
129
|
this.animate.gotoAndPlay(frameNumber);
|
|
261
|
-
}
|
|
262
|
-
|
|
130
|
+
}
|
|
131
|
+
gotoAndStop(frameNumber) {
|
|
263
132
|
this.animate.gotoAndStop(frameNumber);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
data = _a.data;
|
|
293
|
-
return new Promise(function (r) {
|
|
294
|
-
var e_1, _a;
|
|
295
|
-
var textureObj = data.json.data;
|
|
296
|
-
var texture = data.image instanceof pixi_js.Texture ? data.image : pixi_js.Texture.from(data.image);
|
|
297
|
-
var frames = textureObj.frames || {};
|
|
298
|
-
var animations = textureObj.animations || {};
|
|
299
|
-
var newFrames = {};
|
|
300
|
-
for (var key in frames) {
|
|
301
|
-
var newKey = name + resourceKeySplit + key;
|
|
133
|
+
}
|
|
134
|
+
get currentFrame() {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
137
|
+
}
|
|
138
|
+
get totalFrames() {
|
|
139
|
+
var _a, _b;
|
|
140
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
SpriteAnimation$2.componentName = 'SpriteAnimation';
|
|
144
|
+
__decorate([type('string')], SpriteAnimation$2.prototype, "resource", void 0);
|
|
145
|
+
__decorate([type('boolean')], SpriteAnimation$2.prototype, "autoPlay", void 0);
|
|
146
|
+
__decorate([type('number'), step(10)], SpriteAnimation$2.prototype, "speed", void 0);
|
|
147
|
+
__decorate([type('boolean')], SpriteAnimation$2.prototype, "forwards", void 0);
|
|
148
|
+
const resourceKeySplit = '_s|r|c_';
|
|
149
|
+
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, ({
|
|
150
|
+
name,
|
|
151
|
+
data
|
|
152
|
+
}) => {
|
|
153
|
+
return new Promise(r => {
|
|
154
|
+
const textureObj = data.json.data;
|
|
155
|
+
const texture = data.image instanceof pixi_js.Texture ? data.image : pixi_js.Texture.from(data.image);
|
|
156
|
+
const frames = textureObj.frames || {};
|
|
157
|
+
const animations = textureObj.animations || {};
|
|
158
|
+
const newFrames = {};
|
|
159
|
+
for (const key in frames) {
|
|
160
|
+
const newKey = name + resourceKeySplit + key;
|
|
302
161
|
newFrames[newKey] = frames[key];
|
|
303
162
|
}
|
|
304
|
-
for (
|
|
305
|
-
|
|
163
|
+
for (const key in animations) {
|
|
164
|
+
const spriteList = [];
|
|
306
165
|
if (animations[key] && animations[key].length >= 0) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
311
|
-
spriteList.push(newSpriteName);
|
|
312
|
-
}
|
|
313
|
-
} catch (e_1_1) {
|
|
314
|
-
e_1 = {
|
|
315
|
-
error: e_1_1
|
|
316
|
-
};
|
|
317
|
-
} finally {
|
|
318
|
-
try {
|
|
319
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
320
|
-
} finally {
|
|
321
|
-
if (e_1) throw e_1.error;
|
|
322
|
-
}
|
|
166
|
+
for (const spriteName of animations[key]) {
|
|
167
|
+
const newSpriteName = name + resourceKeySplit + spriteName;
|
|
168
|
+
spriteList.push(newSpriteName);
|
|
323
169
|
}
|
|
324
170
|
}
|
|
325
171
|
animations[key] = spriteList;
|
|
326
172
|
}
|
|
327
173
|
textureObj.frames = newFrames;
|
|
328
|
-
|
|
329
|
-
spriteSheet.parse().then(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
174
|
+
const spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
175
|
+
spriteSheet.parse().then(() => {
|
|
176
|
+
const {
|
|
177
|
+
textures
|
|
178
|
+
} = spriteSheet;
|
|
179
|
+
const spriteFrames = [];
|
|
180
|
+
for (const key in textures) {
|
|
333
181
|
spriteFrames.push(textures[key]);
|
|
334
182
|
}
|
|
335
183
|
r(spriteFrames);
|
|
336
184
|
});
|
|
337
185
|
});
|
|
338
186
|
});
|
|
339
|
-
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION,
|
|
340
|
-
|
|
341
|
-
|
|
187
|
+
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, ({
|
|
188
|
+
instance
|
|
189
|
+
}) => {
|
|
342
190
|
if (!instance) return;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
var texture = instance_1_1.value;
|
|
346
|
-
texture.destroy(true);
|
|
347
|
-
}
|
|
348
|
-
} catch (e_2_1) {
|
|
349
|
-
e_2 = {
|
|
350
|
-
error: e_2_1
|
|
351
|
-
};
|
|
352
|
-
} finally {
|
|
353
|
-
try {
|
|
354
|
-
if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
|
|
355
|
-
} finally {
|
|
356
|
-
if (e_2) throw e_2.error;
|
|
357
|
-
}
|
|
191
|
+
for (const texture of instance) {
|
|
192
|
+
texture.destroy(true);
|
|
358
193
|
}
|
|
359
194
|
});
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
_this.autoPlay = {};
|
|
367
|
-
return _this;
|
|
195
|
+
let SpriteAnimation = class SpriteAnimation extends pluginRenderer.Renderer {
|
|
196
|
+
constructor() {
|
|
197
|
+
super(...arguments);
|
|
198
|
+
this.name = 'SpriteAnimation';
|
|
199
|
+
this.animates = {};
|
|
200
|
+
this.autoPlay = {};
|
|
368
201
|
}
|
|
369
|
-
|
|
202
|
+
init() {
|
|
370
203
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
371
204
|
this.renderSystem.rendererManager.register(this);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
width
|
|
376
|
-
height
|
|
205
|
+
}
|
|
206
|
+
rendererUpdate(gameObject) {
|
|
207
|
+
const {
|
|
208
|
+
width,
|
|
209
|
+
height
|
|
210
|
+
} = gameObject.transform.size;
|
|
377
211
|
if (this.animates[gameObject.id]) {
|
|
378
212
|
this.animates[gameObject.id].animatedSprite.width = width;
|
|
379
213
|
this.animates[gameObject.id].animatedSprite.height = height;
|
|
380
214
|
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
component: component
|
|
405
|
-
});
|
|
406
|
-
return [3, 7];
|
|
407
|
-
case 2:
|
|
408
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
409
|
-
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
215
|
+
}
|
|
216
|
+
componentChanged(changed) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
const gameObjectId = changed.gameObject.id;
|
|
219
|
+
if (changed.componentName === 'SpriteAnimation') {
|
|
220
|
+
const component = changed.component;
|
|
221
|
+
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
222
|
+
if (changed.type === eva_js.OBSERVER_TYPE.ADD) {
|
|
223
|
+
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
224
|
+
const {
|
|
225
|
+
instance: frames
|
|
226
|
+
} = yield eva_js.resource.getResource(component.resource);
|
|
227
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return;
|
|
228
|
+
if (!frames) {
|
|
229
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
230
|
+
}
|
|
231
|
+
this.add({
|
|
232
|
+
frames: frames,
|
|
233
|
+
id: changed.gameObject.id,
|
|
234
|
+
component
|
|
235
|
+
});
|
|
236
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.CHANGE) {
|
|
237
|
+
if (changed.prop && changed.prop.prop[0] === 'speed') {
|
|
410
238
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
if (!
|
|
418
|
-
|
|
419
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
239
|
+
} else {
|
|
240
|
+
const asyncId = this.increaseAsyncId(gameObjectId);
|
|
241
|
+
const {
|
|
242
|
+
instance: frames
|
|
243
|
+
} = yield eva_js.resource.getResource(component.resource);
|
|
244
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return;
|
|
245
|
+
if (!frames) {
|
|
246
|
+
console.error(`GameObject:${changed.gameObject.name}'s Img resource load error`);
|
|
420
247
|
}
|
|
421
248
|
this.change({
|
|
422
|
-
frames:
|
|
249
|
+
frames: frames,
|
|
423
250
|
id: changed.gameObject.id,
|
|
424
|
-
component
|
|
251
|
+
component
|
|
425
252
|
});
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
431
|
-
this.increaseAsyncId(gameObjectId);
|
|
432
|
-
this.remove(changed.gameObject.id);
|
|
433
|
-
}
|
|
434
|
-
_a.label = 7;
|
|
435
|
-
case 7:
|
|
436
|
-
return [2];
|
|
253
|
+
}
|
|
254
|
+
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
255
|
+
this.increaseAsyncId(gameObjectId);
|
|
256
|
+
this.remove(changed.gameObject.id);
|
|
437
257
|
}
|
|
438
|
-
}
|
|
258
|
+
}
|
|
439
259
|
});
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
260
|
+
}
|
|
261
|
+
add({
|
|
262
|
+
frames,
|
|
263
|
+
id,
|
|
264
|
+
component
|
|
265
|
+
}) {
|
|
266
|
+
const animate = new rendererAdapter.SpriteAnimation({
|
|
267
|
+
frames
|
|
447
268
|
});
|
|
448
269
|
this.animates[id] = animate;
|
|
449
270
|
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
450
|
-
animate.animatedSprite.onComplete =
|
|
271
|
+
animate.animatedSprite.onComplete = () => {
|
|
451
272
|
component.emit('complete');
|
|
452
273
|
};
|
|
453
|
-
animate.animatedSprite.onFrameChange =
|
|
274
|
+
animate.animatedSprite.onFrameChange = () => {
|
|
454
275
|
component.emit('frameChange');
|
|
455
276
|
};
|
|
456
|
-
animate.animatedSprite.onLoop =
|
|
277
|
+
animate.animatedSprite.onLoop = () => {
|
|
457
278
|
component.emit('loop');
|
|
458
279
|
};
|
|
459
280
|
component.animate = this.animates[id];
|
|
@@ -461,20 +282,21 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
461
282
|
if (this.autoPlay[id]) {
|
|
462
283
|
animate.animatedSprite.play();
|
|
463
284
|
}
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
285
|
+
}
|
|
286
|
+
change({
|
|
287
|
+
frames,
|
|
288
|
+
id,
|
|
289
|
+
component
|
|
290
|
+
}) {
|
|
469
291
|
this.remove(id, true);
|
|
470
292
|
this.add({
|
|
471
|
-
frames
|
|
472
|
-
id
|
|
473
|
-
component
|
|
293
|
+
frames,
|
|
294
|
+
id,
|
|
295
|
+
component
|
|
474
296
|
});
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
|
|
297
|
+
}
|
|
298
|
+
remove(id, isChange) {
|
|
299
|
+
const animate = this.animates[id];
|
|
478
300
|
if (!animate) return;
|
|
479
301
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
480
302
|
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
@@ -483,15 +305,14 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
483
305
|
if (!isChange) {
|
|
484
306
|
delete this.autoPlay[id];
|
|
485
307
|
}
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}(pluginRenderer.Renderer);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
311
|
+
SpriteAnimation = __decorate([eva_js.decorators.componentObserver({
|
|
312
|
+
SpriteAnimation: ['speed', 'resource']
|
|
313
|
+
})], SpriteAnimation);
|
|
493
314
|
var SpriteAnimation$1 = SpriteAnimation;
|
|
494
|
-
exports.SpriteAnimation = SpriteAnimation$
|
|
315
|
+
exports.SpriteAnimation = SpriteAnimation$2;
|
|
495
316
|
exports.SpriteAnimationSystem = SpriteAnimation$1;
|
|
496
317
|
Object.defineProperty(exports, '__esModule', {
|
|
497
318
|
value: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},_extends.apply(null,arguments)}window.EVA=window.EVA||{},window.EVA.plugin=window.EVA.plugin||{},window.EVA.plugin.renderer=window.EVA.plugin.renderer||{};var _EVA_IIFE_spriteAnimation=function(e,t,i,n,o){"use strict";function r(e,t,i,n){var o,r=arguments.length,s=r<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(r<3?o(s):r>3?o(t,i,s):o(t,i))||s);return r>3&&s&&Object.defineProperty(t,i,s),s}function s(e,t,i,n){return new(i||(i=Promise))((function(o,r){function s(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))}function a(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function c(e){return function(t,i){var n=a(t,i);n.key=i,n.type=e}}class m 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}init(e){e&&_extends(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(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.currentFrame}get totalFrames(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.totalFrames}}m.componentName="SpriteAnimation",r([c("string")],m.prototype,"resource",void 0),r([c("boolean")],m.prototype,"autoPlay",void 0),r([c("number"),function(e){return function(t,i){a(t,i).step=e}}(10)],m.prototype,"speed",void 0),r([c("boolean")],m.prototype,"forwards",void 0);const d="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,(({name:e,data:t})=>new Promise((i=>{const n=t.json.data,r=t.image instanceof o.Texture?t.image:o.Texture.from(t.image),s=n.frames||{},a=n.animations||{},c={};for(const t in s){c[e+d+t]=s[t]}for(const t in a){const i=[];if(a[t]&&a[t].length>=0)for(const n of a[t]){const t=e+d+n;i.push(t)}a[t]=i}n.frames=c;const m=new o.Spritesheet(r,n);m.parse().then((()=>{const{textures:e}=m,t=[];for(const i in e)t.push(e[i]);i(t)}))})))),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,(({instance:e})=>{if(e)for(const t of e)t.destroy(!0)}));let p=class extends i.Renderer{constructor(){super(...arguments),this.name="SpriteAnimation",this.animates={},this.autoPlay={}}init(){this.renderSystem=this.game.getSystem(i.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)}componentChanged(e){return s(this,void 0,void 0,(function*(){const i=e.gameObject.id;if("SpriteAnimation"===e.componentName){const n=e.component;if(this.autoPlay[e.gameObject.id]=n.autoPlay,e.type===t.OBSERVER_TYPE.ADD){const o=this.increaseAsyncId(i),{instance:r}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,o))return;r||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.add({frames:r,id:e.gameObject.id,component:n})}else if(e.type===t.OBSERVER_TYPE.CHANGE)if(e.prop&&"speed"===e.prop.prop[0])this.animates[e.gameObject.id].speed=1e3/60/n.speed;else{const o=this.increaseAsyncId(i),{instance:r}=yield t.resource.getResource(n.resource);if(!this.validateAsyncId(i,o))return;r||console.error(`GameObject:${e.gameObject.name}'s Img resource load error`),this.change({frames:r,id:e.gameObject.id,component:n})}else e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(i),this.remove(e.gameObject.id))}}))}add({frames:e,id:t,component:i}){const o=new n.SpriteAnimation({frames:e});this.animates[t]=o,this.containerManager.getContainer(t).addChildAt(o.animatedSprite,0),o.animatedSprite.onComplete=()=>{i.emit("complete")},o.animatedSprite.onFrameChange=()=>{i.emit("frameChange")},o.animatedSprite.onLoop=()=>{i.emit("loop")},i.animate=this.animates[t],this.animates[t].speed=1e3/60/i.speed,this.autoPlay[t]&&o.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(),delete this.animates[e],t||delete this.autoPlay[e])}};p.systemName="SpriteAnimation",p=r([t.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],p);var h=p;return e.SpriteAnimation=m,e.SpriteAnimationSystem=h,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);window.EVA.plugin.renderer.spriteAnimation=window.EVA.plugin.renderer.spriteAnimation||_EVA_IIFE_spriteAnimation;
|