@eva/plugin-renderer-sprite-animation 1.2.5 → 1.2.7
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 +8 -1
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js +1 -1
- package/dist/miniprogram.js +8 -1
- package/dist/plugin-renderer-sprite-animation.cjs.js +13 -2
- package/dist/plugin-renderer-sprite-animation.cjs.prod.js +1 -1
- package/dist/plugin-renderer-sprite-animation.esm.js +13 -2
- package/package.json +4 -4
|
@@ -471,18 +471,21 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
471
471
|
|
|
472
472
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
473
473
|
return __awaiter(this, void 0, void 0, function () {
|
|
474
|
-
var component, frames_1, frames_2;
|
|
474
|
+
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
475
475
|
return __generator(this, function (_a) {
|
|
476
476
|
switch (_a.label) {
|
|
477
477
|
case 0:
|
|
478
|
+
gameObjectId = changed.gameObject.id;
|
|
478
479
|
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
479
480
|
component = changed.component;
|
|
480
481
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
481
482
|
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
483
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
482
484
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
483
485
|
|
|
484
486
|
case 1:
|
|
485
487
|
frames_1 = _a.sent().instance;
|
|
488
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
486
489
|
|
|
487
490
|
if (!frames_1) {
|
|
488
491
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
@@ -502,10 +505,12 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
502
505
|
return [3, 5];
|
|
503
506
|
|
|
504
507
|
case 3:
|
|
508
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
505
509
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
506
510
|
|
|
507
511
|
case 4:
|
|
508
512
|
frames_2 = _a.sent().instance;
|
|
513
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
509
514
|
|
|
510
515
|
if (!frames_2) {
|
|
511
516
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
@@ -523,6 +528,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
523
528
|
|
|
524
529
|
case 6:
|
|
525
530
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
531
|
+
this.increaseAsyncId(gameObjectId);
|
|
526
532
|
this.remove(changed.gameObject.id);
|
|
527
533
|
}
|
|
528
534
|
|
|
@@ -579,6 +585,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
579
585
|
|
|
580
586
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
581
587
|
var animate = this.animates[id];
|
|
588
|
+
if (!animate) return;
|
|
582
589
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
583
590
|
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
584
591
|
animate.animatedSprite.destroy({
|
|
@@ -1 +1 @@
|
|
|
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)}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
|
|
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
|
@@ -249,18 +249,21 @@ var SpriteAnimation = function (_super) {
|
|
|
249
249
|
|
|
250
250
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
251
251
|
return __awaiter(this, void 0, void 0, function () {
|
|
252
|
-
var component, frames_1, frames_2;
|
|
252
|
+
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
253
253
|
return __generator(this, function (_a) {
|
|
254
254
|
switch (_a.label) {
|
|
255
255
|
case 0:
|
|
256
|
+
gameObjectId = changed.gameObject.id;
|
|
256
257
|
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
257
258
|
component = changed.component;
|
|
258
259
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
259
260
|
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
261
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
260
262
|
return [4, resource.getResource(component.resource)];
|
|
261
263
|
|
|
262
264
|
case 1:
|
|
263
265
|
frames_1 = _a.sent().instance;
|
|
266
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
264
267
|
|
|
265
268
|
if (!frames_1) {
|
|
266
269
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
@@ -280,10 +283,12 @@ var SpriteAnimation = function (_super) {
|
|
|
280
283
|
return [3, 5];
|
|
281
284
|
|
|
282
285
|
case 3:
|
|
286
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
283
287
|
return [4, resource.getResource(component.resource)];
|
|
284
288
|
|
|
285
289
|
case 4:
|
|
286
290
|
frames_2 = _a.sent().instance;
|
|
291
|
+
if (!this.validateAsyncId(gameObjectId, asyncId)) return [2];
|
|
287
292
|
|
|
288
293
|
if (!frames_2) {
|
|
289
294
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
@@ -301,6 +306,7 @@ var SpriteAnimation = function (_super) {
|
|
|
301
306
|
|
|
302
307
|
case 6:
|
|
303
308
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
309
|
+
this.increaseAsyncId(gameObjectId);
|
|
304
310
|
this.remove(changed.gameObject.id);
|
|
305
311
|
}
|
|
306
312
|
|
|
@@ -357,6 +363,7 @@ var SpriteAnimation = function (_super) {
|
|
|
357
363
|
|
|
358
364
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
359
365
|
var animate = this.animates[id];
|
|
366
|
+
if (!animate) return;
|
|
360
367
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
361
368
|
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
362
369
|
animate.animatedSprite.destroy({
|
|
@@ -294,17 +294,21 @@ var SpriteAnimation = (function (_super) {
|
|
|
294
294
|
};
|
|
295
295
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
296
296
|
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
-
var component, frames_1, frames_2;
|
|
297
|
+
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
298
298
|
return __generator(this, function (_a) {
|
|
299
299
|
switch (_a.label) {
|
|
300
300
|
case 0:
|
|
301
|
+
gameObjectId = changed.gameObject.id;
|
|
301
302
|
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
302
303
|
component = changed.component;
|
|
303
304
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
304
305
|
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
306
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
305
307
|
return [4, eva_js.resource.getResource(component.resource)];
|
|
306
308
|
case 1:
|
|
307
309
|
frames_1 = (_a.sent()).instance;
|
|
310
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
311
|
+
return [2];
|
|
308
312
|
if (!frames_1) {
|
|
309
313
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
310
314
|
}
|
|
@@ -319,9 +323,13 @@ var SpriteAnimation = (function (_super) {
|
|
|
319
323
|
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
320
324
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
321
325
|
return [3, 5];
|
|
322
|
-
case 3:
|
|
326
|
+
case 3:
|
|
327
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
328
|
+
return [4, eva_js.resource.getResource(component.resource)];
|
|
323
329
|
case 4:
|
|
324
330
|
frames_2 = (_a.sent()).instance;
|
|
331
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
332
|
+
return [2];
|
|
325
333
|
if (!frames_2) {
|
|
326
334
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
327
335
|
}
|
|
@@ -334,6 +342,7 @@ var SpriteAnimation = (function (_super) {
|
|
|
334
342
|
case 5: return [3, 7];
|
|
335
343
|
case 6:
|
|
336
344
|
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
345
|
+
this.increaseAsyncId(gameObjectId);
|
|
337
346
|
this.remove(changed.gameObject.id);
|
|
338
347
|
}
|
|
339
348
|
_a.label = 7;
|
|
@@ -369,6 +378,8 @@ var SpriteAnimation = (function (_super) {
|
|
|
369
378
|
};
|
|
370
379
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
371
380
|
var animate = this.animates[id];
|
|
381
|
+
if (!animate)
|
|
382
|
+
return;
|
|
372
383
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
373
384
|
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
374
385
|
animate.animatedSprite.destroy({ children: true });
|
|
@@ -1 +1 @@
|
|
|
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;return c(this,(function(
|
|
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;
|
|
@@ -290,17 +290,21 @@ var SpriteAnimation = (function (_super) {
|
|
|
290
290
|
};
|
|
291
291
|
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
292
292
|
return __awaiter(this, void 0, void 0, function () {
|
|
293
|
-
var component, frames_1, frames_2;
|
|
293
|
+
var gameObjectId, component, asyncId, frames_1, asyncId, frames_2;
|
|
294
294
|
return __generator(this, function (_a) {
|
|
295
295
|
switch (_a.label) {
|
|
296
296
|
case 0:
|
|
297
|
+
gameObjectId = changed.gameObject.id;
|
|
297
298
|
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
298
299
|
component = changed.component;
|
|
299
300
|
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
300
301
|
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
302
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
301
303
|
return [4, resource.getResource(component.resource)];
|
|
302
304
|
case 1:
|
|
303
305
|
frames_1 = (_a.sent()).instance;
|
|
306
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
307
|
+
return [2];
|
|
304
308
|
if (!frames_1) {
|
|
305
309
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
306
310
|
}
|
|
@@ -315,9 +319,13 @@ var SpriteAnimation = (function (_super) {
|
|
|
315
319
|
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
316
320
|
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
317
321
|
return [3, 5];
|
|
318
|
-
case 3:
|
|
322
|
+
case 3:
|
|
323
|
+
asyncId = this.increaseAsyncId(gameObjectId);
|
|
324
|
+
return [4, resource.getResource(component.resource)];
|
|
319
325
|
case 4:
|
|
320
326
|
frames_2 = (_a.sent()).instance;
|
|
327
|
+
if (!this.validateAsyncId(gameObjectId, asyncId))
|
|
328
|
+
return [2];
|
|
321
329
|
if (!frames_2) {
|
|
322
330
|
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
323
331
|
}
|
|
@@ -330,6 +338,7 @@ var SpriteAnimation = (function (_super) {
|
|
|
330
338
|
case 5: return [3, 7];
|
|
331
339
|
case 6:
|
|
332
340
|
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
341
|
+
this.increaseAsyncId(gameObjectId);
|
|
333
342
|
this.remove(changed.gameObject.id);
|
|
334
343
|
}
|
|
335
344
|
_a.label = 7;
|
|
@@ -365,6 +374,8 @@ var SpriteAnimation = (function (_super) {
|
|
|
365
374
|
};
|
|
366
375
|
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
367
376
|
var animate = this.animates[id];
|
|
377
|
+
if (!animate)
|
|
378
|
+
return;
|
|
368
379
|
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
369
380
|
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
370
381
|
animate.animatedSprite.destroy({ children: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
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.
|
|
23
|
-
"@eva/renderer-adapter": "1.2.
|
|
24
|
-
"@eva/eva.js": "1.2.
|
|
22
|
+
"@eva/plugin-renderer": "1.2.7",
|
|
23
|
+
"@eva/renderer-adapter": "1.2.7",
|
|
24
|
+
"@eva/eva.js": "1.2.7",
|
|
25
25
|
"pixi.js": "^4.8.7"
|
|
26
26
|
}
|
|
27
27
|
}
|