@eva/plugin-renderer-sprite-animation 1.2.2-mini.1 → 1.2.2-mini.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -238,6 +238,7 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
238
238
|
_this.resource = '';
|
|
239
239
|
_this.autoPlay = true;
|
|
240
240
|
_this.speed = 100;
|
|
241
|
+
_this.forwards = false;
|
|
241
242
|
_this.waitPlay = false;
|
|
242
243
|
_this.waitStop = false;
|
|
243
244
|
_this.times = Infinity;
|
|
@@ -251,9 +252,13 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
251
252
|
obj && _extends(this, obj);
|
|
252
253
|
this.on('loop', function () {
|
|
253
254
|
if (++_this.count >= _this.times) {
|
|
254
|
-
_this.
|
|
255
|
+
if (_this.forwards) {
|
|
256
|
+
_this.animate.animatedSprite.loop = false;
|
|
257
|
+
} else {
|
|
258
|
+
_this.animate.stop();
|
|
255
259
|
|
|
256
|
-
|
|
260
|
+
_this.emit('complete');
|
|
261
|
+
}
|
|
257
262
|
}
|
|
258
263
|
});
|
|
259
264
|
};
|
|
@@ -272,6 +277,10 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
272
277
|
if (!this.animate) {
|
|
273
278
|
this.waitPlay = true;
|
|
274
279
|
} else {
|
|
280
|
+
if (times === 1 && this.forwards) {
|
|
281
|
+
this.animate.animatedSprite.loop = false;
|
|
282
|
+
}
|
|
283
|
+
|
|
275
284
|
this.animate.play();
|
|
276
285
|
this.count = 0;
|
|
277
286
|
}
|
|
@@ -314,6 +323,24 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
314
323
|
this.animate.gotoAndStop(frameNumber);
|
|
315
324
|
};
|
|
316
325
|
|
|
326
|
+
Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
|
|
327
|
+
get: function get() {
|
|
328
|
+
var _a, _b;
|
|
329
|
+
|
|
330
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
331
|
+
},
|
|
332
|
+
enumerable: false,
|
|
333
|
+
configurable: true
|
|
334
|
+
});
|
|
335
|
+
Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
|
|
336
|
+
get: function get() {
|
|
337
|
+
var _a, _b;
|
|
338
|
+
|
|
339
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
340
|
+
},
|
|
341
|
+
enumerable: false,
|
|
342
|
+
configurable: true
|
|
343
|
+
});
|
|
317
344
|
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
318
345
|
|
|
319
346
|
__decorate([type('string')], SpriteAnimation.prototype, "resource", void 0);
|
|
@@ -322,6 +349,8 @@ var _EVA_IIFE_spriteAnimation = function (exports, eva_js, pluginRenderer, rende
|
|
|
322
349
|
|
|
323
350
|
__decorate([type('number'), step(10)], SpriteAnimation.prototype, "speed", void 0);
|
|
324
351
|
|
|
352
|
+
__decorate([type('boolean')], SpriteAnimation.prototype, "forwards", void 0);
|
|
353
|
+
|
|
325
354
|
return SpriteAnimation;
|
|
326
355
|
}(eva_js.Component);
|
|
327
356
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return(_extends=Object.assign||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)}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 m(e){return function(t,n){var r=l(t,n);r.key=n,r.type=e}}function f(e){return function(t,n){l(t,n).step=e}}var d=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}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.animate.animatedSprite.loop=!1:(t.animate.stop(),t.emit("complete")))}))},t.prototype.play=function(e){void 0===e&&(e=1/0),0!==e&&(this.times=e,this.animate?(1===e&&this.forwards&&(this.animate.animatedSprite.loop=!1),this.animate.play(),this.count=0):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([m("string")],t.prototype,"resource",void 0),s([m("boolean")],t.prototype,"autoPlay",void 0),s([m("number"),f(10)],t.prototype,"speed",void 0),s([m("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 m in c){l[t+h+m]=c[m]}for(var m in p){var f=[];if(p[m]&&p[m].length>=0)try{for(var d=(r=void 0,u(p[m])),y=d.next();!y.done;y=d.next()){var v=y.value,b=t+h+v;f.push(b)}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}p[m]=f}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)}))}))})),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;return p(this,(function(i){switch(i.label){case 0:return"SpriteAnimation"!==e.componentName?[3,7]:(n=e.component,this.autoPlay[e.gameObject.id]=n.autoPlay,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:[4,t.resource.getResource(n.resource)]);case 1:return(r=i.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.add({frames:r,id:e.gameObject.id,component:n}),[3,7];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/n.speed,[3,5]):[3,3];case 3:return[4,t.resource.getResource(n.resource)];case 4:(o=i.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.change({frames:o,id:e.gameObject.id,component:n}),i.label=5;case 5:return[3,7];case 6:e.type===t.OBSERVER_TYPE.REMOVE&&this.remove(e.gameObject.id),i.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];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=d,e.SpriteAnimationSystem=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({},EVA,EVA.plugin.renderer,EVA.rendererAdapter,PIXI);
|
|
@@ -95,6 +95,7 @@ var SpriteAnimation$2 = (function (_super) {
|
|
|
95
95
|
_this.resource = '';
|
|
96
96
|
_this.autoPlay = true;
|
|
97
97
|
_this.speed = 100;
|
|
98
|
+
_this.forwards = false;
|
|
98
99
|
_this.waitPlay = false;
|
|
99
100
|
_this.waitStop = false;
|
|
100
101
|
_this.times = Infinity;
|
|
@@ -106,8 +107,13 @@ var SpriteAnimation$2 = (function (_super) {
|
|
|
106
107
|
obj && Object.assign(this, obj);
|
|
107
108
|
this.on('loop', function () {
|
|
108
109
|
if (++_this.count >= _this.times) {
|
|
109
|
-
_this.
|
|
110
|
-
|
|
110
|
+
if (_this.forwards) {
|
|
111
|
+
_this.animate.animatedSprite.loop = false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
_this.animate.stop();
|
|
115
|
+
_this.emit('complete');
|
|
116
|
+
}
|
|
111
117
|
}
|
|
112
118
|
});
|
|
113
119
|
};
|
|
@@ -121,6 +127,9 @@ var SpriteAnimation$2 = (function (_super) {
|
|
|
121
127
|
this.waitPlay = true;
|
|
122
128
|
}
|
|
123
129
|
else {
|
|
130
|
+
if (times === 1 && this.forwards) {
|
|
131
|
+
this.animate.animatedSprite.loop = false;
|
|
132
|
+
}
|
|
124
133
|
this.animate.play();
|
|
125
134
|
this.count = 0;
|
|
126
135
|
}
|
|
@@ -157,6 +166,22 @@ var SpriteAnimation$2 = (function (_super) {
|
|
|
157
166
|
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
158
167
|
this.animate.gotoAndStop(frameNumber);
|
|
159
168
|
};
|
|
169
|
+
Object.defineProperty(SpriteAnimation.prototype, "currentFrame", {
|
|
170
|
+
get: function () {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.currentFrame;
|
|
173
|
+
},
|
|
174
|
+
enumerable: false,
|
|
175
|
+
configurable: true
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(SpriteAnimation.prototype, "totalFrames", {
|
|
178
|
+
get: function () {
|
|
179
|
+
var _a, _b;
|
|
180
|
+
return (_b = (_a = this.animate) === null || _a === void 0 ? void 0 : _a.animatedSprite) === null || _b === void 0 ? void 0 : _b.totalFrames;
|
|
181
|
+
},
|
|
182
|
+
enumerable: false,
|
|
183
|
+
configurable: true
|
|
184
|
+
});
|
|
160
185
|
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
161
186
|
__decorate([
|
|
162
187
|
type('string')
|
|
@@ -168,6 +193,9 @@ var SpriteAnimation$2 = (function (_super) {
|
|
|
168
193
|
type('number'),
|
|
169
194
|
step(10)
|
|
170
195
|
], SpriteAnimation.prototype, "speed", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
type('boolean')
|
|
198
|
+
], SpriteAnimation.prototype, "forwards", void 0);
|
|
171
199
|
return SpriteAnimation;
|
|
172
200
|
}(Component));
|
|
173
201
|
var SpriteAnimation$3 = SpriteAnimation$2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "1.2.2-mini.
|
|
3
|
+
"version": "1.2.2-mini.3",
|
|
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.2-mini.
|
|
23
|
-
"@eva/renderer-adapter": "1.2.2-mini.
|
|
24
|
-
"@eva/eva.js": "1.2.2-mini.
|
|
22
|
+
"@eva/plugin-renderer": "1.2.2-mini.3",
|
|
23
|
+
"@eva/renderer-adapter": "1.2.2-mini.3",
|
|
24
|
+
"@eva/eva.js": "1.2.2-mini.3",
|
|
25
25
|
"pixi.js": "^4.8.7"
|
|
26
26
|
}
|
|
27
27
|
}
|