@eva/plugin-renderer-sprite-animation 1.1.1-fix.2 → 1.1.1-fix.3
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 +360 -615
- package/dist/EVA.plugin.renderer.spriteAnimation.js.map +1 -0
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js +0 -1
- package/dist/plugin-renderer-sprite-animation.cjs.js +7 -50
- package/dist/plugin-renderer-sprite-animation.cjs.js.map +1 -0
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js +0 -1
- package/dist/plugin-renderer-sprite-animation.esm.js +8 -51
- package/dist/plugin-renderer-sprite-animation.esm.js.map +1 -0
- package/package.json +4 -4
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js.map +0 -1
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js.map +0 -1
|
@@ -1,617 +1,362 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
d;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
next: verb(0),
|
|
92
|
-
"throw": verb(1),
|
|
93
|
-
"return": verb(2)
|
|
94
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
95
|
-
return this;
|
|
96
|
-
}), g;
|
|
97
|
-
|
|
98
|
-
function verb(n) {
|
|
99
|
-
return function (v) {
|
|
100
|
-
return step([n, v]);
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function step(op) {
|
|
105
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
106
|
-
|
|
107
|
-
while (_) {
|
|
108
|
-
try {
|
|
109
|
-
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;
|
|
110
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
111
|
-
|
|
112
|
-
switch (op[0]) {
|
|
113
|
-
case 0:
|
|
114
|
-
case 1:
|
|
115
|
-
t = op;
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case 4:
|
|
119
|
-
_.label++;
|
|
120
|
-
return {
|
|
121
|
-
value: op[1],
|
|
122
|
-
done: false
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
case 5:
|
|
126
|
-
_.label++;
|
|
127
|
-
y = op[1];
|
|
128
|
-
op = [0];
|
|
129
|
-
continue;
|
|
130
|
-
|
|
131
|
-
case 7:
|
|
132
|
-
op = _.ops.pop();
|
|
133
|
-
|
|
134
|
-
_.trys.pop();
|
|
135
|
-
|
|
136
|
-
continue;
|
|
137
|
-
|
|
138
|
-
default:
|
|
139
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
140
|
-
_ = 0;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
145
|
-
_.label = op[1];
|
|
146
|
-
break;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
150
|
-
_.label = t[1];
|
|
151
|
-
t = op;
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (t && _.label < t[2]) {
|
|
156
|
-
_.label = t[2];
|
|
157
|
-
|
|
158
|
-
_.ops.push(op);
|
|
159
|
-
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (t[2]) _.ops.pop();
|
|
164
|
-
|
|
165
|
-
_.trys.pop();
|
|
166
|
-
|
|
167
|
-
continue;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
op = body.call(thisArg, _);
|
|
171
|
-
} catch (e) {
|
|
172
|
-
op = [6, e];
|
|
173
|
-
y = 0;
|
|
174
|
-
} finally {
|
|
175
|
-
f = t = 0;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (op[0] & 5) throw op[1];
|
|
180
|
-
return {
|
|
181
|
-
value: op[0] ? op[1] : void 0,
|
|
182
|
-
done: true
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function __values(o) {
|
|
188
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
189
|
-
m = s && o[s],
|
|
190
|
-
i = 0;
|
|
191
|
-
if (m) return m.call(o);
|
|
192
|
-
if (o && typeof o.length === "number") return {
|
|
193
|
-
next: function next() {
|
|
194
|
-
if (o && i >= o.length) o = void 0;
|
|
195
|
-
return {
|
|
196
|
-
value: o && o[i++],
|
|
197
|
-
done: !o
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
205
|
-
if (!target.constructor.IDEProps) {
|
|
206
|
-
target.constructor.IDEProps = {};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (!target.constructor.IDEProps[propertyKey]) {
|
|
210
|
-
target.constructor.IDEProps[propertyKey] = {};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
214
|
-
return propertyObj;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function type(type) {
|
|
218
|
-
return function (target, propertyKey) {
|
|
219
|
-
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
220
|
-
prop.key = propertyKey;
|
|
221
|
-
prop.type = type;
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function step(step) {
|
|
226
|
-
return function (target, propertyKey) {
|
|
227
|
-
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
228
|
-
prop.step = step;
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
var SpriteAnimation$2 = function (_super) {
|
|
233
|
-
__extends(SpriteAnimation, _super);
|
|
234
|
-
|
|
235
|
-
function SpriteAnimation() {
|
|
236
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
237
|
-
|
|
238
|
-
_this.resource = '';
|
|
239
|
-
_this.autoPlay = true;
|
|
240
|
-
_this.speed = 100;
|
|
241
|
-
_this.forwards = false;
|
|
242
|
-
_this.waitPlay = false;
|
|
243
|
-
_this.waitStop = false;
|
|
244
|
-
_this.times = Infinity;
|
|
245
|
-
_this.count = 0;
|
|
246
|
-
_this.complete = false;
|
|
247
|
-
return _this;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
SpriteAnimation.prototype.init = function (obj) {
|
|
251
|
-
var _this = this;
|
|
252
|
-
|
|
253
|
-
obj && _extends(this, obj);
|
|
254
|
-
this.on('loop', function () {
|
|
255
|
-
if (++_this.count >= _this.times) {
|
|
256
|
-
if (_this.forwards) {
|
|
257
|
-
_this.gotoAndStop(_this.totalFrames - 1);
|
|
258
|
-
} else {
|
|
259
|
-
_this.animate.stop();
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
_this.complete = true;
|
|
263
|
-
|
|
264
|
-
_this.emit('complete');
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
SpriteAnimation.prototype.play = function (times) {
|
|
270
|
-
if (times === void 0) {
|
|
271
|
-
times = Infinity;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (times === 0) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
this.times = times;
|
|
279
|
-
|
|
280
|
-
if (!this.animate) {
|
|
281
|
-
this.waitPlay = true;
|
|
282
|
-
} else {
|
|
283
|
-
if (this.complete) {
|
|
284
|
-
this.gotoAndStop(0);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
this.animate.play();
|
|
288
|
-
this.count = 0;
|
|
289
|
-
this.complete = false;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
SpriteAnimation.prototype.stop = function () {
|
|
294
|
-
if (!this.animate) {
|
|
295
|
-
this.waitStop = true;
|
|
296
|
-
} else {
|
|
297
|
-
this.animate.stop();
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
302
|
-
get: function get() {
|
|
303
|
-
return this._animate;
|
|
304
|
-
},
|
|
305
|
-
set: function set(val) {
|
|
306
|
-
this._animate = val;
|
|
307
|
-
|
|
308
|
-
if (this.waitPlay) {
|
|
309
|
-
this.waitPlay = false;
|
|
310
|
-
this.play(this.times);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (this.waitStop) {
|
|
314
|
-
this.waitStop = false;
|
|
315
|
-
this.stop();
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
enumerable: false,
|
|
319
|
-
configurable: true
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
323
|
-
this.animate.gotoAndPlay(frameNumber);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
327
|
-
this.animate.gotoAndStop(frameNumber);
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
|
|
331
|
-
get: function get() {
|
|
332
|
-
var _a, _b;
|
|
333
|
-
|
|
334
|
-
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
335
|
-
},
|
|
336
|
-
enumerable: false,
|
|
337
|
-
configurable: true
|
|
338
|
-
});
|
|
339
|
-
Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
|
|
340
|
-
get: function get() {
|
|
341
|
-
var _a, _b;
|
|
342
|
-
|
|
343
|
-
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
344
|
-
},
|
|
345
|
-
enumerable: false,
|
|
346
|
-
configurable: true
|
|
347
|
-
});
|
|
348
|
-
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
349
|
-
|
|
350
|
-
__decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
|
|
351
|
-
|
|
352
|
-
__decorate([type('boolean')], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
353
|
-
|
|
354
|
-
__decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
|
|
355
|
-
|
|
356
|
-
__decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
|
|
357
|
-
|
|
358
|
-
return SpriteAnimation;
|
|
359
|
-
}(eva_js.Component);
|
|
360
|
-
|
|
361
|
-
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
362
|
-
var resourceKeySplit = '_s|r|c_';
|
|
363
|
-
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
364
|
-
var name = _a.name,
|
|
365
|
-
data = _a.data;
|
|
366
|
-
return new Promise(function (r) {
|
|
367
|
-
var e_1, _a;
|
|
368
|
-
|
|
369
|
-
var textureObj = data.json;
|
|
370
|
-
var texture = pixi_js.BaseTexture.from(data.image);
|
|
371
|
-
var frames = textureObj.frames || {};
|
|
372
|
-
var animations = textureObj.animations || {};
|
|
373
|
-
var newFrames = {};
|
|
374
|
-
|
|
375
|
-
for (var key in frames) {
|
|
376
|
-
var newKey = name + resourceKeySplit + key;
|
|
377
|
-
newFrames[newKey] = frames[key];
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
for (var key in animations) {
|
|
381
|
-
var spriteList = [];
|
|
382
|
-
|
|
383
|
-
if (animations[key] && animations[key].length >= 0) {
|
|
384
|
-
try {
|
|
385
|
-
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
386
|
-
var spriteName = _c.value;
|
|
387
|
-
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
388
|
-
spriteList.push(newSpriteName);
|
|
389
|
-
}
|
|
390
|
-
} catch (e_1_1) {
|
|
391
|
-
e_1 = {
|
|
392
|
-
error: e_1_1
|
|
393
|
-
};
|
|
394
|
-
} finally {
|
|
395
|
-
try {
|
|
396
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
397
|
-
} finally {
|
|
398
|
-
if (e_1) throw e_1.error;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
animations[key] = spriteList;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
textureObj.frames = newFrames;
|
|
407
|
-
var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
408
|
-
spriteSheet.parse(function () {
|
|
409
|
-
var textures = spriteSheet.textures;
|
|
410
|
-
var spriteFrames = [];
|
|
411
|
-
|
|
412
|
-
for (var key in textures) {
|
|
413
|
-
spriteFrames.push(textures[key]);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
r(spriteFrames);
|
|
417
|
-
});
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
421
|
-
var e_2, _b;
|
|
422
|
-
|
|
423
|
-
var instance = _a.instance;
|
|
424
|
-
if (!instance) return;
|
|
425
|
-
|
|
426
|
-
try {
|
|
427
|
-
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
428
|
-
var texture = instance_1_1.value;
|
|
429
|
-
texture.destroy(true);
|
|
430
|
-
}
|
|
431
|
-
} catch (e_2_1) {
|
|
432
|
-
e_2 = {
|
|
433
|
-
error: e_2_1
|
|
434
|
-
};
|
|
435
|
-
} finally {
|
|
436
|
-
try {
|
|
437
|
-
if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
|
|
438
|
-
} finally {
|
|
439
|
-
if (e_2) throw e_2.error;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
|
|
444
|
-
var SpriteAnimation = function (_super) {
|
|
445
|
-
__extends(SpriteAnimation, _super);
|
|
446
|
-
|
|
447
|
-
function SpriteAnimation() {
|
|
448
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
449
|
-
|
|
450
|
-
_this.name = 'SpriteAnimation';
|
|
451
|
-
_this.animates = {};
|
|
452
|
-
_this.autoPlay = {};
|
|
453
|
-
return _this;
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js'), require('@eva/plugin-renderer'), require('@eva/renderer-adapter'), require('pixi.js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@eva/eva.js', '@eva/plugin-renderer', '@eva/renderer-adapter', 'pixi.js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.renderer = global.EVA.plugin.renderer || {}, global.EVA.plugin.renderer.spriteAnimation = {}), global.EVA, global.EVA.plugin.renderer, global.EVA.rendererAdapter, global.PIXI));
|
|
5
|
+
}(this, (function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) { 'use strict';
|
|
6
|
+
|
|
7
|
+
/*! *****************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise */
|
|
22
|
+
|
|
23
|
+
var extendStatics = function(d, b) {
|
|
24
|
+
extendStatics = Object.setPrototypeOf ||
|
|
25
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
+
return extendStatics(d, b);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function __extends(d, b) {
|
|
31
|
+
extendStatics(d, b);
|
|
32
|
+
function __() { this.constructor = d; }
|
|
33
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function __decorate(decorators, target, key, desc) {
|
|
37
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
38
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
39
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
40
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
44
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
45
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
46
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
47
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
48
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
49
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function __generator(thisArg, body) {
|
|
54
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
55
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
56
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
|
+
function step(op) {
|
|
58
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
59
|
+
while (_) try {
|
|
60
|
+
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;
|
|
61
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
62
|
+
switch (op[0]) {
|
|
63
|
+
case 0: case 1: t = op; break;
|
|
64
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
65
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
66
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
67
|
+
default:
|
|
68
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
69
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
70
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
71
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
72
|
+
if (t[2]) _.ops.pop();
|
|
73
|
+
_.trys.pop(); continue;
|
|
74
|
+
}
|
|
75
|
+
op = body.call(thisArg, _);
|
|
76
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
77
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function __values(o) {
|
|
82
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
83
|
+
if (m) return m.call(o);
|
|
84
|
+
if (o && typeof o.length === "number") return {
|
|
85
|
+
next: function () {
|
|
86
|
+
if (o && i >= o.length) o = void 0;
|
|
87
|
+
return { value: o && o[i++], done: !o };
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
454
91
|
}
|
|
455
92
|
|
|
456
|
-
SpriteAnimation
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
};
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
93
|
+
var SpriteAnimation$2 = (function (_super) {
|
|
94
|
+
__extends(SpriteAnimation, _super);
|
|
95
|
+
function SpriteAnimation() {
|
|
96
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
97
|
+
_this.resource = '';
|
|
98
|
+
_this.autoPlay = true;
|
|
99
|
+
_this.speed = 100;
|
|
100
|
+
_this.waitPlay = false;
|
|
101
|
+
_this.waitStop = false;
|
|
102
|
+
_this.times = Infinity;
|
|
103
|
+
_this.count = 0;
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
SpriteAnimation.prototype.init = function (obj) {
|
|
107
|
+
var _this = this;
|
|
108
|
+
obj && Object.assign(this, obj);
|
|
109
|
+
this.on('loop', function () {
|
|
110
|
+
if (++_this.count >= _this.times) {
|
|
111
|
+
_this.animate.stop();
|
|
112
|
+
_this.emit('complete');
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
SpriteAnimation.prototype.play = function (times) {
|
|
117
|
+
if (times === void 0) { times = Infinity; }
|
|
118
|
+
if (times === 0) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this.times = times;
|
|
122
|
+
if (!this.animate) {
|
|
123
|
+
this.waitPlay = true;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.animate.play();
|
|
127
|
+
this.count = 0;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
SpriteAnimation.prototype.stop = function () {
|
|
131
|
+
if (!this.animate) {
|
|
132
|
+
this.waitStop = true;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.animate.stop();
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
139
|
+
get: function () {
|
|
140
|
+
return this._animate;
|
|
141
|
+
},
|
|
142
|
+
set: function (val) {
|
|
143
|
+
this._animate = val;
|
|
144
|
+
if (this.waitPlay) {
|
|
145
|
+
this.waitPlay = false;
|
|
146
|
+
this.play(this.times);
|
|
147
|
+
}
|
|
148
|
+
if (this.waitStop) {
|
|
149
|
+
this.waitStop = false;
|
|
150
|
+
this.stop();
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
enumerable: false,
|
|
154
|
+
configurable: true
|
|
155
|
+
});
|
|
156
|
+
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
157
|
+
this.animate.gotoAndPlay(frameNumber);
|
|
158
|
+
};
|
|
159
|
+
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
160
|
+
this.animate.gotoAndStop(frameNumber);
|
|
161
|
+
};
|
|
162
|
+
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
163
|
+
__decorate([
|
|
164
|
+
eva_js.decorators.IDEProp
|
|
165
|
+
], SpriteAnimation.prototype, "resource", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
eva_js.decorators.IDEProp
|
|
168
|
+
], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
169
|
+
__decorate([
|
|
170
|
+
eva_js.decorators.IDEProp
|
|
171
|
+
], SpriteAnimation.prototype, "speed", void 0);
|
|
172
|
+
return SpriteAnimation;
|
|
173
|
+
}(eva_js.Component));
|
|
174
|
+
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
175
|
+
|
|
176
|
+
var resourceKeySplit = '_s|r|c_';
|
|
177
|
+
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
178
|
+
var name = _a.name, data = _a.data;
|
|
179
|
+
return new Promise(function (r) {
|
|
180
|
+
var e_1, _a;
|
|
181
|
+
var textureObj = data.json;
|
|
182
|
+
var texture = pixi_js.BaseTexture.from(data.image);
|
|
183
|
+
var frames = textureObj.frames || {};
|
|
184
|
+
var animations = textureObj.animations || {};
|
|
185
|
+
var newFrames = {};
|
|
186
|
+
for (var key in frames) {
|
|
187
|
+
var newKey = name + resourceKeySplit + key;
|
|
188
|
+
newFrames[newKey] = frames[key];
|
|
189
|
+
}
|
|
190
|
+
for (var key in animations) {
|
|
191
|
+
var spriteList = [];
|
|
192
|
+
if (animations[key] && animations[key].length >= 0) {
|
|
193
|
+
try {
|
|
194
|
+
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
195
|
+
var spriteName = _c.value;
|
|
196
|
+
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
197
|
+
spriteList.push(newSpriteName);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
201
|
+
finally {
|
|
202
|
+
try {
|
|
203
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
204
|
+
}
|
|
205
|
+
finally { if (e_1) throw e_1.error; }
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
animations[key] = spriteList;
|
|
209
|
+
}
|
|
210
|
+
textureObj.frames = newFrames;
|
|
211
|
+
var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
212
|
+
spriteSheet.parse(function () {
|
|
213
|
+
var textures = spriteSheet.textures;
|
|
214
|
+
var spriteFrames = [];
|
|
215
|
+
for (var key in textures) {
|
|
216
|
+
spriteFrames.push(textures[key]);
|
|
217
|
+
}
|
|
218
|
+
r(spriteFrames);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
223
|
+
var e_2, _b;
|
|
224
|
+
var instance = _a.instance;
|
|
225
|
+
if (!instance)
|
|
226
|
+
return;
|
|
227
|
+
try {
|
|
228
|
+
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
229
|
+
var texture = instance_1_1.value;
|
|
230
|
+
texture.destroy(true);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
234
|
+
finally {
|
|
235
|
+
try {
|
|
236
|
+
if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
|
|
237
|
+
}
|
|
238
|
+
finally { if (e_2) throw e_2.error; }
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
var SpriteAnimation = (function (_super) {
|
|
242
|
+
__extends(SpriteAnimation, _super);
|
|
243
|
+
function SpriteAnimation() {
|
|
244
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
245
|
+
_this.name = 'SpriteAnimation';
|
|
246
|
+
_this.animates = {};
|
|
247
|
+
_this.autoPlay = {};
|
|
248
|
+
return _this;
|
|
249
|
+
}
|
|
250
|
+
SpriteAnimation.prototype.init = function () {
|
|
251
|
+
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
252
|
+
this.renderSystem.rendererManager.register(this);
|
|
253
|
+
};
|
|
254
|
+
SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
|
|
255
|
+
var _a = gameObject.transform.size, width = _a.width, height = _a.height;
|
|
256
|
+
if (this.animates[gameObject.id]) {
|
|
257
|
+
this.animates[gameObject.id].animatedSprite.width = width;
|
|
258
|
+
this.animates[gameObject.id].animatedSprite.height = height;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
+
var component, frames_1, frames_2;
|
|
264
|
+
return __generator(this, function (_a) {
|
|
265
|
+
switch (_a.label) {
|
|
266
|
+
case 0:
|
|
267
|
+
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
268
|
+
component = changed.component;
|
|
269
|
+
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
270
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
271
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
272
|
+
case 1:
|
|
273
|
+
frames_1 = (_a.sent()).instance;
|
|
274
|
+
if (!frames_1) {
|
|
275
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
276
|
+
}
|
|
277
|
+
this.add({
|
|
278
|
+
frames: frames_1,
|
|
279
|
+
id: changed.gameObject.id,
|
|
280
|
+
component: component,
|
|
281
|
+
});
|
|
282
|
+
return [3, 7];
|
|
283
|
+
case 2:
|
|
284
|
+
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
285
|
+
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
286
|
+
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
287
|
+
return [3, 5];
|
|
288
|
+
case 3: return [4, eva_js.resource.getResource(component.resource)];
|
|
289
|
+
case 4:
|
|
290
|
+
frames_2 = (_a.sent()).instance;
|
|
291
|
+
if (!frames_2) {
|
|
292
|
+
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
293
|
+
}
|
|
294
|
+
this.change({
|
|
295
|
+
frames: frames_2,
|
|
296
|
+
id: changed.gameObject.id,
|
|
297
|
+
component: component,
|
|
298
|
+
});
|
|
299
|
+
_a.label = 5;
|
|
300
|
+
case 5: return [3, 7];
|
|
301
|
+
case 6:
|
|
302
|
+
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
303
|
+
this.remove(changed.gameObject.id);
|
|
304
|
+
}
|
|
305
|
+
_a.label = 7;
|
|
306
|
+
case 7: return [2];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
SpriteAnimation.prototype.add = function (_a) {
|
|
312
|
+
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
313
|
+
var animate = new rendererAdapter.SpriteAnimation({ frames: frames });
|
|
314
|
+
this.animates[id] = animate;
|
|
315
|
+
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
316
|
+
animate.animatedSprite.onComplete = function () {
|
|
317
|
+
component.emit('complete');
|
|
318
|
+
};
|
|
319
|
+
animate.animatedSprite.onFrameChange = function () {
|
|
320
|
+
component.emit('frameChange');
|
|
321
|
+
};
|
|
322
|
+
animate.animatedSprite.onLoop = function () {
|
|
323
|
+
component.emit('loop');
|
|
324
|
+
};
|
|
325
|
+
component.animate = this.animates[id];
|
|
326
|
+
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
327
|
+
if (this.autoPlay[id]) {
|
|
328
|
+
animate.animatedSprite.play();
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
SpriteAnimation.prototype.change = function (_a) {
|
|
332
|
+
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
333
|
+
this.remove(id, true);
|
|
334
|
+
this.add({ frames: frames, id: id, component: component });
|
|
335
|
+
};
|
|
336
|
+
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
337
|
+
var animate = this.animates[id];
|
|
338
|
+
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
339
|
+
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
340
|
+
animate.animatedSprite.destroy({ children: true });
|
|
341
|
+
delete this.animates[id];
|
|
342
|
+
if (!isChange) {
|
|
343
|
+
delete this.autoPlay[id];
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
347
|
+
SpriteAnimation = __decorate([
|
|
348
|
+
eva_js.decorators.componentObserver({
|
|
349
|
+
SpriteAnimation: ['speed', 'resource'],
|
|
350
|
+
})
|
|
351
|
+
], SpriteAnimation);
|
|
352
|
+
return SpriteAnimation;
|
|
353
|
+
}(pluginRenderer.Renderer));
|
|
354
|
+
var SpriteAnimation$1 = SpriteAnimation;
|
|
355
|
+
|
|
356
|
+
exports.SpriteAnimation = SpriteAnimation$3;
|
|
357
|
+
exports.SpriteAnimationSystem = SpriteAnimation$1;
|
|
358
|
+
|
|
359
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
360
|
+
|
|
361
|
+
})));
|
|
362
|
+
//# sourceMappingURL=EVA.plugin.renderer.spriteAnimation.js.map
|