@eva/plugin-renderer-sprite-animation 1.2.7-fix.4 → 1.2.7-fix.6
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 +130 -23
- package/dist/EVA.plugin.renderer.spriteAnimation.js.map +1 -0
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js +1 -1
- package/dist/miniprogram.js +76 -8
- package/dist/plugin-renderer-sprite-animation.cjs.js.map +1 -0
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js +1 -1
- package/dist/plugin-renderer-sprite-animation.esm.js.map +1 -0
- package/package.json +4 -4
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
2
3
|
window.EVA = window.EVA || {};
|
|
3
4
|
window.EVA.plugin = window.EVA.plugin || {};
|
|
4
5
|
window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
|
|
6
|
+
|
|
5
7
|
var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
|
|
6
8
|
'use strict';
|
|
7
9
|
|
|
@@ -15,30 +17,37 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
15
17
|
if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
16
18
|
}
|
|
17
19
|
};
|
|
20
|
+
|
|
18
21
|
return _extendStatics(d, b);
|
|
19
22
|
};
|
|
23
|
+
|
|
20
24
|
function __extends(d, b) {
|
|
21
25
|
_extendStatics(d, b);
|
|
26
|
+
|
|
22
27
|
function __() {
|
|
23
28
|
this.constructor = d;
|
|
24
29
|
}
|
|
30
|
+
|
|
25
31
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
26
32
|
}
|
|
33
|
+
|
|
27
34
|
function __decorate(decorators, target, key, desc) {
|
|
28
35
|
var c = arguments.length,
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
37
|
+
d;
|
|
31
38
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
|
|
32
39
|
if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
33
40
|
}
|
|
34
41
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
35
42
|
}
|
|
43
|
+
|
|
36
44
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
37
45
|
function adopt(value) {
|
|
38
46
|
return value instanceof P ? value : new P(function (resolve) {
|
|
39
47
|
resolve(value);
|
|
40
48
|
});
|
|
41
49
|
}
|
|
50
|
+
|
|
42
51
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
52
|
function fulfilled(value) {
|
|
44
53
|
try {
|
|
@@ -47,6 +56,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
47
56
|
reject(e);
|
|
48
57
|
}
|
|
49
58
|
}
|
|
59
|
+
|
|
50
60
|
function rejected(value) {
|
|
51
61
|
try {
|
|
52
62
|
step(generator["throw"](value));
|
|
@@ -54,26 +64,29 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
54
64
|
reject(e);
|
|
55
65
|
}
|
|
56
66
|
}
|
|
67
|
+
|
|
57
68
|
function step(result) {
|
|
58
69
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
59
70
|
}
|
|
71
|
+
|
|
60
72
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61
73
|
});
|
|
62
74
|
}
|
|
75
|
+
|
|
63
76
|
function __generator(thisArg, body) {
|
|
64
77
|
var _ = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
trys: [],
|
|
71
|
-
ops: []
|
|
78
|
+
label: 0,
|
|
79
|
+
sent: function sent() {
|
|
80
|
+
if (t[0] & 1) throw t[1];
|
|
81
|
+
return t[1];
|
|
72
82
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
trys: [],
|
|
84
|
+
ops: []
|
|
85
|
+
},
|
|
86
|
+
f,
|
|
87
|
+
y,
|
|
88
|
+
t,
|
|
89
|
+
g;
|
|
77
90
|
return g = {
|
|
78
91
|
next: verb(0),
|
|
79
92
|
"throw": verb(1),
|
|
@@ -81,60 +94,79 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
81
94
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
82
95
|
return this;
|
|
83
96
|
}), g;
|
|
97
|
+
|
|
84
98
|
function verb(n) {
|
|
85
99
|
return function (v) {
|
|
86
100
|
return step([n, v]);
|
|
87
101
|
};
|
|
88
102
|
}
|
|
103
|
+
|
|
89
104
|
function step(op) {
|
|
90
105
|
if (f) throw new TypeError("Generator is already executing.");
|
|
106
|
+
|
|
91
107
|
while (_) {
|
|
92
108
|
try {
|
|
93
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;
|
|
94
110
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
111
|
+
|
|
95
112
|
switch (op[0]) {
|
|
96
113
|
case 0:
|
|
97
114
|
case 1:
|
|
98
115
|
t = op;
|
|
99
116
|
break;
|
|
117
|
+
|
|
100
118
|
case 4:
|
|
101
119
|
_.label++;
|
|
102
120
|
return {
|
|
103
121
|
value: op[1],
|
|
104
122
|
done: false
|
|
105
123
|
};
|
|
124
|
+
|
|
106
125
|
case 5:
|
|
107
126
|
_.label++;
|
|
108
127
|
y = op[1];
|
|
109
128
|
op = [0];
|
|
110
129
|
continue;
|
|
130
|
+
|
|
111
131
|
case 7:
|
|
112
132
|
op = _.ops.pop();
|
|
133
|
+
|
|
113
134
|
_.trys.pop();
|
|
135
|
+
|
|
114
136
|
continue;
|
|
137
|
+
|
|
115
138
|
default:
|
|
116
139
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
117
140
|
_ = 0;
|
|
118
141
|
continue;
|
|
119
142
|
}
|
|
143
|
+
|
|
120
144
|
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
121
145
|
_.label = op[1];
|
|
122
146
|
break;
|
|
123
147
|
}
|
|
148
|
+
|
|
124
149
|
if (op[0] === 6 && _.label < t[1]) {
|
|
125
150
|
_.label = t[1];
|
|
126
151
|
t = op;
|
|
127
152
|
break;
|
|
128
153
|
}
|
|
154
|
+
|
|
129
155
|
if (t && _.label < t[2]) {
|
|
130
156
|
_.label = t[2];
|
|
157
|
+
|
|
131
158
|
_.ops.push(op);
|
|
159
|
+
|
|
132
160
|
break;
|
|
133
161
|
}
|
|
162
|
+
|
|
134
163
|
if (t[2]) _.ops.pop();
|
|
164
|
+
|
|
135
165
|
_.trys.pop();
|
|
166
|
+
|
|
136
167
|
continue;
|
|
137
168
|
}
|
|
169
|
+
|
|
138
170
|
op = body.call(thisArg, _);
|
|
139
171
|
} catch (e) {
|
|
140
172
|
op = [6, e];
|
|
@@ -143,6 +175,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
143
175
|
f = t = 0;
|
|
144
176
|
}
|
|
145
177
|
}
|
|
178
|
+
|
|
146
179
|
if (op[0] & 5) throw op[1];
|
|
147
180
|
return {
|
|
148
181
|
value: op[0] ? op[1] : void 0,
|
|
@@ -150,10 +183,11 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
150
183
|
};
|
|
151
184
|
}
|
|
152
185
|
}
|
|
186
|
+
|
|
153
187
|
function __values(o) {
|
|
154
188
|
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
155
|
-
|
|
156
|
-
|
|
189
|
+
m = s && o[s],
|
|
190
|
+
i = 0;
|
|
157
191
|
if (m) return m.call(o);
|
|
158
192
|
if (o && typeof o.length === "number") return {
|
|
159
193
|
next: function next() {
|
|
@@ -166,16 +200,20 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
166
200
|
};
|
|
167
201
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
168
202
|
}
|
|
203
|
+
|
|
169
204
|
function getIDEPropsPropertyObj(target, propertyKey) {
|
|
170
205
|
if (!target.constructor.IDEProps) {
|
|
171
206
|
target.constructor.IDEProps = {};
|
|
172
207
|
}
|
|
208
|
+
|
|
173
209
|
if (!target.constructor.IDEProps[propertyKey]) {
|
|
174
210
|
target.constructor.IDEProps[propertyKey] = {};
|
|
175
211
|
}
|
|
212
|
+
|
|
176
213
|
var propertyObj = target.constructor.IDEProps[propertyKey];
|
|
177
214
|
return propertyObj;
|
|
178
215
|
}
|
|
216
|
+
|
|
179
217
|
function type(type) {
|
|
180
218
|
return function (target, propertyKey) {
|
|
181
219
|
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
@@ -183,16 +221,20 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
183
221
|
prop.type = type;
|
|
184
222
|
};
|
|
185
223
|
}
|
|
224
|
+
|
|
186
225
|
function step(step) {
|
|
187
226
|
return function (target, propertyKey) {
|
|
188
227
|
var prop = getIDEPropsPropertyObj(target, propertyKey);
|
|
189
228
|
prop.step = step;
|
|
190
229
|
};
|
|
191
230
|
}
|
|
231
|
+
|
|
192
232
|
var SpriteAnimation$2 = function (_super) {
|
|
193
233
|
__extends(SpriteAnimation, _super);
|
|
234
|
+
|
|
194
235
|
function SpriteAnimation() {
|
|
195
236
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
237
|
+
|
|
196
238
|
_this.resource = '';
|
|
197
239
|
_this.autoPlay = true;
|
|
198
240
|
_this.speed = 100;
|
|
@@ -204,8 +246,10 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
204
246
|
_this.complete = false;
|
|
205
247
|
return _this;
|
|
206
248
|
}
|
|
249
|
+
|
|
207
250
|
SpriteAnimation.prototype.init = function (obj) {
|
|
208
251
|
var _this = this;
|
|
252
|
+
|
|
209
253
|
obj && _extends(this, obj);
|
|
210
254
|
this.on('loop', function () {
|
|
211
255
|
if (++_this.count >= _this.times) {
|
|
@@ -214,30 +258,38 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
214
258
|
} else {
|
|
215
259
|
_this.animate.stop();
|
|
216
260
|
}
|
|
261
|
+
|
|
217
262
|
_this.complete = true;
|
|
263
|
+
|
|
218
264
|
_this.emit('complete');
|
|
219
265
|
}
|
|
220
266
|
});
|
|
221
267
|
};
|
|
268
|
+
|
|
222
269
|
SpriteAnimation.prototype.play = function (times) {
|
|
223
270
|
if (times === void 0) {
|
|
224
271
|
times = Infinity;
|
|
225
272
|
}
|
|
273
|
+
|
|
226
274
|
if (times === 0) {
|
|
227
275
|
return;
|
|
228
276
|
}
|
|
277
|
+
|
|
229
278
|
this.times = times;
|
|
279
|
+
|
|
230
280
|
if (!this.animate) {
|
|
231
281
|
this.waitPlay = true;
|
|
232
282
|
} else {
|
|
233
283
|
if (this.complete) {
|
|
234
284
|
this.gotoAndStop(0);
|
|
235
285
|
}
|
|
286
|
+
|
|
236
287
|
this.animate.play();
|
|
237
288
|
this.count = 0;
|
|
238
289
|
this.complete = false;
|
|
239
290
|
}
|
|
240
291
|
};
|
|
292
|
+
|
|
241
293
|
SpriteAnimation.prototype.stop = function () {
|
|
242
294
|
if (!this.animate) {
|
|
243
295
|
this.waitStop = true;
|
|
@@ -245,16 +297,19 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
245
297
|
this.animate.stop();
|
|
246
298
|
}
|
|
247
299
|
};
|
|
300
|
+
|
|
248
301
|
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
249
302
|
get: function get() {
|
|
250
303
|
return this._animate;
|
|
251
304
|
},
|
|
252
305
|
set: function set(val) {
|
|
253
306
|
this._animate = val;
|
|
307
|
+
|
|
254
308
|
if (this.waitPlay) {
|
|
255
309
|
this.waitPlay = false;
|
|
256
310
|
this.play(this.times);
|
|
257
311
|
}
|
|
312
|
+
|
|
258
313
|
if (this.waitStop) {
|
|
259
314
|
this.waitStop = false;
|
|
260
315
|
this.stop();
|
|
@@ -263,15 +318,19 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
263
318
|
enumerable: false,
|
|
264
319
|
configurable: true
|
|
265
320
|
});
|
|
321
|
+
|
|
266
322
|
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
267
323
|
this.animate.gotoAndPlay(frameNumber);
|
|
268
324
|
};
|
|
325
|
+
|
|
269
326
|
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
270
327
|
this.animate.gotoAndStop(frameNumber);
|
|
271
328
|
};
|
|
329
|
+
|
|
272
330
|
Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
|
|
273
331
|
get: function get() {
|
|
274
332
|
var _a, _b;
|
|
333
|
+
|
|
275
334
|
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
276
335
|
},
|
|
277
336
|
enumerable: false,
|
|
@@ -280,36 +339,47 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
280
339
|
Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
|
|
281
340
|
get: function get() {
|
|
282
341
|
var _a, _b;
|
|
342
|
+
|
|
283
343
|
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
284
344
|
},
|
|
285
345
|
enumerable: false,
|
|
286
346
|
configurable: true
|
|
287
347
|
});
|
|
288
348
|
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
349
|
+
|
|
289
350
|
__decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
|
|
351
|
+
|
|
290
352
|
__decorate([type('boolean')], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
353
|
+
|
|
291
354
|
__decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
|
|
355
|
+
|
|
292
356
|
__decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
|
|
357
|
+
|
|
293
358
|
return SpriteAnimation;
|
|
294
359
|
}(eva_js.Component);
|
|
360
|
+
|
|
295
361
|
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
296
362
|
var resourceKeySplit = '_s|r|c_';
|
|
297
363
|
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
298
364
|
var name = _a.name,
|
|
299
|
-
|
|
365
|
+
data = _a.data;
|
|
300
366
|
return new Promise(function (r) {
|
|
301
367
|
var e_1, _a;
|
|
368
|
+
|
|
302
369
|
var textureObj = data.json;
|
|
303
370
|
var texture = pixi_js.BaseTexture.from(data.image);
|
|
304
371
|
var frames = textureObj.frames || {};
|
|
305
372
|
var animations = textureObj.animations || {};
|
|
306
373
|
var newFrames = {};
|
|
374
|
+
|
|
307
375
|
for (var key in frames) {
|
|
308
376
|
var newKey = name + resourceKeySplit + key;
|
|
309
377
|
newFrames[newKey] = frames[key];
|
|
310
378
|
}
|
|
379
|
+
|
|
311
380
|
for (var key in animations) {
|
|
312
381
|
var spriteList = [];
|
|
382
|
+
|
|
313
383
|
if (animations[key] && animations[key].length >= 0) {
|
|
314
384
|
try {
|
|
315
385
|
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -329,24 +399,30 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
329
399
|
}
|
|
330
400
|
}
|
|
331
401
|
}
|
|
402
|
+
|
|
332
403
|
animations[key] = spriteList;
|
|
333
404
|
}
|
|
405
|
+
|
|
334
406
|
textureObj.frames = newFrames;
|
|
335
407
|
var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
336
408
|
spriteSheet.parse(function () {
|
|
337
409
|
var textures = spriteSheet.textures;
|
|
338
410
|
var spriteFrames = [];
|
|
411
|
+
|
|
339
412
|
for (var key in textures) {
|
|
340
413
|
spriteFrames.push(textures[key]);
|
|
341
414
|
}
|
|
415
|
+
|
|
342
416
|
r(spriteFrames);
|
|
343
417
|
});
|
|
344
418
|
});
|
|
345
419
|
});
|
|
346
420
|
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
347
421
|
var e_2, _b;
|
|
422
|
+
|
|
348
423
|
var instance = _a.instance;
|
|
349
424
|
if (!instance) return;
|
|
425
|
+
|
|
350
426
|
try {
|
|
351
427
|
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
352
428
|
var texture = instance_1_1.value;
|
|
@@ -364,28 +440,35 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
364
440
|
}
|
|
365
441
|
}
|
|
366
442
|
});
|
|
443
|
+
|
|
367
444
|
var SpriteAnimation = function (_super) {
|
|
368
445
|
__extends(SpriteAnimation, _super);
|
|
446
|
+
|
|
369
447
|
function SpriteAnimation() {
|
|
370
448
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
449
|
+
|
|
371
450
|
_this.name = 'SpriteAnimation';
|
|
372
451
|
_this.animates = {};
|
|
373
452
|
_this.autoPlay = {};
|
|
374
453
|
return _this;
|
|
375
454
|
}
|
|
455
|
+
|
|
376
456
|
SpriteAnimation.prototype.init = function () {
|
|
377
457
|
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
378
458
|
this.renderSystem.rendererManager.register(this);
|
|
379
459
|
};
|
|
460
|
+
|
|
380
461
|
SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
|
|
381
462
|
var _a = gameObject.transform.size,
|
|
382
|
-
|
|
383
|
-
|
|
463
|
+
width = _a.width,
|
|
464
|
+
height = _a.height;
|
|
465
|
+
|
|
384
466
|
if (this.animates[gameObject.id]) {
|
|
385
467
|
this.animates[gameObject.id].animatedSprite.width = width;
|
|
386
468
|
this.animates[gameObject.id].animatedSprite.height = height;
|
|
387
469
|
}
|
|
388
470
|
};
|
|
471
|
+
|
|
389
472
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
390
473
|
return __awaiter(this, void 0, void 0, function () {
|
|
391
474
|
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
@@ -399,80 +482,99 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
399
482
|
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
400
483
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
401
484
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
485
|
+
|
|
402
486
|
case 1:
|
|
403
487
|
frames_1 = _a.sent().instance;
|
|
404
488
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
489
|
+
|
|
405
490
|
if (!frames_1) {
|
|
406
491
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
407
492
|
}
|
|
493
|
+
|
|
408
494
|
this.add({
|
|
409
495
|
frames: frames_1,
|
|
410
496
|
id: changed.gameObject.id,
|
|
411
497
|
component: component
|
|
412
498
|
});
|
|
413
499
|
return [3, 7];
|
|
500
|
+
|
|
414
501
|
case 2:
|
|
415
502
|
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
416
503
|
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
417
504
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
418
505
|
return [3, 5];
|
|
506
|
+
|
|
419
507
|
case 3:
|
|
420
508
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
421
509
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
510
|
+
|
|
422
511
|
case 4:
|
|
423
512
|
frames_2 = _a.sent().instance;
|
|
424
513
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
514
|
+
|
|
425
515
|
if (!frames_2) {
|
|
426
516
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
427
517
|
}
|
|
518
|
+
|
|
428
519
|
this.change({
|
|
429
520
|
frames: frames_2,
|
|
430
521
|
id: changed.gameObject.id,
|
|
431
522
|
component: component
|
|
432
523
|
});
|
|
433
524
|
_a.label = 5;
|
|
525
|
+
|
|
434
526
|
case 5:
|
|
435
527
|
return [3, 7];
|
|
528
|
+
|
|
436
529
|
case 6:
|
|
437
530
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
438
531
|
this.increaseAsyncId(gameObjectId);
|
|
439
532
|
this.remove(changed.gameObject.id);
|
|
440
533
|
}
|
|
534
|
+
|
|
441
535
|
_a.label = 7;
|
|
536
|
+
|
|
442
537
|
case 7:
|
|
443
538
|
return [2];
|
|
444
539
|
}
|
|
445
540
|
});
|
|
446
541
|
});
|
|
447
542
|
};
|
|
543
|
+
|
|
448
544
|
SpriteAnimation.prototype.add = function (_a) {
|
|
449
545
|
var frames = _a.frames,
|
|
450
|
-
|
|
451
|
-
|
|
546
|
+
id = _a.id,
|
|
547
|
+
component = _a.component;
|
|
452
548
|
var animate = new rendererAdapter.SpriteAnimation({
|
|
453
549
|
frames: frames
|
|
454
550
|
});
|
|
455
551
|
this.animates[id] = animate;
|
|
456
552
|
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
553
|
+
|
|
457
554
|
animate.animatedSprite.onComplete = function () {
|
|
458
555
|
component.emit('complete');
|
|
459
556
|
};
|
|
557
|
+
|
|
460
558
|
animate.animatedSprite.onFrameChange = function () {
|
|
461
559
|
component.emit('frameChange');
|
|
462
560
|
};
|
|
561
|
+
|
|
463
562
|
animate.animatedSprite.onLoop = function () {
|
|
464
563
|
component.emit('loop');
|
|
465
564
|
};
|
|
565
|
+
|
|
466
566
|
component.animate = this.animates[id];
|
|
467
567
|
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
568
|
+
|
|
468
569
|
if (this.autoPlay[id]) {
|
|
469
570
|
animate.animatedSprite.play();
|
|
470
571
|
}
|
|
471
572
|
};
|
|
573
|
+
|
|
472
574
|
SpriteAnimation.prototype.change = function (_a) {
|
|
473
575
|
var frames = _a.frames,
|
|
474
|
-
|
|
475
|
-
|
|
576
|
+
id = _a.id,
|
|
577
|
+
component = _a.component;
|
|
476
578
|
this.remove(id, true);
|
|
477
579
|
this.add({
|
|
478
580
|
frames: frames,
|
|
@@ -480,6 +582,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
480
582
|
component: component
|
|
481
583
|
});
|
|
482
584
|
};
|
|
585
|
+
|
|
483
586
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
484
587
|
var animate = this.animates[id];
|
|
485
588
|
if (!animate) return;
|
|
@@ -489,16 +592,19 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
489
592
|
children: true
|
|
490
593
|
});
|
|
491
594
|
delete this.animates[id];
|
|
595
|
+
|
|
492
596
|
if (!isChange) {
|
|
493
597
|
delete this.autoPlay[id];
|
|
494
598
|
}
|
|
495
599
|
};
|
|
600
|
+
|
|
496
601
|
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
497
602
|
SpriteAnimation = __decorate([eva_js.decorators.componentObserver({
|
|
498
603
|
SpriteAnimation: ['speed', 'resource']
|
|
499
604
|
})], SpriteAnimation);
|
|
500
605
|
return SpriteAnimation;
|
|
501
606
|
}(pluginRenderer.Renderer);
|
|
607
|
+
|
|
502
608
|
var SpriteAnimation$1 = SpriteAnimation;
|
|
503
609
|
exports.SpriteAnimation = SpriteAnimation$3;
|
|
504
610
|
exports.SpriteAnimationSystem = SpriteAnimation$1;
|
|
@@ -507,4 +613,5 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
507
613
|
});
|
|
508
614
|
return exports;
|
|
509
615
|
}({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter, PIXI);
|
|
616
|
+
|
|
510
617
|
window.EVA.plugin.renderer.spriteAnimation = window.EVA.plugin.renderer.spriteAnimation || _EVA_IIFE_spriteAnimation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EVA.plugin.renderer.spriteAnimation.js","sources":["../../../node_modules/tslib/tslib.es6.js","../lib/component.ts","../lib/system.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n 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;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n 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;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n","import { Component, decorators } from '@eva/eva.js';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n autoPlay: boolean;\n speed: number;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n @decorators.IDEProp resource: string = '';\n @decorators.IDEProp autoPlay: boolean = true;\n @decorators.IDEProp speed: number = 100;\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n this.animate.stop();\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 this.animate.play();\n this.count = 0;\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}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\nimport { Spritesheet, BaseTexture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = '_s|r|c_';\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({ name, data }) => {\n return new Promise(r => {\n const textureObj = data.json;\n const texture = BaseTexture.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 spriteSheet.parse(() => {\n const { textures } = spriteSheet;\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n r(spriteFrames);\n });\n });\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 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 { instance: frames } = await resource.getResource(component.resource);\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 { instance: frames } = await resource.getResource(component.resource);\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.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 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":["decorators","Component","SpriteAnimation","resource","RESOURCE_TYPE","BaseTexture","Spritesheet","RendererSystem","OBSERVER_TYPE","SpriteAnimationEngine","Renderer"],"mappings":";;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACA;IACA,IAAI,aAAa,GAAG,SAAS,CAAC,EAAE,CAAC,EAAE;IACnC,IAAI,aAAa,GAAG,MAAM,CAAC,cAAc;IACzC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,YAAY,KAAK,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;IACpF,QAAQ,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnF,IAAI,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC;AACF;IACO,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE;IAChC,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACxB,IAAI,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,EAAE;IAC3C,IAAI,CAA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AAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACzB,IAAI,CAAC,QAAQ,EAAE;gBACb,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;aAC1B;SACF;QArFM,0BAAU,GAAG,iBAAiB,CAAC;QADnB,eAAe;YAHnCT,iBAAU,CAAC,iBAAiB,CAAC;gBAC5B,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;aACvC,CAAC;WACmB,eAAe,CAuFnC;QAAD,sBAAC;KAAA,CAvF4CU,uBAAQ,GAuFpD;4BAvFoB,eAAe;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return
|
|
1
|
+
function _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,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,n,r,o){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function s(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){return e.constructor.IDEProps||(e.constructor.IDEProps={}),e.constructor.IDEProps[t]||(e.constructor.IDEProps[t]={}),e.constructor.IDEProps[t]}function d(e){return function(t,n){var r=l(t,n);r.key=n,r.type=e}}function m(e){return function(t,n){l(t,n).step=e}}var f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.autoPlay=!0,t.speed=100,t.forwards=!1,t.waitPlay=!1,t.waitStop=!1,t.times=1/0,t.count=0,t.complete=!1,t}return a(t,e),t.prototype.init=function(e){var t=this;e&&_extends(this,e),this.on("loop",(function(){++t.count>=t.times&&(t.forwards?t.gotoAndStop(t.totalFrames-1):t.animate.stop(),t.complete=!0,t.emit("complete"))}))},t.prototype.play=function(e){void 0===e&&(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)},t.prototype.stop=function(){this.animate?this.animate.stop():this.waitStop=!0},Object.defineProperty(t.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e,this.waitPlay&&(this.waitPlay=!1,this.play(this.times)),this.waitStop&&(this.waitStop=!1,this.stop())},enumerable:!1,configurable:!0}),t.prototype.gotoAndPlay=function(e){this.animate.gotoAndPlay(e)},t.prototype.gotoAndStop=function(e){this.animate.gotoAndStop(e)},Object.defineProperty(t.prototype,"currentFrame",{get:function(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"totalFrames",{get:function(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.totalFrames},enumerable:!1,configurable:!0}),t.componentName="SpriteAnimation",s([d("string")],t.prototype,"resource",void 0),s([d("boolean")],t.prototype,"autoPlay",void 0),s([d("number"),m(10)],t.prototype,"speed",void 0),s([d("boolean")],t.prototype,"forwards",void 0),t}(t.Component),h="_s|r|c_";t.resource.registerInstance(t.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t=e.name,n=e.data;return new Promise((function(e){var r,i,a=n.json,s=o.BaseTexture.from(n.image),c=a.frames||{},p=a.animations||{},l={};for(var d in c){l[t+h+d]=c[d]}for(var d in p){var m=[];if(p[d]&&p[d].length>=0)try{for(var f=(r=void 0,u(p[d])),y=f.next();!y.done;y=f.next()){var v=y.value,g=t+h+v;m.push(g)}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}p[d]=m}a.frames=l;var b=new o.Spritesheet(s,a);b.parse((function(){var t=b.textures,n=[];for(var r in t)n.push(t[r]);e(n)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t,n,r=e.instance;if(r)try{for(var o=u(r),i=o.next();!i.done;i=o.next()){i.value.destroy(!0)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}));var y=function(e){function o(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="SpriteAnimation",t.animates={},t.autoPlay={},t}return a(o,e),o.prototype.init=function(){this.renderSystem=this.game.getSystem(n.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var t=e.transform.size,n=t.width,r=t.height;this.animates[e.id]&&(this.animates[e.id].animatedSprite.width=n,this.animates[e.id].animatedSprite.height=r)},o.prototype.componentChanged=function(e){return c(this,void 0,void 0,(function(){var n,r,o,i,a;return p(this,(function(s){switch(s.label){case 0:return n=e.gameObject.id,"SpriteAnimation"!==e.componentName?[3,7]:(r=e.component,this.autoPlay[e.gameObject.id]=r.autoPlay,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:(i=this.increaseAsyncId(n),[4,t.resource.getResource(r.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(n,i)?(o||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.add({frames:o,id:e.gameObject.id,component:r}),[3,7]):[2];case 2:return e.type!==t.OBSERVER_TYPE.CHANGE?[3,6]:e.prop&&"speed"===e.prop.prop[0]?(this.animates[e.gameObject.id].speed=1e3/60/r.speed,[3,5]):[3,3];case 3:return i=this.increaseAsyncId(n),[4,t.resource.getResource(r.resource)];case 4:if(a=s.sent().instance,!this.validateAsyncId(n,i))return[2];a||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.change({frames:a,id:e.gameObject.id,component:r}),s.label=5;case 5:return[3,7];case 6:e.type===t.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(n),this.remove(e.gameObject.id)),s.label=7;case 7:return[2]}}))}))},o.prototype.add=function(e){var t=e.frames,n=e.id,o=e.component,i=new r.SpriteAnimation({frames:t});this.animates[n]=i,this.containerManager.getContainer(n).addChildAt(i.animatedSprite,0),i.animatedSprite.onComplete=function(){o.emit("complete")},i.animatedSprite.onFrameChange=function(){o.emit("frameChange")},i.animatedSprite.onLoop=function(){o.emit("loop")},o.animate=this.animates[n],this.animates[n].speed=1e3/60/o.speed,this.autoPlay[n]&&i.animatedSprite.play()},o.prototype.change=function(e){var t=e.frames,n=e.id,r=e.component;this.remove(n,!0),this.add({frames:t,id:n,component:r})},o.prototype.remove=function(e,t){var n=this.animates[e];n&&(this.autoPlay[e]=n.animatedSprite.playing,this.containerManager.getContainer(e).removeChild(n.animatedSprite),n.animatedSprite.destroy({children:!0}),delete this.animates[e],t||delete this.autoPlay[e])},o.systemName="SpriteAnimation",o=s([t.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(n.Renderer);return e.SpriteAnimation=f,e.SpriteAnimationSystem=y,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;
|
package/dist/miniprogram.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
2
3
|
import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
|
|
3
4
|
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
4
5
|
import { type, step } from '@eva/inspector-decorator';
|
|
5
6
|
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
6
7
|
import { SpriteAnimation as SpriteAnimation$4 } from '@eva/renderer-adapter/dist/miniprogram';
|
|
7
8
|
import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
|
|
9
|
+
|
|
8
10
|
var SpriteAnimation$2 = function (_super) {
|
|
9
11
|
__extends(SpriteAnimation, _super);
|
|
12
|
+
|
|
10
13
|
function SpriteAnimation() {
|
|
11
14
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
15
|
+
|
|
12
16
|
_this.resource = '';
|
|
13
17
|
_this.autoPlay = true;
|
|
14
18
|
_this.speed = 100;
|
|
@@ -20,8 +24,10 @@ var SpriteAnimation$2 = function (_super) {
|
|
|
20
24
|
_this.complete = false;
|
|
21
25
|
return _this;
|
|
22
26
|
}
|
|
27
|
+
|
|
23
28
|
SpriteAnimation.prototype.init = function (obj) {
|
|
24
29
|
var _this = this;
|
|
30
|
+
|
|
25
31
|
obj && _extends(this, obj);
|
|
26
32
|
this.on('loop', function () {
|
|
27
33
|
if (++_this.count >= _this.times) {
|
|
@@ -30,30 +36,38 @@ var SpriteAnimation$2 = function (_super) {
|
|
|
30
36
|
} else {
|
|
31
37
|
_this.animate.stop();
|
|
32
38
|
}
|
|
39
|
+
|
|
33
40
|
_this.complete = true;
|
|
41
|
+
|
|
34
42
|
_this.emit('complete');
|
|
35
43
|
}
|
|
36
44
|
});
|
|
37
45
|
};
|
|
46
|
+
|
|
38
47
|
SpriteAnimation.prototype.play = function (times) {
|
|
39
48
|
if (times === void 0) {
|
|
40
49
|
times = Infinity;
|
|
41
50
|
}
|
|
51
|
+
|
|
42
52
|
if (times === 0) {
|
|
43
53
|
return;
|
|
44
54
|
}
|
|
55
|
+
|
|
45
56
|
this.times = times;
|
|
57
|
+
|
|
46
58
|
if (!this.animate) {
|
|
47
59
|
this.waitPlay = true;
|
|
48
60
|
} else {
|
|
49
61
|
if (this.complete) {
|
|
50
62
|
this.gotoAndStop(0);
|
|
51
63
|
}
|
|
64
|
+
|
|
52
65
|
this.animate.play();
|
|
53
66
|
this.count = 0;
|
|
54
67
|
this.complete = false;
|
|
55
68
|
}
|
|
56
69
|
};
|
|
70
|
+
|
|
57
71
|
SpriteAnimation.prototype.stop = function () {
|
|
58
72
|
if (!this.animate) {
|
|
59
73
|
this.waitStop = true;
|
|
@@ -61,16 +75,19 @@ var SpriteAnimation$2 = function (_super) {
|
|
|
61
75
|
this.animate.stop();
|
|
62
76
|
}
|
|
63
77
|
};
|
|
78
|
+
|
|
64
79
|
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
65
80
|
get: function get() {
|
|
66
81
|
return this._animate;
|
|
67
82
|
},
|
|
68
83
|
set: function set(val) {
|
|
69
84
|
this._animate = val;
|
|
85
|
+
|
|
70
86
|
if (this.waitPlay) {
|
|
71
87
|
this.waitPlay = false;
|
|
72
88
|
this.play(this.times);
|
|
73
89
|
}
|
|
90
|
+
|
|
74
91
|
if (this.waitStop) {
|
|
75
92
|
this.waitStop = false;
|
|
76
93
|
this.stop();
|
|
@@ -79,15 +96,19 @@ var SpriteAnimation$2 = function (_super) {
|
|
|
79
96
|
enumerable: false,
|
|
80
97
|
configurable: true
|
|
81
98
|
});
|
|
99
|
+
|
|
82
100
|
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
83
101
|
this.animate.gotoAndPlay(frameNumber);
|
|
84
102
|
};
|
|
103
|
+
|
|
85
104
|
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
86
105
|
this.animate.gotoAndStop(frameNumber);
|
|
87
106
|
};
|
|
107
|
+
|
|
88
108
|
Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
|
|
89
109
|
get: function get() {
|
|
90
110
|
var _a, _b;
|
|
111
|
+
|
|
91
112
|
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
92
113
|
},
|
|
93
114
|
enumerable: false,
|
|
@@ -96,36 +117,47 @@ var SpriteAnimation$2 = function (_super) {
|
|
|
96
117
|
Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
|
|
97
118
|
get: function get() {
|
|
98
119
|
var _a, _b;
|
|
120
|
+
|
|
99
121
|
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
100
122
|
},
|
|
101
123
|
enumerable: false,
|
|
102
124
|
configurable: true
|
|
103
125
|
});
|
|
104
126
|
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
127
|
+
|
|
105
128
|
__decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
|
|
129
|
+
|
|
106
130
|
__decorate([type('boolean')], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
131
|
+
|
|
107
132
|
__decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
|
|
133
|
+
|
|
108
134
|
__decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
|
|
135
|
+
|
|
109
136
|
return SpriteAnimation;
|
|
110
137
|
}(Component);
|
|
138
|
+
|
|
111
139
|
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
112
140
|
var resourceKeySplit = '_s|r|c_';
|
|
113
141
|
resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
114
142
|
var name = _a.name,
|
|
115
|
-
|
|
143
|
+
data = _a.data;
|
|
116
144
|
return new Promise(function (r) {
|
|
117
145
|
var e_1, _a;
|
|
146
|
+
|
|
118
147
|
var textureObj = data.json;
|
|
119
148
|
var texture = BaseTexture.from(data.image);
|
|
120
149
|
var frames = textureObj.frames || {};
|
|
121
150
|
var animations = textureObj.animations || {};
|
|
122
151
|
var newFrames = {};
|
|
152
|
+
|
|
123
153
|
for (var key in frames) {
|
|
124
154
|
var newKey = name + resourceKeySplit + key;
|
|
125
155
|
newFrames[newKey] = frames[key];
|
|
126
156
|
}
|
|
157
|
+
|
|
127
158
|
for (var key in animations) {
|
|
128
159
|
var spriteList = [];
|
|
160
|
+
|
|
129
161
|
if (animations[key] && animations[key].length >= 0) {
|
|
130
162
|
try {
|
|
131
163
|
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -145,24 +177,30 @@ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
|
145
177
|
}
|
|
146
178
|
}
|
|
147
179
|
}
|
|
180
|
+
|
|
148
181
|
animations[key] = spriteList;
|
|
149
182
|
}
|
|
183
|
+
|
|
150
184
|
textureObj.frames = newFrames;
|
|
151
185
|
var spriteSheet = new Spritesheet(texture, textureObj);
|
|
152
186
|
spriteSheet.parse(function () {
|
|
153
187
|
var textures = spriteSheet.textures;
|
|
154
188
|
var spriteFrames = [];
|
|
189
|
+
|
|
155
190
|
for (var key in textures) {
|
|
156
191
|
spriteFrames.push(textures[key]);
|
|
157
192
|
}
|
|
193
|
+
|
|
158
194
|
r(spriteFrames);
|
|
159
195
|
});
|
|
160
196
|
});
|
|
161
197
|
});
|
|
162
198
|
resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
163
199
|
var e_2, _b;
|
|
200
|
+
|
|
164
201
|
var instance = _a.instance;
|
|
165
202
|
if (!instance) return;
|
|
203
|
+
|
|
166
204
|
try {
|
|
167
205
|
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
168
206
|
var texture = instance_1_1.value;
|
|
@@ -180,28 +218,35 @@ resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
|
180
218
|
}
|
|
181
219
|
}
|
|
182
220
|
});
|
|
221
|
+
|
|
183
222
|
var SpriteAnimation = function (_super) {
|
|
184
223
|
__extends(SpriteAnimation, _super);
|
|
224
|
+
|
|
185
225
|
function SpriteAnimation() {
|
|
186
226
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
227
|
+
|
|
187
228
|
_this.name = 'SpriteAnimation';
|
|
188
229
|
_this.animates = {};
|
|
189
230
|
_this.autoPlay = {};
|
|
190
231
|
return _this;
|
|
191
232
|
}
|
|
233
|
+
|
|
192
234
|
SpriteAnimation.prototype.init = function () {
|
|
193
235
|
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
194
236
|
this.renderSystem.rendererManager.register(this);
|
|
195
237
|
};
|
|
238
|
+
|
|
196
239
|
SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
|
|
197
240
|
var _a = gameObject.transform.size,
|
|
198
|
-
|
|
199
|
-
|
|
241
|
+
width = _a.width,
|
|
242
|
+
height = _a.height;
|
|
243
|
+
|
|
200
244
|
if (this.animates[gameObject.id]) {
|
|
201
245
|
this.animates[gameObject.id].animatedSprite.width = width;
|
|
202
246
|
this.animates[gameObject.id].animatedSprite.height = height;
|
|
203
247
|
}
|
|
204
248
|
};
|
|
249
|
+
|
|
205
250
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
206
251
|
return __awaiter(this, void 0, void 0, function () {
|
|
207
252
|
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
@@ -215,80 +260,99 @@ var SpriteAnimation = function (_super) {
|
|
|
215
260
|
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
216
261
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
217
262
|
return [4, resource.getResource(component.resource)];
|
|
263
|
+
|
|
218
264
|
case 1:
|
|
219
265
|
frames_1 = _a.sent().instance;
|
|
220
266
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
267
|
+
|
|
221
268
|
if (!frames_1) {
|
|
222
269
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
223
270
|
}
|
|
271
|
+
|
|
224
272
|
this.add({
|
|
225
273
|
frames: frames_1,
|
|
226
274
|
id: changed.gameObject.id,
|
|
227
275
|
component: component
|
|
228
276
|
});
|
|
229
277
|
return [3, 7];
|
|
278
|
+
|
|
230
279
|
case 2:
|
|
231
280
|
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
232
281
|
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
233
282
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
234
283
|
return [3, 5];
|
|
284
|
+
|
|
235
285
|
case 3:
|
|
236
286
|
asyncId = this.increaseAsyncId(gameObjectId);
|
|
237
287
|
return [4, resource.getResource(component.resource)];
|
|
288
|
+
|
|
238
289
|
case 4:
|
|
239
290
|
frames_2 = _a.sent().instance;
|
|
240
291
|
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
292
|
+
|
|
241
293
|
if (!frames_2) {
|
|
242
294
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
243
295
|
}
|
|
296
|
+
|
|
244
297
|
this.change({
|
|
245
298
|
frames: frames_2,
|
|
246
299
|
id: changed.gameObject.id,
|
|
247
300
|
component: component
|
|
248
301
|
});
|
|
249
302
|
_a.label = 5;
|
|
303
|
+
|
|
250
304
|
case 5:
|
|
251
305
|
return [3, 7];
|
|
306
|
+
|
|
252
307
|
case 6:
|
|
253
308
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
254
309
|
this.increaseAsyncId(gameObjectId);
|
|
255
310
|
this.remove(changed.gameObject.id);
|
|
256
311
|
}
|
|
312
|
+
|
|
257
313
|
_a.label = 7;
|
|
314
|
+
|
|
258
315
|
case 7:
|
|
259
316
|
return [2];
|
|
260
317
|
}
|
|
261
318
|
});
|
|
262
319
|
});
|
|
263
320
|
};
|
|
321
|
+
|
|
264
322
|
SpriteAnimation.prototype.add = function (_a) {
|
|
265
323
|
var frames = _a.frames,
|
|
266
|
-
|
|
267
|
-
|
|
324
|
+
id = _a.id,
|
|
325
|
+
component = _a.component;
|
|
268
326
|
var animate = new SpriteAnimation$4({
|
|
269
327
|
frames: frames
|
|
270
328
|
});
|
|
271
329
|
this.animates[id] = animate;
|
|
272
330
|
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
331
|
+
|
|
273
332
|
animate.animatedSprite.onComplete = function () {
|
|
274
333
|
component.emit('complete');
|
|
275
334
|
};
|
|
335
|
+
|
|
276
336
|
animate.animatedSprite.onFrameChange = function () {
|
|
277
337
|
component.emit('frameChange');
|
|
278
338
|
};
|
|
339
|
+
|
|
279
340
|
animate.animatedSprite.onLoop = function () {
|
|
280
341
|
component.emit('loop');
|
|
281
342
|
};
|
|
343
|
+
|
|
282
344
|
component.animate = this.animates[id];
|
|
283
345
|
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
346
|
+
|
|
284
347
|
if (this.autoPlay[id]) {
|
|
285
348
|
animate.animatedSprite.play();
|
|
286
349
|
}
|
|
287
350
|
};
|
|
351
|
+
|
|
288
352
|
SpriteAnimation.prototype.change = function (_a) {
|
|
289
353
|
var frames = _a.frames,
|
|
290
|
-
|
|
291
|
-
|
|
354
|
+
id = _a.id,
|
|
355
|
+
component = _a.component;
|
|
292
356
|
this.remove(id, true);
|
|
293
357
|
this.add({
|
|
294
358
|
frames: frames,
|
|
@@ -296,6 +360,7 @@ var SpriteAnimation = function (_super) {
|
|
|
296
360
|
component: component
|
|
297
361
|
});
|
|
298
362
|
};
|
|
363
|
+
|
|
299
364
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
300
365
|
var animate = this.animates[id];
|
|
301
366
|
if (!animate) return;
|
|
@@ -305,15 +370,18 @@ var SpriteAnimation = function (_super) {
|
|
|
305
370
|
children: true
|
|
306
371
|
});
|
|
307
372
|
delete this.animates[id];
|
|
373
|
+
|
|
308
374
|
if (!isChange) {
|
|
309
375
|
delete this.autoPlay[id];
|
|
310
376
|
}
|
|
311
377
|
};
|
|
378
|
+
|
|
312
379
|
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
313
380
|
SpriteAnimation = __decorate([decorators.componentObserver({
|
|
314
381
|
SpriteAnimation: ['speed', 'resource']
|
|
315
382
|
})], SpriteAnimation);
|
|
316
383
|
return SpriteAnimation;
|
|
317
384
|
}(Renderer);
|
|
385
|
+
|
|
318
386
|
var SpriteAnimation$1 = SpriteAnimation;
|
|
319
387
|
export { SpriteAnimation$3 as SpriteAnimation, SpriteAnimation$1 as SpriteAnimationSystem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-sprite-animation.cjs.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component, decorators } from '@eva/eva.js';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n autoPlay: boolean;\n speed: number;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n @decorators.IDEProp resource: string = '';\n @decorators.IDEProp autoPlay: boolean = true;\n @decorators.IDEProp speed: number = 100;\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n this.animate.stop();\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 this.animate.play();\n this.count = 0;\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}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\nimport { Spritesheet, BaseTexture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = '_s|r|c_';\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({ name, data }) => {\n return new Promise(r => {\n const textureObj = data.json;\n const texture = BaseTexture.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 spriteSheet.parse(() => {\n const { textures } = spriteSheet;\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n r(spriteFrames);\n });\n });\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 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 { instance: frames } = await resource.getResource(component.resource);\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 { instance: frames } = await resource.getResource(component.resource);\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.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 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":["decorators","Component","SpriteAnimation","resource","RESOURCE_TYPE","BaseTexture","Spritesheet","RendererSystem","OBSERVER_TYPE","SpriteAnimationEngine","Renderer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;IAA6C,mCAAgC;IAA7E;QAAA,qEA0DC;QAxDqB,cAAQ,GAAW,EAAE,CAAC;QACtB,cAAQ,GAAY,IAAI,CAAC;QACzB,WAAK,GAAW,GAAG,CAAC;QAEhC,cAAQ,GAAY,KAAK,CAAC;QAC1B,cAAQ,GAAY,KAAK,CAAC;QAC1B,WAAK,GAAW,QAAQ,CAAC;QACzB,WAAK,GAAW,CAAC,CAAC;;KAiD3B;IAhDC,8BAAI,GAAJ,UAAK,GAA2B;QAAhC,iBAQC;QAPC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE;YACd,IAAI,EAAE,KAAI,CAAC,KAAK,IAAI,KAAI,CAAC,KAAK,EAAE;gBAC9B,KAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;aACvB;SACF,CAAC,CAAC;KACJ;IACD,8BAAI,GAAJ,UAAK,KAAgB;QAAhB,sBAAA,EAAA,gBAAgB;QACnB,IAAI,KAAK,KAAK,CAAC,EAAE;YACf,OAAO;SACR;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,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{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),o=require("pixi.js"),i=function(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),r=require("@eva/plugin-renderer"),n=require("@eva/renderer-adapter"),o=require("pixi.js"),i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function a(e,t){function r(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function s(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function p(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}var u=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.autoPlay=!0,t.speed=100,t.forwards=!1,t.waitPlay=!1,t.waitStop=!1,t.times=1/0,t.count=0,t.complete=!1,t}return a(r,e),r.prototype.init=function(e){var t=this;e&&Object.assign(this,e),this.on("loop",(function(){++t.count>=t.times&&(t.forwards?t.gotoAndStop(t.totalFrames-1):t.animate.stop(),t.complete=!0,t.emit("complete"))}))},r.prototype.play=function(e){void 0===e&&(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)},r.prototype.stop=function(){this.animate?this.animate.stop():this.waitStop=!0},Object.defineProperty(r.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e,this.waitPlay&&(this.waitPlay=!1,this.play(this.times)),this.waitStop&&(this.waitStop=!1,this.stop())},enumerable:!1,configurable:!0}),r.prototype.gotoAndPlay=function(e){this.animate.gotoAndPlay(e)},r.prototype.gotoAndStop=function(e){this.animate.gotoAndStop(e)},Object.defineProperty(r.prototype,"currentFrame",{get:function(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"totalFrames",{get:function(){var e,t;return null===(t=null===(e=this.animate)||void 0===e?void 0:e.animatedSprite)||void 0===t?void 0:t.totalFrames},enumerable:!1,configurable:!0}),r.componentName="SpriteAnimation",s([t.type("string")],r.prototype,"resource",void 0),s([t.type("boolean")],r.prototype,"autoPlay",void 0),s([t.type("number"),t.step(10)],r.prototype,"speed",void 0),s([t.type("boolean")],r.prototype,"forwards",void 0),r}(e.Component);e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var n,i,a=r.json,s=o.BaseTexture.from(r.image),c=a.frames||{},u=a.animations||{},l={};for(var m in c){l[t+"_s|r|c_"+m]=c[m]}for(var m in u){var d=[];if(u[m]&&u[m].length>=0)try{for(var f=(n=void 0,p(u[m])),h=f.next();!h.done;h=f.next()){var y=h.value,v=t+"_s|r|c_"+y;d.push(v)}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}u[m]=d}a.frames=l;var g=new o.Spritesheet(s,a);g.parse((function(){var t=g.textures,r=[];for(var n in t)r.push(t[n]);e(r)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t,r,n=e.instance;if(n)try{for(var o=p(n),i=o.next();!i.done;i=o.next()){i.value.destroy(!0)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}));var l=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="SpriteAnimation",e.animates={},e.autoPlay={},e}return a(o,t),o.prototype.init=function(){this.renderSystem=this.game.getSystem(r.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(e){var t=e.transform.size,r=t.width,n=t.height;this.animates[e.id]&&(this.animates[e.id].animatedSprite.width=r,this.animates[e.id].animatedSprite.height=n)},o.prototype.componentChanged=function(t){return r=this,n=void 0,i=function(){var r,n,o,i,a;return c(this,(function(s){switch(s.label){case 0:return r=t.gameObject.id,"SpriteAnimation"!==t.componentName?[3,7]:(n=t.component,this.autoPlay[t.gameObject.id]=n.autoPlay,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(r,i)?(o||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.add({frames:o,id:t.gameObject.id,component:n}),[3,7]):[2];case 2:return t.type!==e.OBSERVER_TYPE.CHANGE?[3,6]:t.prop&&"speed"===t.prop.prop[0]?(this.animates[t.gameObject.id].speed=1e3/60/n.speed,[3,5]):[3,3];case 3:return i=this.increaseAsyncId(r),[4,e.resource.getResource(n.resource)];case 4:if(a=s.sent().instance,!this.validateAsyncId(r,i))return[2];a||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.change({frames:a,id:t.gameObject.id,component:n}),s.label=5;case 5:return[3,7];case 6:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(r),this.remove(t.gameObject.id)),s.label=7;case 7:return[2]}}))},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{c(i.next(e))}catch(e){t(e)}}function s(e){try{c(i.throw(e))}catch(e){t(e)}}function c(t){t.done?e(t.value):new o((function(e){e(t.value)})).then(a,s)}c((i=i.apply(r,n||[])).next())}));var r,n,o,i},o.prototype.add=function(e){var t=e.frames,r=e.id,o=e.component,i=new n.SpriteAnimation({frames:t});this.animates[r]=i,this.containerManager.getContainer(r).addChildAt(i.animatedSprite,0),i.animatedSprite.onComplete=function(){o.emit("complete")},i.animatedSprite.onFrameChange=function(){o.emit("frameChange")},i.animatedSprite.onLoop=function(){o.emit("loop")},o.animate=this.animates[r],this.animates[r].speed=1e3/60/o.speed,this.autoPlay[r]&&i.animatedSprite.play()},o.prototype.change=function(e){var t=e.frames,r=e.id,n=e.component;this.remove(r,!0),this.add({frames:t,id:r,component:n})},o.prototype.remove=function(e,t){var r=this.animates[e];r&&(this.autoPlay[e]=r.animatedSprite.playing,this.containerManager.getContainer(e).removeChild(r.animatedSprite),r.animatedSprite.destroy({children:!0}),delete this.animates[e],t||delete this.autoPlay[e])},o.systemName="SpriteAnimation",o=s([e.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(r.Renderer);exports.SpriteAnimation=u,exports.SpriteAnimationSystem=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-renderer-sprite-animation.esm.js","sources":["../lib/component.ts","../lib/system.ts"],"sourcesContent":["import { Component, decorators } from '@eva/eva.js';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\n\nexport interface SpriteAnimationParams {\n resource: string;\n autoPlay: boolean;\n speed: number;\n}\n\nexport default class SpriteAnimation extends Component<SpriteAnimationParams> {\n static componentName: string = 'SpriteAnimation';\n @decorators.IDEProp resource: string = '';\n @decorators.IDEProp autoPlay: boolean = true;\n @decorators.IDEProp speed: number = 100;\n _animate: SpriteAnimationEngine;\n private waitPlay: boolean = false;\n private waitStop: boolean = false;\n private times: number = Infinity;\n private count: number = 0;\n init(obj?: SpriteAnimationParams) {\n obj && Object.assign(this, obj);\n this.on('loop', () => {\n if (++this.count >= this.times) {\n this.animate.stop();\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 this.animate.play();\n this.count = 0;\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}\n","import { GameObject, decorators, resource, ComponentChanged, RESOURCE_TYPE, OBSERVER_TYPE } from '@eva/eva.js';\nimport { RendererManager, ContainerManager, RendererSystem, Renderer } from '@eva/plugin-renderer';\nimport { SpriteAnimation as SpriteAnimationEngine } from '@eva/renderer-adapter';\nimport { Spritesheet, BaseTexture } from 'pixi.js';\n\nimport SpriteAnimationComponent from './component';\n\nconst resourceKeySplit = '_s|r|c_';\n\nresource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, ({ name, data }) => {\n return new Promise(r => {\n const textureObj = data.json;\n const texture = BaseTexture.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 spriteSheet.parse(() => {\n const { textures } = spriteSheet;\n const spriteFrames = [];\n for (const key in textures) {\n spriteFrames.push(textures[key]);\n }\n r(spriteFrames);\n });\n });\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 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 { instance: frames } = await resource.getResource(component.resource);\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 { instance: frames } = await resource.getResource(component.resource);\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.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 this.autoPlay[id] = animate.animatedSprite.playing;\n this.containerManager.getContainer(id).removeChild(animate.animatedSprite);\n animate.animatedSprite.destroy({ children: true });\n delete this.animates[id];\n if (!isChange) {\n delete this.autoPlay[id];\n }\n }\n}\n"],"names":["SpriteAnimation","SpriteAnimationEngine"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAO,EAAE,EAAE,QAAkB;QAC3B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC;QACnD,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC3E,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,EAAE;YACb,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;SAC1B;KACF;IArFM,0BAAU,GAAG,iBAAiB,CAAC;IADnB,eAAe;QAHnC,UAAU,CAAC,iBAAiB,CAAC;YAC5B,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC;SACvC,CAAC;OACmB,eAAe,CAuFnC;IAAD,sBAAC;CAAA,CAvF4C,QAAQ,GAuFpD;wBAvFoB,eAAe;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "1.2.7-fix.
|
|
3
|
+
"version": "1.2.7-fix.6",
|
|
4
4
|
"description": "@eva/plugin-renderer-sprite-animation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite-animation.esm.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "1.2.7-fix.
|
|
23
|
-
"@eva/renderer-adapter": "1.2.7-fix.
|
|
24
|
-
"@eva/eva.js": "1.2.7-fix.
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7-fix.6",
|
|
23
|
+
"@eva/renderer-adapter": "1.2.7-fix.6",
|
|
24
|
+
"@eva/eva.js": "1.2.7-fix.6",
|
|
25
25
|
"pixi.js": "^4.8.7"
|
|
26
26
|
}
|
|
27
27
|
}
|