@eva/plugin-renderer-sprite-animation 1.2.7-editor.8 → 1.2.7-fix.4

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.
@@ -1,9 +1,7 @@
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
-
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
3
2
  window.EVA = window.EVA || {};
4
3
  window.EVA.plugin = window.EVA.plugin || {};
5
4
  window.EVA.plugin.renderer = window.EVA.plugin.renderer || {};
6
-
7
5
  var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) {
8
6
  'use strict';
9
7
 
@@ -14,62 +12,33 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
14
12
  d.__proto__ = b;
15
13
  } || function (d, b) {
16
14
  for (var p in b) {
17
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
15
+ if (b.hasOwnProperty(p)) d[p] = b[p];
18
16
  }
19
17
  };
20
-
21
18
  return _extendStatics(d, b);
22
19
  };
23
-
24
20
  function __extends(d, b) {
25
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
26
-
27
21
  _extendStatics(d, b);
28
-
29
22
  function __() {
30
23
  this.constructor = d;
31
24
  }
32
-
33
25
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
26
  }
35
-
36
- var _assign = function __assign() {
37
- _assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
-
41
- for (var p in s) {
42
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
43
- }
44
- }
45
-
46
- return t;
47
- };
48
-
49
- return _assign.apply(this, arguments);
50
- };
51
-
52
27
  function __decorate(decorators, target, key, desc) {
53
28
  var c = arguments.length,
54
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
55
- d;
29
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
30
+ d;
56
31
  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--) {
57
32
  if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
58
33
  }
59
34
  return c > 3 && r && Object.defineProperty(target, key, r), r;
60
35
  }
61
-
62
- function __metadata(metadataKey, metadataValue) {
63
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
64
- }
65
-
66
36
  function __awaiter(thisArg, _arguments, P, generator) {
67
37
  function adopt(value) {
68
38
  return value instanceof P ? value : new P(function (resolve) {
69
39
  resolve(value);
70
40
  });
71
41
  }
72
-
73
42
  return new (P || (P = Promise))(function (resolve, reject) {
74
43
  function fulfilled(value) {
75
44
  try {
@@ -78,7 +47,6 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
78
47
  reject(e);
79
48
  }
80
49
  }
81
-
82
50
  function rejected(value) {
83
51
  try {
84
52
  step(generator["throw"](value));
@@ -86,29 +54,26 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
86
54
  reject(e);
87
55
  }
88
56
  }
89
-
90
57
  function step(result) {
91
58
  result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
92
59
  }
93
-
94
60
  step((generator = generator.apply(thisArg, _arguments || [])).next());
95
61
  });
96
62
  }
97
-
98
63
  function __generator(thisArg, body) {
99
64
  var _ = {
100
- label: 0,
101
- sent: function sent() {
102
- if (t[0] & 1) throw t[1];
103
- return t[1];
65
+ label: 0,
66
+ sent: function sent() {
67
+ if (t[0] & 1) throw t[1];
68
+ return t[1];
69
+ },
70
+ trys: [],
71
+ ops: []
104
72
  },
105
- trys: [],
106
- ops: []
107
- },
108
- f,
109
- y,
110
- t,
111
- g;
73
+ f,
74
+ y,
75
+ t,
76
+ g;
112
77
  return g = {
113
78
  next: verb(0),
114
79
  "throw": verb(1),
@@ -116,79 +81,60 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
116
81
  }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
117
82
  return this;
118
83
  }), g;
119
-
120
84
  function verb(n) {
121
85
  return function (v) {
122
86
  return step([n, v]);
123
87
  };
124
88
  }
125
-
126
89
  function step(op) {
127
90
  if (f) throw new TypeError("Generator is already executing.");
128
-
129
91
  while (_) {
130
92
  try {
131
93
  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;
132
94
  if (y = 0, t) op = [op[0] & 2, t.value];
133
-
134
95
  switch (op[0]) {
135
96
  case 0:
136
97
  case 1:
137
98
  t = op;
138
99
  break;
139
-
140
100
  case 4:
141
101
  _.label++;
142
102
  return {
143
103
  value: op[1],
144
104
  done: false
145
105
  };
146
-
147
106
  case 5:
148
107
  _.label++;
149
108
  y = op[1];
150
109
  op = [0];
151
110
  continue;
152
-
153
111
  case 7:
154
112
  op = _.ops.pop();
155
-
156
113
  _.trys.pop();
157
-
158
114
  continue;
159
-
160
115
  default:
161
116
  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
162
117
  _ = 0;
163
118
  continue;
164
119
  }
165
-
166
120
  if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
167
121
  _.label = op[1];
168
122
  break;
169
123
  }
170
-
171
124
  if (op[0] === 6 && _.label < t[1]) {
172
125
  _.label = t[1];
173
126
  t = op;
174
127
  break;
175
128
  }
176
-
177
129
  if (t && _.label < t[2]) {
178
130
  _.label = t[2];
179
-
180
131
  _.ops.push(op);
181
-
182
132
  break;
183
133
  }
184
-
185
134
  if (t[2]) _.ops.pop();
186
-
187
135
  _.trys.pop();
188
-
189
136
  continue;
190
137
  }
191
-
192
138
  op = body.call(thisArg, _);
193
139
  } catch (e) {
194
140
  op = [6, e];
@@ -197,7 +143,6 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
197
143
  f = t = 0;
198
144
  }
199
145
  }
200
-
201
146
  if (op[0] & 5) throw op[1];
202
147
  return {
203
148
  value: op[0] ? op[1] : void 0,
@@ -205,11 +150,10 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
205
150
  };
206
151
  }
207
152
  }
208
-
209
153
  function __values(o) {
210
154
  var s = typeof Symbol === "function" && Symbol.iterator,
211
- m = s && o[s],
212
- i = 0;
155
+ m = s && o[s],
156
+ i = 0;
213
157
  if (m) return m.call(o);
214
158
  if (o && typeof o.length === "number") return {
215
159
  next: function next() {
@@ -222,124 +166,33 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
222
166
  };
223
167
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
224
168
  }
225
-
226
- var SymbolKeysNotSupportedError = function (_super) {
227
- __extends(SymbolKeysNotSupportedError, _super);
228
-
229
- function SymbolKeysNotSupportedError() {
230
- var _newTarget = this.constructor;
231
-
232
- var _this = _super.call(this, 'Symbol keys are not supported yet!') || this;
233
-
234
- Object.setPrototypeOf(_this, _newTarget.prototype);
235
- return _this;
169
+ function getIDEPropsPropertyObj(target, propertyKey) {
170
+ if (!target.constructor.IDEProps) {
171
+ target.constructor.IDEProps = {};
236
172
  }
237
-
238
- return SymbolKeysNotSupportedError;
239
- }(Error);
240
-
241
- (function (_super) {
242
- __extends(StaticGetPropertiesIsNotAFunctionError, _super);
243
-
244
- function StaticGetPropertiesIsNotAFunctionError() {
245
- var _newTarget = this.constructor;
246
-
247
- var _this = _super.call(this, 'getProperties is not a function!') || this;
248
-
249
- Object.setPrototypeOf(_this, _newTarget.prototype);
250
- return _this;
173
+ if (!target.constructor.IDEProps[propertyKey]) {
174
+ target.constructor.IDEProps[propertyKey] = {};
251
175
  }
252
-
253
- return StaticGetPropertiesIsNotAFunctionError;
254
- })(Error);
255
-
256
- var IDE_PROPERTY_METADATA = 'IDE_PROPERTY_METADATA';
257
-
258
- function transformBasicType(type) {
259
- if (type === String) {
260
- return 'string';
261
- }
262
-
263
- if (type === Number) {
264
- return 'number';
265
- }
266
-
267
- if (type === Boolean) {
268
- return 'boolean';
269
- }
270
-
271
- return 'unknown';
176
+ var propertyObj = target.constructor.IDEProps[propertyKey];
177
+ return propertyObj;
272
178
  }
273
-
274
- function defineTypes(target, key, options, returnTypeFunction) {
275
- var type = Reflect.getMetadata('design:type', target, key);
276
- var isArray = type === Array;
277
- var str = transformBasicType(type);
278
-
279
- if (str !== 'unknown') {
280
- type = str;
281
- }
282
-
283
- if (returnTypeFunction) {
284
- var returnType = returnTypeFunction();
285
-
286
- if (Array.isArray(returnType)) {
287
- isArray = true;
288
- type = returnType[0];
289
- } else {
290
- type = returnType;
291
- }
292
- }
293
-
294
- var properties = Reflect.getMetadata(IDE_PROPERTY_METADATA, target.constructor) || {};
295
- properties[key] = _assign({
296
- type: type,
297
- isArray: isArray
298
- }, options);
299
- Reflect.defineMetadata(IDE_PROPERTY_METADATA, properties, target.constructor);
300
- }
301
-
302
- function getTypeDecoratorParams(returnTypeFuncOrOptions, maybeOptions) {
303
- if (typeof returnTypeFuncOrOptions === 'function') {
304
- return {
305
- returnTypeFunc: returnTypeFuncOrOptions,
306
- options: maybeOptions || {}
307
- };
308
- }
309
-
310
- return {
311
- options: returnTypeFuncOrOptions || {}
179
+ function type(type) {
180
+ return function (target, propertyKey) {
181
+ var prop = getIDEPropsPropertyObj(target, propertyKey);
182
+ prop.key = propertyKey;
183
+ prop.type = type;
312
184
  };
313
185
  }
314
-
315
- function Field(returnTypeFunction, maybeOptions) {
186
+ function step(step) {
316
187
  return function (target, propertyKey) {
317
- if (typeof propertyKey === 'symbol') {
318
- throw new SymbolKeysNotSupportedError();
319
- }
320
-
321
- var _a = getTypeDecoratorParams(returnTypeFunction, maybeOptions),
322
- options = _a.options,
323
- returnTypeFunc = _a.returnTypeFunc;
324
-
325
- defineTypes(target, propertyKey, options, returnTypeFunc);
188
+ var prop = getIDEPropsPropertyObj(target, propertyKey);
189
+ prop.step = step;
326
190
  };
327
191
  }
328
-
329
- var ExecuteMode;
330
-
331
- (function (ExecuteMode) {
332
- ExecuteMode[ExecuteMode["Edit"] = 2] = "Edit";
333
- ExecuteMode[ExecuteMode["Game"] = 4] = "Game";
334
- ExecuteMode[ExecuteMode["All"] = 6] = "All";
335
- })(ExecuteMode || (ExecuteMode = {}));
336
-
337
192
  var SpriteAnimation$2 = function (_super) {
338
193
  __extends(SpriteAnimation, _super);
339
-
340
194
  function SpriteAnimation() {
341
195
  var _this = _super !== null && _super.apply(this, arguments) || this;
342
-
343
196
  _this.resource = '';
344
197
  _this.autoPlay = true;
345
198
  _this.speed = 100;
@@ -351,10 +204,8 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
351
204
  _this.complete = false;
352
205
  return _this;
353
206
  }
354
-
355
207
  SpriteAnimation.prototype.init = function (obj) {
356
208
  var _this = this;
357
-
358
209
  obj && _extends(this, obj);
359
210
  this.on('loop', function () {
360
211
  if (++_this.count >= _this.times) {
@@ -363,38 +214,30 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
363
214
  } else {
364
215
  _this.animate.stop();
365
216
  }
366
-
367
217
  _this.complete = true;
368
-
369
218
  _this.emit('complete');
370
219
  }
371
220
  });
372
221
  };
373
-
374
222
  SpriteAnimation.prototype.play = function (times) {
375
223
  if (times === void 0) {
376
224
  times = Infinity;
377
225
  }
378
-
379
226
  if (times === 0) {
380
227
  return;
381
228
  }
382
-
383
229
  this.times = times;
384
-
385
230
  if (!this.animate) {
386
231
  this.waitPlay = true;
387
232
  } else {
388
233
  if (this.complete) {
389
234
  this.gotoAndStop(0);
390
235
  }
391
-
392
236
  this.animate.play();
393
237
  this.count = 0;
394
238
  this.complete = false;
395
239
  }
396
240
  };
397
-
398
241
  SpriteAnimation.prototype.stop = function () {
399
242
  if (!this.animate) {
400
243
  this.waitStop = true;
@@ -402,19 +245,16 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
402
245
  this.animate.stop();
403
246
  }
404
247
  };
405
-
406
248
  Object.defineProperty(SpriteAnimation.prototype, "animate", {
407
249
  get: function get() {
408
250
  return this._animate;
409
251
  },
410
252
  set: function set(val) {
411
253
  this._animate = val;
412
-
413
254
  if (this.waitPlay) {
414
255
  this.waitPlay = false;
415
256
  this.play(this.times);
416
257
  }
417
-
418
258
  if (this.waitStop) {
419
259
  this.waitStop = false;
420
260
  this.stop();
@@ -423,19 +263,15 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
423
263
  enumerable: false,
424
264
  configurable: true
425
265
  });
426
-
427
266
  SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
428
267
  this.animate.gotoAndPlay(frameNumber);
429
268
  };
430
-
431
269
  SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
432
270
  this.animate.gotoAndStop(frameNumber);
433
271
  };
434
-
435
272
  Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
436
273
  get: function get() {
437
274
  var _a, _b;
438
-
439
275
  return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
440
276
  },
441
277
  enumerable: false,
@@ -444,49 +280,36 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
444
280
  Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
445
281
  get: function get() {
446
282
  var _a, _b;
447
-
448
283
  return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
449
284
  },
450
285
  enumerable: false,
451
286
  configurable: true
452
287
  });
453
288
  SpriteAnimation.componentName = 'SpriteAnimation';
454
-
455
- __decorate([Field(), __metadata("design:type", String)], SpriteAnimation.prototype, "resource", void 0);
456
-
457
- __decorate([Field(), __metadata("design:type", Boolean)], SpriteAnimation.prototype, "autoPlay", void 0);
458
-
459
- __decorate([Field({
460
- step: 10
461
- }), __metadata("design:type", Number)], SpriteAnimation.prototype, "speed", void 0);
462
-
463
- __decorate([Field(), __metadata("design:type", Boolean)], SpriteAnimation.prototype, "forwards", void 0);
464
-
289
+ __decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
290
+ __decorate([type('boolean')], SpriteAnimation.prototype, "autoPlay", void 0);
291
+ __decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
292
+ __decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
465
293
  return SpriteAnimation;
466
294
  }(eva_js.Component);
467
-
468
295
  var SpriteAnimation$3 = SpriteAnimation$2;
469
296
  var resourceKeySplit = '_s|r|c_';
470
297
  eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
471
298
  var name = _a.name,
472
- data = _a.data;
299
+ data = _a.data;
473
300
  return new Promise(function (r) {
474
301
  var e_1, _a;
475
-
476
302
  var textureObj = data.json;
477
303
  var texture = pixi_js.BaseTexture.from(data.image);
478
304
  var frames = textureObj.frames || {};
479
305
  var animations = textureObj.animations || {};
480
306
  var newFrames = {};
481
-
482
307
  for (var key in frames) {
483
308
  var newKey = name + resourceKeySplit + key;
484
309
  newFrames[newKey] = frames[key];
485
310
  }
486
-
487
311
  for (var key in animations) {
488
312
  var spriteList = [];
489
-
490
313
  if (animations[key] && animations[key].length >= 0) {
491
314
  try {
492
315
  for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -506,30 +329,24 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
506
329
  }
507
330
  }
508
331
  }
509
-
510
332
  animations[key] = spriteList;
511
333
  }
512
-
513
334
  textureObj.frames = newFrames;
514
335
  var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
515
336
  spriteSheet.parse(function () {
516
337
  var textures = spriteSheet.textures;
517
338
  var spriteFrames = [];
518
-
519
339
  for (var key in textures) {
520
340
  spriteFrames.push(textures[key]);
521
341
  }
522
-
523
342
  r(spriteFrames);
524
343
  });
525
344
  });
526
345
  });
527
346
  eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
528
347
  var e_2, _b;
529
-
530
348
  var instance = _a.instance;
531
349
  if (!instance) return;
532
-
533
350
  try {
534
351
  for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
535
352
  var texture = instance_1_1.value;
@@ -547,35 +364,28 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
547
364
  }
548
365
  }
549
366
  });
550
-
551
367
  var SpriteAnimation = function (_super) {
552
368
  __extends(SpriteAnimation, _super);
553
-
554
369
  function SpriteAnimation() {
555
370
  var _this = _super !== null && _super.apply(this, arguments) || this;
556
-
557
371
  _this.name = 'SpriteAnimation';
558
372
  _this.animates = {};
559
373
  _this.autoPlay = {};
560
374
  return _this;
561
375
  }
562
-
563
376
  SpriteAnimation.prototype.init = function () {
564
377
  this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
565
378
  this.renderSystem.rendererManager.register(this);
566
379
  };
567
-
568
380
  SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
569
381
  var _a = gameObject.transform.size,
570
- width = _a.width,
571
- height = _a.height;
572
-
382
+ width = _a.width,
383
+ height = _a.height;
573
384
  if (this.animates[gameObject.id]) {
574
385
  this.animates[gameObject.id].animatedSprite.width = width;
575
386
  this.animates[gameObject.id].animatedSprite.height = height;
576
387
  }
577
388
  };
578
-
579
389
  SpriteAnimation.prototype.componentChanged = function (changed) {
580
390
  return __awaiter(this, void 0, void 0, function () {
581
391
  var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
@@ -589,99 +399,80 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
589
399
  if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
590
400
  asyncId = this.increaseAsyncId(gameObjectId);
591
401
  return [4, eva_js.resource.getResource(component.resource)];
592
-
593
402
  case 1:
594
403
  frames_1 = _a.sent().instance;
595
404
  if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
596
-
597
405
  if (!frames_1) {
598
406
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
599
407
  }
600
-
601
408
  this.add({
602
409
  frames: frames_1,
603
410
  id: changed.gameObject.id,
604
411
  component: component
605
412
  });
606
413
  return [3, 7];
607
-
608
414
  case 2:
609
415
  if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
610
416
  if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
611
417
  this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
612
418
  return [3, 5];
613
-
614
419
  case 3:
615
420
  asyncId = this.increaseAsyncId(gameObjectId);
616
421
  return [4, eva_js.resource.getResource(component.resource)];
617
-
618
422
  case 4:
619
423
  frames_2 = _a.sent().instance;
620
424
  if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
621
-
622
425
  if (!frames_2) {
623
426
  console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
624
427
  }
625
-
626
428
  this.change({
627
429
  frames: frames_2,
628
430
  id: changed.gameObject.id,
629
431
  component: component
630
432
  });
631
433
  _a.label = 5;
632
-
633
434
  case 5:
634
435
  return [3, 7];
635
-
636
436
  case 6:
637
437
  if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
638
438
  this.increaseAsyncId(gameObjectId);
639
439
  this.remove(changed.gameObject.id);
640
440
  }
641
-
642
441
  _a.label = 7;
643
-
644
442
  case 7:
645
443
  return [2];
646
444
  }
647
445
  });
648
446
  });
649
447
  };
650
-
651
448
  SpriteAnimation.prototype.add = function (_a) {
652
449
  var frames = _a.frames,
653
- id = _a.id,
654
- component = _a.component;
450
+ id = _a.id,
451
+ component = _a.component;
655
452
  var animate = new rendererAdapter.SpriteAnimation({
656
453
  frames: frames
657
454
  });
658
455
  this.animates[id] = animate;
659
456
  this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
660
-
661
457
  animate.animatedSprite.onComplete = function () {
662
458
  component.emit('complete');
663
459
  };
664
-
665
460
  animate.animatedSprite.onFrameChange = function () {
666
461
  component.emit('frameChange');
667
462
  };
668
-
669
463
  animate.animatedSprite.onLoop = function () {
670
464
  component.emit('loop');
671
465
  };
672
-
673
466
  component.animate = this.animates[id];
674
467
  this.animates[id].speed = 1000 / 60 / component.speed;
675
-
676
468
  if (this.autoPlay[id]) {
677
469
  animate.animatedSprite.play();
678
470
  }
679
471
  };
680
-
681
472
  SpriteAnimation.prototype.change = function (_a) {
682
473
  var frames = _a.frames,
683
- id = _a.id,
684
- component = _a.component;
474
+ id = _a.id,
475
+ component = _a.component;
685
476
  this.remove(id, true);
686
477
  this.add({
687
478
  frames: frames,
@@ -689,7 +480,6 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
689
480
  component: component
690
481
  });
691
482
  };
692
-
693
483
  SpriteAnimation.prototype.remove = function (id, isChange) {
694
484
  var animate = this.animates[id];
695
485
  if (!animate) return;
@@ -699,19 +489,16 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
699
489
  children: true
700
490
  });
701
491
  delete this.animates[id];
702
-
703
492
  if (!isChange) {
704
493
  delete this.autoPlay[id];
705
494
  }
706
495
  };
707
-
708
496
  SpriteAnimation.systemName = 'SpriteAnimation';
709
497
  SpriteAnimation = __decorate([eva_js.decorators.componentObserver({
710
498
  SpriteAnimation: ['speed', 'resource']
711
499
  })], SpriteAnimation);
712
500
  return SpriteAnimation;
713
501
  }(pluginRenderer.Renderer);
714
-
715
502
  var SpriteAnimation$1 = SpriteAnimation;
716
503
  exports.SpriteAnimation = SpriteAnimation$3;
717
504
  exports.SpriteAnimationSystem = SpriteAnimation$1;
@@ -720,5 +507,4 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
720
507
  });
721
508
  return exports;
722
509
  }({}, EVA, EVA.plugin.renderer, EVA.rendererAdapter, PIXI);
723
-
724
510
  window.EVA.plugin.renderer.spriteAnimation = window.EVA.plugin.renderer.spriteAnimation || _EVA_IIFE_spriteAnimation;
@@ -1 +1 @@
1
- function _extends(){return _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_extends.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(t,e,n,r,o){"use strict";var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)};function c(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function u(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function l(t,e){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=e.call(t,a)}catch(t){i=[6,t],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 f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}var d=function(t){function e(){var e=this.constructor,n=t.call(this,"Symbol keys are not supported yet!")||this;return Object.setPrototypeOf(n,e.prototype),n}return a(e,t),e}(Error);!function(t){function e(){var e=this.constructor,n=t.call(this,"getProperties is not a function!")||this;return Object.setPrototypeOf(n,e.prototype),n}a(e,t)}(Error);var m,y="IDE_PROPERTY_METADATA";function h(t,e,n,r){var o=Reflect.getMetadata("design:type",t,e),i=o===Array,a=function(t){return t===String?"string":t===Number?"number":t===Boolean?"boolean":"unknown"}(o);if("unknown"!==a&&(o=a),r){var c=r();Array.isArray(c)?(i=!0,o=c[0]):o=c}var p=Reflect.getMetadata(y,t.constructor)||{};p[e]=s({type:o,isArray:i},n),Reflect.defineMetadata(y,p,t.constructor)}function v(t,e){return function(n,r){if("symbol"==typeof r)throw new d;var o=function(t,e){return"function"==typeof t?{returnTypeFunc:t,options:e||{}}:{options:t||{}}}(t,e);h(n,r,o.options,o.returnTypeFunc)}}!function(t){t[t.Edit=2]="Edit",t[t.Game=4]="Game",t[t.All=6]="All"}(m||(m={}));var g=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.autoPlay=!0,e.speed=100,e.forwards=!1,e.waitPlay=!1,e.waitStop=!1,e.times=1/0,e.count=0,e.complete=!1,e}return a(e,t),e.prototype.init=function(t){var e=this;t&&_extends(this,t),this.on("loop",(function(){++e.count>=e.times&&(e.forwards?e.gotoAndStop(e.totalFrames-1):e.animate.stop(),e.complete=!0,e.emit("complete"))}))},e.prototype.play=function(t){void 0===t&&(t=1/0),0!==t&&(this.times=t,this.animate?(this.complete&&this.gotoAndStop(0),this.animate.play(),this.count=0,this.complete=!1):this.waitPlay=!0)},e.prototype.stop=function(){this.animate?this.animate.stop():this.waitStop=!0},Object.defineProperty(e.prototype,"animate",{get:function(){return this._animate},set:function(t){this._animate=t,this.waitPlay&&(this.waitPlay=!1,this.play(this.times)),this.waitStop&&(this.waitStop=!1,this.stop())},enumerable:!1,configurable:!0}),e.prototype.gotoAndPlay=function(t){this.animate.gotoAndPlay(t)},e.prototype.gotoAndStop=function(t){this.animate.gotoAndStop(t)},Object.defineProperty(e.prototype,"currentFrame",{get:function(){var t,e;return null===(e=null===(t=this.animate)||void 0===t?void 0:t.animatedSprite)||void 0===e?void 0:e.currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"totalFrames",{get:function(){var t,e;return null===(e=null===(t=this.animate)||void 0===t?void 0:t.animatedSprite)||void 0===e?void 0:e.totalFrames},enumerable:!1,configurable:!0}),e.componentName="SpriteAnimation",c([v(),p("design:type",String)],e.prototype,"resource",void 0),c([v(),p("design:type",Boolean)],e.prototype,"autoPlay",void 0),c([v({step:10}),p("design:type",Number)],e.prototype,"speed",void 0),c([v(),p("design:type",Boolean)],e.prototype,"forwards",void 0),e}(e.Component),b=g,w="_s|r|c_";e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE_ANIMATION,(function(t){var e=t.name,n=t.data;return new Promise((function(t){var r,i,a=n.json,s=o.BaseTexture.from(n.image),c=a.frames||{},p=a.animations||{},u={};for(var l in c){u[e+w+l]=c[l]}for(var l in p){var d=[];if(p[l]&&p[l].length>=0)try{for(var m=(r=void 0,f(p[l])),y=m.next();!y.done;y=m.next()){var h=y.value,v=e+w+h;d.push(v)}}catch(t){r={error:t}}finally{try{y&&!y.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}p[l]=d}a.frames=u;var g=new o.Spritesheet(s,a);g.parse((function(){var e=g.textures,n=[];for(var r in e)n.push(e[r]);t(n)}))}))})),e.resource.registerDestroy(e.RESOURCE_TYPE.SPRITE_ANIMATION,(function(t){var e,n,r=t.instance;if(r)try{for(var o=f(r),i=o.next();!i.done;i=o.next()){i.value.destroy(!0)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}}));var A=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(n.RendererSystem),this.renderSystem.rendererManager.register(this)},o.prototype.rendererUpdate=function(t){var e=t.transform.size,n=e.width,r=e.height;this.animates[t.id]&&(this.animates[t.id].animatedSprite.width=n,this.animates[t.id].animatedSprite.height=r)},o.prototype.componentChanged=function(t){return u(this,void 0,void 0,(function(){var n,r,o,i,a;return l(this,(function(s){switch(s.label){case 0:return n=t.gameObject.id,"SpriteAnimation"!==t.componentName?[3,7]:(r=t.component,this.autoPlay[t.gameObject.id]=r.autoPlay,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(i=this.increaseAsyncId(n),[4,e.resource.getResource(r.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(n,i)?(o||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.add({frames:o,id:t.gameObject.id,component:r}),[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/r.speed,[3,5]):[3,3];case 3:return i=this.increaseAsyncId(n),[4,e.resource.getResource(r.resource)];case 4:if(a=s.sent().instance,!this.validateAsyncId(n,i))return[2];a||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.change({frames:a,id:t.gameObject.id,component:r}),s.label=5;case 5:return[3,7];case 6:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(n),this.remove(t.gameObject.id)),s.label=7;case 7:return[2]}}))}))},o.prototype.add=function(t){var e=t.frames,n=t.id,o=t.component,i=new r.SpriteAnimation({frames:e});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(t){var e=t.frames,n=t.id,r=t.component;this.remove(n,!0),this.add({frames:e,id:n,component:r})},o.prototype.remove=function(t,e){var n=this.animates[t];n&&(this.autoPlay[t]=n.animatedSprite.playing,this.containerManager.getContainer(t).removeChild(n.animatedSprite),n.animatedSprite.destroy({children:!0}),delete this.animates[t],e||delete this.autoPlay[t])},o.systemName="SpriteAnimation",o=c([e.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(n.Renderer),S=A;return t.SpriteAnimation=b,t.SpriteAnimationSystem=S,Object.defineProperty(t,"__esModule",{value:!0}),t}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);window.EVA.plugin.renderer.spriteAnimation=window.EVA.plugin.renderer.spriteAnimation||_EVA_IIFE_spriteAnimation;
1
+ function _extends(){return _extends=Object.assign?Object.assign.bind():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},_extends.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])},i(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=f,y="_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+y+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])),h=f.next();!h.done;h=f.next()){var v=h.value,g=t+y+v;m.push(g)}}catch(e){r={error:e}}finally{try{h&&!h.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 v=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),g=v;return e.SpriteAnimation=h,e.SpriteAnimationSystem=g,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;
@@ -0,0 +1,319 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
+ import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
3
+ import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
4
+ import { type, step } from '@eva/inspector-decorator';
5
+ import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
6
+ import { SpriteAnimation as SpriteAnimation$4 } from '@eva/renderer-adapter/dist/miniprogram';
7
+ import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
8
+ var SpriteAnimation$2 = function (_super) {
9
+ __extends(SpriteAnimation, _super);
10
+ function SpriteAnimation() {
11
+ var _this = _super !== null && _super.apply(this, arguments) || this;
12
+ _this.resource = '';
13
+ _this.autoPlay = true;
14
+ _this.speed = 100;
15
+ _this.forwards = false;
16
+ _this.waitPlay = false;
17
+ _this.waitStop = false;
18
+ _this.times = Infinity;
19
+ _this.count = 0;
20
+ _this.complete = false;
21
+ return _this;
22
+ }
23
+ SpriteAnimation.prototype.init = function (obj) {
24
+ var _this = this;
25
+ obj && _extends(this, obj);
26
+ this.on('loop', function () {
27
+ if (++_this.count >= _this.times) {
28
+ if (_this.forwards) {
29
+ _this.gotoAndStop(_this.totalFrames - 1);
30
+ } else {
31
+ _this.animate.stop();
32
+ }
33
+ _this.complete = true;
34
+ _this.emit('complete');
35
+ }
36
+ });
37
+ };
38
+ SpriteAnimation.prototype.play = function (times) {
39
+ if (times === void 0) {
40
+ times = Infinity;
41
+ }
42
+ if (times === 0) {
43
+ return;
44
+ }
45
+ this.times = times;
46
+ if (!this.animate) {
47
+ this.waitPlay = true;
48
+ } else {
49
+ if (this.complete) {
50
+ this.gotoAndStop(0);
51
+ }
52
+ this.animate.play();
53
+ this.count = 0;
54
+ this.complete = false;
55
+ }
56
+ };
57
+ SpriteAnimation.prototype.stop = function () {
58
+ if (!this.animate) {
59
+ this.waitStop = true;
60
+ } else {
61
+ this.animate.stop();
62
+ }
63
+ };
64
+ Object.defineProperty(SpriteAnimation.prototype, "animate", {
65
+ get: function get() {
66
+ return this._animate;
67
+ },
68
+ set: function set(val) {
69
+ this._animate = val;
70
+ if (this.waitPlay) {
71
+ this.waitPlay = false;
72
+ this.play(this.times);
73
+ }
74
+ if (this.waitStop) {
75
+ this.waitStop = false;
76
+ this.stop();
77
+ }
78
+ },
79
+ enumerable: false,
80
+ configurable: true
81
+ });
82
+ SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
83
+ this.animate.gotoAndPlay(frameNumber);
84
+ };
85
+ SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
86
+ this.animate.gotoAndStop(frameNumber);
87
+ };
88
+ Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
89
+ get: function get() {
90
+ var _a, _b;
91
+ return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
92
+ },
93
+ enumerable: false,
94
+ configurable: true
95
+ });
96
+ Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
97
+ get: function get() {
98
+ var _a, _b;
99
+ return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
100
+ },
101
+ enumerable: false,
102
+ configurable: true
103
+ });
104
+ SpriteAnimation.componentName = 'SpriteAnimation';
105
+ __decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
106
+ __decorate([type('boolean')], SpriteAnimation.prototype, "autoPlay", void 0);
107
+ __decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
108
+ __decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
109
+ return SpriteAnimation;
110
+ }(Component);
111
+ var SpriteAnimation$3 = SpriteAnimation$2;
112
+ var resourceKeySplit = '_s|r|c_';
113
+ resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
114
+ var name = _a.name,
115
+ data = _a.data;
116
+ return new Promise(function (r) {
117
+ var e_1, _a;
118
+ var textureObj = data.json;
119
+ var texture = BaseTexture.from(data.image);
120
+ var frames = textureObj.frames || {};
121
+ var animations = textureObj.animations || {};
122
+ var newFrames = {};
123
+ for (var key in frames) {
124
+ var newKey = name + resourceKeySplit + key;
125
+ newFrames[newKey] = frames[key];
126
+ }
127
+ for (var key in animations) {
128
+ var spriteList = [];
129
+ if (animations[key] && animations[key].length >= 0) {
130
+ try {
131
+ for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
132
+ var spriteName = _c.value;
133
+ var newSpriteName = name + resourceKeySplit + spriteName;
134
+ spriteList.push(newSpriteName);
135
+ }
136
+ } catch (e_1_1) {
137
+ e_1 = {
138
+ error: e_1_1
139
+ };
140
+ } finally {
141
+ try {
142
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
143
+ } finally {
144
+ if (e_1) throw e_1.error;
145
+ }
146
+ }
147
+ }
148
+ animations[key] = spriteList;
149
+ }
150
+ textureObj.frames = newFrames;
151
+ var spriteSheet = new Spritesheet(texture, textureObj);
152
+ spriteSheet.parse(function () {
153
+ var textures = spriteSheet.textures;
154
+ var spriteFrames = [];
155
+ for (var key in textures) {
156
+ spriteFrames.push(textures[key]);
157
+ }
158
+ r(spriteFrames);
159
+ });
160
+ });
161
+ });
162
+ resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
163
+ var e_2, _b;
164
+ var instance = _a.instance;
165
+ if (!instance) return;
166
+ try {
167
+ for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
168
+ var texture = instance_1_1.value;
169
+ texture.destroy(true);
170
+ }
171
+ } catch (e_2_1) {
172
+ e_2 = {
173
+ error: e_2_1
174
+ };
175
+ } finally {
176
+ try {
177
+ if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
178
+ } finally {
179
+ if (e_2) throw e_2.error;
180
+ }
181
+ }
182
+ });
183
+ var SpriteAnimation = function (_super) {
184
+ __extends(SpriteAnimation, _super);
185
+ function SpriteAnimation() {
186
+ var _this = _super !== null && _super.apply(this, arguments) || this;
187
+ _this.name = 'SpriteAnimation';
188
+ _this.animates = {};
189
+ _this.autoPlay = {};
190
+ return _this;
191
+ }
192
+ SpriteAnimation.prototype.init = function () {
193
+ this.renderSystem = this.game.getSystem(RendererSystem);
194
+ this.renderSystem.rendererManager.register(this);
195
+ };
196
+ SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
197
+ var _a = gameObject.transform.size,
198
+ width = _a.width,
199
+ height = _a.height;
200
+ if (this.animates[gameObject.id]) {
201
+ this.animates[gameObject.id].animatedSprite.width = width;
202
+ this.animates[gameObject.id].animatedSprite.height = height;
203
+ }
204
+ };
205
+ SpriteAnimation.prototype.componentChanged = function (changed) {
206
+ return __awaiter(this, void 0, void 0, function () {
207
+ var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
208
+ return __generator(this, function (_a) {
209
+ switch (_a.label) {
210
+ case 0:
211
+ gameObjectId = changed.gameObject.id;
212
+ if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
213
+ component = changed.component;
214
+ this.autoPlay[changed.gameObject.id] = component.autoPlay;
215
+ if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
216
+ asyncId = this.increaseAsyncId(gameObjectId);
217
+ return [4, resource.getResource(component.resource)];
218
+ case 1:
219
+ frames_1 = _a.sent().instance;
220
+ if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
221
+ if (!frames_1) {
222
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
223
+ }
224
+ this.add({
225
+ frames: frames_1,
226
+ id: changed.gameObject.id,
227
+ component: component
228
+ });
229
+ return [3, 7];
230
+ case 2:
231
+ if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 6];
232
+ if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
233
+ this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
234
+ return [3, 5];
235
+ case 3:
236
+ asyncId = this.increaseAsyncId(gameObjectId);
237
+ return [4, resource.getResource(component.resource)];
238
+ case 4:
239
+ frames_2 = _a.sent().instance;
240
+ if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
241
+ if (!frames_2) {
242
+ console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
243
+ }
244
+ this.change({
245
+ frames: frames_2,
246
+ id: changed.gameObject.id,
247
+ component: component
248
+ });
249
+ _a.label = 5;
250
+ case 5:
251
+ return [3, 7];
252
+ case 6:
253
+ if (changed.type === OBSERVER_TYPE.REMOVE) {
254
+ this.increaseAsyncId(gameObjectId);
255
+ this.remove(changed.gameObject.id);
256
+ }
257
+ _a.label = 7;
258
+ case 7:
259
+ return [2];
260
+ }
261
+ });
262
+ });
263
+ };
264
+ SpriteAnimation.prototype.add = function (_a) {
265
+ var frames = _a.frames,
266
+ id = _a.id,
267
+ component = _a.component;
268
+ var animate = new SpriteAnimation$4({
269
+ frames: frames
270
+ });
271
+ this.animates[id] = animate;
272
+ this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
273
+ animate.animatedSprite.onComplete = function () {
274
+ component.emit('complete');
275
+ };
276
+ animate.animatedSprite.onFrameChange = function () {
277
+ component.emit('frameChange');
278
+ };
279
+ animate.animatedSprite.onLoop = function () {
280
+ component.emit('loop');
281
+ };
282
+ component.animate = this.animates[id];
283
+ this.animates[id].speed = 1000 / 60 / component.speed;
284
+ if (this.autoPlay[id]) {
285
+ animate.animatedSprite.play();
286
+ }
287
+ };
288
+ SpriteAnimation.prototype.change = function (_a) {
289
+ var frames = _a.frames,
290
+ id = _a.id,
291
+ component = _a.component;
292
+ this.remove(id, true);
293
+ this.add({
294
+ frames: frames,
295
+ id: id,
296
+ component: component
297
+ });
298
+ };
299
+ SpriteAnimation.prototype.remove = function (id, isChange) {
300
+ var animate = this.animates[id];
301
+ if (!animate) return;
302
+ this.autoPlay[id] = animate.animatedSprite.playing;
303
+ this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
304
+ animate.animatedSprite.destroy({
305
+ children: true
306
+ });
307
+ delete this.animates[id];
308
+ if (!isChange) {
309
+ delete this.autoPlay[id];
310
+ }
311
+ };
312
+ SpriteAnimation.systemName = 'SpriteAnimation';
313
+ SpriteAnimation = __decorate([decorators.componentObserver({
314
+ SpriteAnimation: ['speed', 'resource']
315
+ })], SpriteAnimation);
316
+ return SpriteAnimation;
317
+ }(Renderer);
318
+ var SpriteAnimation$1 = SpriteAnimation;
319
+ export { SpriteAnimation$3 as SpriteAnimation, SpriteAnimation$1 as SpriteAnimationSystem };
@@ -44,10 +44,6 @@ function __decorate(decorators, target, key, desc) {
44
44
  return c > 3 && r && Object.defineProperty(target, key, r), r;
45
45
  }
46
46
 
47
- function __metadata(metadataKey, metadataValue) {
48
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
49
- }
50
-
51
47
  function __awaiter(thisArg, _arguments, P, generator) {
52
48
  return new (P || (P = Promise))(function (resolve, reject) {
53
49
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -195,20 +191,17 @@ var SpriteAnimation$2 = (function (_super) {
195
191
  });
196
192
  SpriteAnimation.componentName = 'SpriteAnimation';
197
193
  __decorate([
198
- inspectorDecorator.Field(),
199
- __metadata("design:type", String)
194
+ inspectorDecorator.type('string')
200
195
  ], SpriteAnimation.prototype, "resource", void 0);
201
196
  __decorate([
202
- inspectorDecorator.Field(),
203
- __metadata("design:type", Boolean)
197
+ inspectorDecorator.type('boolean')
204
198
  ], SpriteAnimation.prototype, "autoPlay", void 0);
205
199
  __decorate([
206
- inspectorDecorator.Field({ step: 10 }),
207
- __metadata("design:type", Number)
200
+ inspectorDecorator.type('number'),
201
+ inspectorDecorator.step(10)
208
202
  ], SpriteAnimation.prototype, "speed", void 0);
209
203
  __decorate([
210
- inspectorDecorator.Field(),
211
- __metadata("design:type", Boolean)
204
+ inspectorDecorator.type('boolean')
212
205
  ], SpriteAnimation.prototype, "forwards", void 0);
213
206
  return SpriteAnimation;
214
207
  }(eva_js.Component));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/inspector-decorator"),n=require("@eva/plugin-renderer"),r=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 n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},i(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){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}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&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}var l=function(e){function n(){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(n,e),n.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"))}))},n.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)},n.prototype.stop=function(){this.animate?this.animate.stop():this.waitStop=!0},Object.defineProperty(n.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}),n.prototype.gotoAndPlay=function(e){this.animate.gotoAndPlay(e)},n.prototype.gotoAndStop=function(e){this.animate.gotoAndStop(e)},Object.defineProperty(n.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(n.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}),n.componentName="SpriteAnimation",s([t.Field(),c("design:type",String)],n.prototype,"resource",void 0),s([t.Field(),c("design:type",Boolean)],n.prototype,"autoPlay",void 0),s([t.Field({step:10}),c("design:type",Number)],n.prototype,"speed",void 0),s([t.Field(),c("design:type",Boolean)],n.prototype,"forwards",void 0),n}(e.Component),d=l;e.resource.registerInstance(e.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+"_s|r|c_"+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])),h=f.next();!h.done;h=f.next()){var y=h.value,v=t+"_s|r|c_"+y;m.push(v)}}catch(e){r={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}p[d]=m}a.frames=l;var g=new o.Spritesheet(s,a);g.parse((function(){var t=g.textures,n=[];for(var r in t)n.push(t[r]);e(n)}))}))})),e.resource.registerDestroy(e.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 m=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(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(t){return n=this,r=void 0,i=function(){var n,r,o,i,a;return p(this,(function(s){switch(s.label){case 0:return n=t.gameObject.id,"SpriteAnimation"!==t.componentName?[3,7]:(r=t.component,this.autoPlay[t.gameObject.id]=r.autoPlay,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:(i=this.increaseAsyncId(n),[4,e.resource.getResource(r.resource)]));case 1:return o=s.sent().instance,this.validateAsyncId(n,i)?(o||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.add({frames:o,id:t.gameObject.id,component:r}),[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/r.speed,[3,5]):[3,3];case 3:return i=this.increaseAsyncId(n),[4,e.resource.getResource(r.resource)];case 4:if(a=s.sent().instance,!this.validateAsyncId(n,i))return[2];a||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.change({frames:a,id:t.gameObject.id,component:r}),s.label=5;case 5:return[3,7];case 6:t.type===e.OBSERVER_TYPE.REMOVE&&(this.increaseAsyncId(n),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(n,r||[])).next())}));var n,r,o,i},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([e.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(n.Renderer);exports.SpriteAnimation=d,exports.SpriteAnimationSystem=m;
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])},i(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),l=u;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 m=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=l,exports.SpriteAnimationSystem=m;
@@ -1,5 +1,5 @@
1
1
  import { Component, resource, RESOURCE_TYPE, decorators, OBSERVER_TYPE } from '@eva/eva.js';
2
- import { Field } from '@eva/inspector-decorator';
2
+ import { type, step } from '@eva/inspector-decorator';
3
3
  import { RendererSystem, Renderer } from '@eva/plugin-renderer';
4
4
  import { SpriteAnimation as SpriteAnimation$4 } from '@eva/renderer-adapter';
5
5
  import { BaseTexture, Spritesheet } from 'pixi.js';
@@ -40,10 +40,6 @@ function __decorate(decorators, target, key, desc) {
40
40
  return c > 3 && r && Object.defineProperty(target, key, r), r;
41
41
  }
42
42
 
43
- function __metadata(metadataKey, metadataValue) {
44
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
45
- }
46
-
47
43
  function __awaiter(thisArg, _arguments, P, generator) {
48
44
  return new (P || (P = Promise))(function (resolve, reject) {
49
45
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -191,20 +187,17 @@ var SpriteAnimation$2 = (function (_super) {
191
187
  });
192
188
  SpriteAnimation.componentName = 'SpriteAnimation';
193
189
  __decorate([
194
- Field(),
195
- __metadata("design:type", String)
190
+ type('string')
196
191
  ], SpriteAnimation.prototype, "resource", void 0);
197
192
  __decorate([
198
- Field(),
199
- __metadata("design:type", Boolean)
193
+ type('boolean')
200
194
  ], SpriteAnimation.prototype, "autoPlay", void 0);
201
195
  __decorate([
202
- Field({ step: 10 }),
203
- __metadata("design:type", Number)
196
+ type('number'),
197
+ step(10)
204
198
  ], SpriteAnimation.prototype, "speed", void 0);
205
199
  __decorate([
206
- Field(),
207
- __metadata("design:type", Boolean)
200
+ type('boolean')
208
201
  ], SpriteAnimation.prototype, "forwards", void 0);
209
202
  return SpriteAnimation;
210
203
  }(Component));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-sprite-animation",
3
- "version": "1.2.7-editor.8",
3
+ "version": "1.2.7-fix.4",
4
4
  "description": "@eva/plugin-renderer-sprite-animation",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-sprite-animation.esm.js",
@@ -18,10 +18,10 @@
18
18
  "license": "MIT",
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
- "@eva/inspector-decorator": "0.1.0-alpha.2",
22
- "@eva/plugin-renderer": "1.2.7-editor.8",
23
- "@eva/renderer-adapter": "1.2.7-editor.8",
24
- "@eva/eva.js": "1.2.7-editor.8",
21
+ "@eva/inspector-decorator": "^0.0.5",
22
+ "@eva/plugin-renderer": "1.2.7-fix.4",
23
+ "@eva/renderer-adapter": "1.2.7-fix.4",
24
+ "@eva/eva.js": "1.2.7-fix.4",
25
25
  "pixi.js": "^4.8.7"
26
26
  }
27
27
  }