@eva/plugin-renderer-sprite-animation 1.1.1-fix.0 → 1.1.1-fix.1
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/plugin-renderer-sprite-animation.cjs.prod.js +1 -1
- package/package.json +4 -4
- package/dist/EVA.plugin.renderer.spriteAnimation.js +0 -361
- package/dist/EVA.plugin.renderer.spriteAnimation.min.js +0 -1
- package/dist/miniprogram.js +0 -272
- package/dist/plugin-renderer-sprite-animation.d.ts +0 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter"),n=require("pixi.js"),o=function(e,t){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@eva/eva.js"),t=require("@eva/plugin-renderer"),r=require("@eva/renderer-adapter"),n=require("pixi.js"),o=function(e,t){return o=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])},o(e,t)};function i(e,t){function r(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function a(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 s(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 c(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 p=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.resource="",e.autoPlay=!0,e.speed=100,e.waitPlay=!1,e.waitStop=!1,e.times=1/0,e.count=0,e}return i(r,t),r.prototype.init=function(e){var t=this;e&&Object.assign(this,e),this.on("loop",(function(){++t.count>=t.times&&(t.animate.stop(),t.emit("complete"))}))},r.prototype.play=function(e){void 0===e&&(e=1/0),0!==e&&(this.times=e,this.animate?(this.animate.play(),this.count=0):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)},r.componentName="SpriteAnimation",a([e.decorators.IDEProp],r.prototype,"resource",void 0),a([e.decorators.IDEProp],r.prototype,"autoPlay",void 0),a([e.decorators.IDEProp],r.prototype,"speed",void 0),r}(e.Component),u=p;e.resource.registerInstance(e.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t=e.name,r=e.data;return new Promise((function(e){var o,i,a=r.json,s=n.BaseTexture.from(r.image),p=a.frames||{},u=a.animations||{},l={};for(var m in p){l[t+"_s|r|c_"+m]=p[m]}for(var m in u){var f=[];if(u[m]&&u[m].length>=0)try{for(var d=(o=void 0,c(u[m])),h=d.next();!h.done;h=d.next()){var y=h.value,v=t+"_s|r|c_"+y;f.push(v)}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=d.return)&&i.call(d)}finally{if(o)throw o.error}}u[m]=f}a.frames=l;var g=new n.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=c(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(n){function o(){var e=null!==n&&n.apply(this,arguments)||this;return e.name="SpriteAnimation",e.animates={},e.autoPlay={},e}return i(o,n),o.prototype.init=function(){this.renderSystem=this.game.getSystem(t.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 s(this,(function(i){switch(i.label){case 0:return"SpriteAnimation"!==t.componentName?[3,7]:(r=t.component,this.autoPlay[t.gameObject.id]=r.autoPlay,t.type!==e.OBSERVER_TYPE.ADD?[3,2]:[4,e.resource.getResource(r.resource)]);case 1:return(n=i.sent().instance)||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.add({frames:n,id:t.gameObject.id,component:r}),[3,7];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[4,e.resource.getResource(r.resource)];case 4:(o=i.sent().instance)||console.error("GameObject:"+t.gameObject.name+"'s Img resource load error"),this.change({frames:o,id:t.gameObject.id,component:r}),i.label=5;case 5:return[3,7];case 6:t.type===e.OBSERVER_TYPE.REMOVE&&this.remove(t.gameObject.id),i.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,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,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];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=a([e.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(t.Renderer);exports.SpriteAnimation=u,exports.SpriteAnimationSystem=l;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-sprite-animation",
|
|
3
|
-
"version": "1.1.1-fix.
|
|
3
|
+
"version": "1.1.1-fix.1",
|
|
4
4
|
"description": "@eva/plugin-renderer-sprite-animation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-sprite-animation.esm.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@eva/plugin-renderer": "1.1.1-fix.
|
|
22
|
-
"@eva/renderer-adapter": "1.1.1-fix.
|
|
23
|
-
"@eva/eva.js": "1.1.1-fix.
|
|
21
|
+
"@eva/plugin-renderer": "1.1.1-fix.1",
|
|
22
|
+
"@eva/renderer-adapter": "1.1.1-fix.1",
|
|
23
|
+
"@eva/eva.js": "1.1.1-fix.1",
|
|
24
24
|
"pixi.js": "^4.8.7"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@eva/eva.js'), require('@eva/plugin-renderer'), require('@eva/renderer-adapter'), require('pixi.js')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@eva/eva.js', '@eva/plugin-renderer', '@eva/renderer-adapter', 'pixi.js'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.EVA = global.EVA || {}, global.EVA.plugin = global.EVA.plugin || {}, global.EVA.plugin.renderer = global.EVA.plugin.renderer || {}, global.EVA.plugin.renderer.spriteAnimation = {}), global.EVA, global.EVA.plugin.renderer, global.EVA.rendererAdapter, global.PIXI));
|
|
5
|
-
}(this, (function (exports, eva_js, pluginRenderer, rendererAdapter, pixi_js) { 'use strict';
|
|
6
|
-
|
|
7
|
-
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
|
|
10
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
-
purpose with or without fee is hereby granted.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
-
***************************************************************************** */
|
|
21
|
-
/* global Reflect, Promise */
|
|
22
|
-
|
|
23
|
-
var extendStatics = function(d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
function __extends(d, b) {
|
|
31
|
-
extendStatics(d, b);
|
|
32
|
-
function __() { this.constructor = d; }
|
|
33
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function __decorate(decorators, target, key, desc) {
|
|
37
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
38
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
39
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
40
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
44
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
45
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
46
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
47
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
48
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
49
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function __generator(thisArg, body) {
|
|
54
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
55
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
56
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
57
|
-
function step(op) {
|
|
58
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
59
|
-
while (_) try {
|
|
60
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
61
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
62
|
-
switch (op[0]) {
|
|
63
|
-
case 0: case 1: t = op; break;
|
|
64
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
65
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
66
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
67
|
-
default:
|
|
68
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
69
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
70
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
71
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
72
|
-
if (t[2]) _.ops.pop();
|
|
73
|
-
_.trys.pop(); continue;
|
|
74
|
-
}
|
|
75
|
-
op = body.call(thisArg, _);
|
|
76
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
77
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function __values(o) {
|
|
82
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
83
|
-
if (m) return m.call(o);
|
|
84
|
-
if (o && typeof o.length === "number") return {
|
|
85
|
-
next: function () {
|
|
86
|
-
if (o && i >= o.length) o = void 0;
|
|
87
|
-
return { value: o && o[i++], done: !o };
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
var SpriteAnimation$2 = (function (_super) {
|
|
94
|
-
__extends(SpriteAnimation, _super);
|
|
95
|
-
function SpriteAnimation() {
|
|
96
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
97
|
-
_this.resource = '';
|
|
98
|
-
_this.autoPlay = true;
|
|
99
|
-
_this.speed = 100;
|
|
100
|
-
_this.waitPlay = false;
|
|
101
|
-
_this.waitStop = false;
|
|
102
|
-
_this.times = Infinity;
|
|
103
|
-
_this.count = 0;
|
|
104
|
-
return _this;
|
|
105
|
-
}
|
|
106
|
-
SpriteAnimation.prototype.init = function (obj) {
|
|
107
|
-
var _this = this;
|
|
108
|
-
obj && Object.assign(this, obj);
|
|
109
|
-
this.on('loop', function () {
|
|
110
|
-
if (++_this.count >= _this.times) {
|
|
111
|
-
_this.animate.stop();
|
|
112
|
-
_this.emit('complete');
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
SpriteAnimation.prototype.play = function (times) {
|
|
117
|
-
if (times === void 0) { times = Infinity; }
|
|
118
|
-
if (times === 0) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
this.times = times;
|
|
122
|
-
if (!this.animate) {
|
|
123
|
-
this.waitPlay = true;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
this.animate.play();
|
|
127
|
-
this.count = 0;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
SpriteAnimation.prototype.stop = function () {
|
|
131
|
-
if (!this.animate) {
|
|
132
|
-
this.waitStop = true;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.animate.stop();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
139
|
-
get: function () {
|
|
140
|
-
return this._animate;
|
|
141
|
-
},
|
|
142
|
-
set: function (val) {
|
|
143
|
-
this._animate = val;
|
|
144
|
-
if (this.waitPlay) {
|
|
145
|
-
this.waitPlay = false;
|
|
146
|
-
this.play(this.times);
|
|
147
|
-
}
|
|
148
|
-
if (this.waitStop) {
|
|
149
|
-
this.waitStop = false;
|
|
150
|
-
this.stop();
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
enumerable: false,
|
|
154
|
-
configurable: true
|
|
155
|
-
});
|
|
156
|
-
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
157
|
-
this.animate.gotoAndPlay(frameNumber);
|
|
158
|
-
};
|
|
159
|
-
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
160
|
-
this.animate.gotoAndStop(frameNumber);
|
|
161
|
-
};
|
|
162
|
-
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
163
|
-
__decorate([
|
|
164
|
-
eva_js.decorators.IDEProp
|
|
165
|
-
], SpriteAnimation.prototype, "resource", void 0);
|
|
166
|
-
__decorate([
|
|
167
|
-
eva_js.decorators.IDEProp
|
|
168
|
-
], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
169
|
-
__decorate([
|
|
170
|
-
eva_js.decorators.IDEProp
|
|
171
|
-
], SpriteAnimation.prototype, "speed", void 0);
|
|
172
|
-
return SpriteAnimation;
|
|
173
|
-
}(eva_js.Component));
|
|
174
|
-
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
175
|
-
|
|
176
|
-
var resourceKeySplit = '_s|r|c_';
|
|
177
|
-
eva_js.resource.registerInstance(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
178
|
-
var name = _a.name, data = _a.data;
|
|
179
|
-
return new Promise(function (r) {
|
|
180
|
-
var e_1, _a;
|
|
181
|
-
var textureObj = data.json;
|
|
182
|
-
var texture = pixi_js.BaseTexture.from(data.image);
|
|
183
|
-
var frames = textureObj.frames || {};
|
|
184
|
-
var animations = textureObj.animations || {};
|
|
185
|
-
var newFrames = {};
|
|
186
|
-
for (var key in frames) {
|
|
187
|
-
var newKey = name + resourceKeySplit + key;
|
|
188
|
-
newFrames[newKey] = frames[key];
|
|
189
|
-
}
|
|
190
|
-
for (var key in animations) {
|
|
191
|
-
var spriteList = [];
|
|
192
|
-
if (animations[key] && animations[key].length >= 0) {
|
|
193
|
-
try {
|
|
194
|
-
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
195
|
-
var spriteName = _c.value;
|
|
196
|
-
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
197
|
-
spriteList.push(newSpriteName);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
201
|
-
finally {
|
|
202
|
-
try {
|
|
203
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
204
|
-
}
|
|
205
|
-
finally { if (e_1) throw e_1.error; }
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
animations[key] = spriteList;
|
|
209
|
-
}
|
|
210
|
-
textureObj.frames = newFrames;
|
|
211
|
-
var spriteSheet = new pixi_js.Spritesheet(texture, textureObj);
|
|
212
|
-
spriteSheet.parse(function () {
|
|
213
|
-
var textures = spriteSheet.textures;
|
|
214
|
-
var spriteFrames = [];
|
|
215
|
-
for (var key in textures) {
|
|
216
|
-
spriteFrames.push(textures[key]);
|
|
217
|
-
}
|
|
218
|
-
r(spriteFrames);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
eva_js.resource.registerDestroy(eva_js.RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
223
|
-
var e_2, _b;
|
|
224
|
-
var instance = _a.instance;
|
|
225
|
-
if (!instance)
|
|
226
|
-
return;
|
|
227
|
-
try {
|
|
228
|
-
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
229
|
-
var texture = instance_1_1.value;
|
|
230
|
-
texture.destroy(true);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
234
|
-
finally {
|
|
235
|
-
try {
|
|
236
|
-
if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
|
|
237
|
-
}
|
|
238
|
-
finally { if (e_2) throw e_2.error; }
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
var SpriteAnimation = (function (_super) {
|
|
242
|
-
__extends(SpriteAnimation, _super);
|
|
243
|
-
function SpriteAnimation() {
|
|
244
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
245
|
-
_this.name = 'SpriteAnimation';
|
|
246
|
-
_this.animates = {};
|
|
247
|
-
_this.autoPlay = {};
|
|
248
|
-
return _this;
|
|
249
|
-
}
|
|
250
|
-
SpriteAnimation.prototype.init = function () {
|
|
251
|
-
this.renderSystem = this.game.getSystem(pluginRenderer.RendererSystem);
|
|
252
|
-
this.renderSystem.rendererManager.register(this);
|
|
253
|
-
};
|
|
254
|
-
SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
|
|
255
|
-
var _a = gameObject.transform.size, width = _a.width, height = _a.height;
|
|
256
|
-
if (this.animates[gameObject.id]) {
|
|
257
|
-
this.animates[gameObject.id].animatedSprite.width = width;
|
|
258
|
-
this.animates[gameObject.id].animatedSprite.height = height;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
262
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
263
|
-
var component, frames_1, frames_2;
|
|
264
|
-
return __generator(this, function (_a) {
|
|
265
|
-
switch (_a.label) {
|
|
266
|
-
case 0:
|
|
267
|
-
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
268
|
-
component = changed.component;
|
|
269
|
-
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
270
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.ADD)) return [3, 2];
|
|
271
|
-
return [4, eva_js.resource.getResource(component.resource)];
|
|
272
|
-
case 1:
|
|
273
|
-
frames_1 = (_a.sent()).instance;
|
|
274
|
-
if (!frames_1) {
|
|
275
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
276
|
-
}
|
|
277
|
-
this.add({
|
|
278
|
-
frames: frames_1,
|
|
279
|
-
id: changed.gameObject.id,
|
|
280
|
-
component: component,
|
|
281
|
-
});
|
|
282
|
-
return [3, 7];
|
|
283
|
-
case 2:
|
|
284
|
-
if (!(changed.type === eva_js.OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
285
|
-
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
286
|
-
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
287
|
-
return [3, 5];
|
|
288
|
-
case 3: return [4, eva_js.resource.getResource(component.resource)];
|
|
289
|
-
case 4:
|
|
290
|
-
frames_2 = (_a.sent()).instance;
|
|
291
|
-
if (!frames_2) {
|
|
292
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
293
|
-
}
|
|
294
|
-
this.change({
|
|
295
|
-
frames: frames_2,
|
|
296
|
-
id: changed.gameObject.id,
|
|
297
|
-
component: component,
|
|
298
|
-
});
|
|
299
|
-
_a.label = 5;
|
|
300
|
-
case 5: return [3, 7];
|
|
301
|
-
case 6:
|
|
302
|
-
if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
303
|
-
this.remove(changed.gameObject.id);
|
|
304
|
-
}
|
|
305
|
-
_a.label = 7;
|
|
306
|
-
case 7: return [2];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
};
|
|
311
|
-
SpriteAnimation.prototype.add = function (_a) {
|
|
312
|
-
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
313
|
-
var animate = new rendererAdapter.SpriteAnimation({ frames: frames });
|
|
314
|
-
this.animates[id] = animate;
|
|
315
|
-
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
316
|
-
animate.animatedSprite.onComplete = function () {
|
|
317
|
-
component.emit('complete');
|
|
318
|
-
};
|
|
319
|
-
animate.animatedSprite.onFrameChange = function () {
|
|
320
|
-
component.emit('frameChange');
|
|
321
|
-
};
|
|
322
|
-
animate.animatedSprite.onLoop = function () {
|
|
323
|
-
component.emit('loop');
|
|
324
|
-
};
|
|
325
|
-
component.animate = this.animates[id];
|
|
326
|
-
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
327
|
-
if (this.autoPlay[id]) {
|
|
328
|
-
animate.animatedSprite.play();
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
SpriteAnimation.prototype.change = function (_a) {
|
|
332
|
-
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
333
|
-
this.remove(id, true);
|
|
334
|
-
this.add({ frames: frames, id: id, component: component });
|
|
335
|
-
};
|
|
336
|
-
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
337
|
-
var animate = this.animates[id];
|
|
338
|
-
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
339
|
-
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
340
|
-
animate.animatedSprite.destroy({ children: true });
|
|
341
|
-
delete this.animates[id];
|
|
342
|
-
if (!isChange) {
|
|
343
|
-
delete this.autoPlay[id];
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
347
|
-
SpriteAnimation = __decorate([
|
|
348
|
-
eva_js.decorators.componentObserver({
|
|
349
|
-
SpriteAnimation: ['speed', 'resource'],
|
|
350
|
-
})
|
|
351
|
-
], SpriteAnimation);
|
|
352
|
-
return SpriteAnimation;
|
|
353
|
-
}(pluginRenderer.Renderer));
|
|
354
|
-
var SpriteAnimation$1 = SpriteAnimation;
|
|
355
|
-
|
|
356
|
-
exports.SpriteAnimation = SpriteAnimation$3;
|
|
357
|
-
exports.SpriteAnimationSystem = SpriteAnimation$1;
|
|
358
|
-
|
|
359
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
360
|
-
|
|
361
|
-
})));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e,t;e=this,t=function(e,t,r,n,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 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 p(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{p(n.next(e))}catch(e){i(e)}}function s(e){try{p(n.throw(e))}catch(e){i(e)}}function p(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}p((n=n.apply(e,t||[])).next())}))}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=(o=a.trys).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 u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}var l=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.resource="",t.autoPlay=!0,t.speed=100,t.waitPlay=!1,t.waitStop=!1,t.times=1/0,t.count=0,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.animate.stop(),t.emit("complete"))}))},r.prototype.play=function(e){void 0===e&&(e=1/0),0!==e&&(this.times=e,this.animate?(this.animate.play(),this.count=0):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)},r.componentName="SpriteAnimation",s([t.decorators.IDEProp],r.prototype,"resource",void 0),s([t.decorators.IDEProp],r.prototype,"autoPlay",void 0),s([t.decorators.IDEProp],r.prototype,"speed",void 0),r}(t.Component),f="_s|r|c_";t.resource.registerInstance(t.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),p=a.frames||{},c=a.animations||{},l={};for(var d in p)l[t+f+d]=p[d];for(var d in c){var m=[];if(c[d]&&c[d].length>=0)try{for(var h=(n=void 0,u(c[d])),y=h.next();!y.done;y=h.next()){var v=y.value,g=t+f+v;m.push(g)}}catch(e){n={error:e}}finally{try{y&&!y.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}c[d]=m}a.frames=l;var b=new o.Spritesheet(s,a);b.parse((function(){var t=b.textures,r=[];for(var n in t)r.push(t[n]);e(r)}))}))})),t.resource.registerDestroy(t.RESOURCE_TYPE.SPRITE_ANIMATION,(function(e){var t,r,n=e.instance;if(n)try{for(var o=u(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 d=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(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(e){return p(this,void 0,void 0,(function(){var r,n,o;return c(this,(function(i){switch(i.label){case 0:return"SpriteAnimation"!==e.componentName?[3,7]:(r=e.component,this.autoPlay[e.gameObject.id]=r.autoPlay,e.type!==t.OBSERVER_TYPE.ADD?[3,2]:[4,t.resource.getResource(r.resource)]);case 1:return(n=i.sent().instance)||console.error("GameObject:"+e.gameObject.name+"'s Img resource load error"),this.add({frames:n,id:e.gameObject.id,component:r}),[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/r.speed,[3,5]):[3,3];case 3:return[4,t.resource.getResource(r.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:r}),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,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];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([t.decorators.componentObserver({SpriteAnimation:["speed","resource"]})],o)}(r.Renderer);e.SpriteAnimation=l,e.SpriteAnimationSystem=d,Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@eva/eva.js"),require("@eva/plugin-renderer"),require("@eva/renderer-adapter"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","@eva/eva.js","@eva/plugin-renderer","@eva/renderer-adapter","pixi.js"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).EVA=e.EVA||{},e.EVA.plugin=e.EVA.plugin||{},e.EVA.plugin.renderer=e.EVA.plugin.renderer||{},e.EVA.plugin.renderer.spriteAnimation={}),e.EVA,e.EVA.plugin.renderer,e.EVA.rendererAdapter,e.PIXI);
|
package/dist/miniprogram.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { __extends, __decorate, __values, __awaiter, __generator } from 'tslib';
|
|
2
|
-
import { Component, resource, RESOURCE_TYPE, OBSERVER_TYPE, decorators } from '@eva/eva.js/dist/miniprogram';
|
|
3
|
-
import { type, step } from '@eva/inspector-decorator/dist/miniprogram';
|
|
4
|
-
import { RendererSystem, Renderer } from '@eva/plugin-renderer/dist/miniprogram';
|
|
5
|
-
import { SpriteAnimation as SpriteAnimation$4 } from '@eva/renderer-adapter/dist/miniprogram';
|
|
6
|
-
import { BaseTexture, Spritesheet } from '@eva/miniprogram-pixi';
|
|
7
|
-
|
|
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.waitPlay = false;
|
|
16
|
-
_this.waitStop = false;
|
|
17
|
-
_this.times = Infinity;
|
|
18
|
-
_this.count = 0;
|
|
19
|
-
return _this;
|
|
20
|
-
}
|
|
21
|
-
SpriteAnimation.prototype.init = function (obj) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
obj && Object.assign(this, obj);
|
|
24
|
-
this.on('loop', function () {
|
|
25
|
-
if (++_this.count >= _this.times) {
|
|
26
|
-
_this.animate.stop();
|
|
27
|
-
_this.emit('complete');
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
SpriteAnimation.prototype.play = function (times) {
|
|
32
|
-
if (times === void 0) { times = Infinity; }
|
|
33
|
-
if (times === 0) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
this.times = times;
|
|
37
|
-
if (!this.animate) {
|
|
38
|
-
this.waitPlay = true;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.animate.play();
|
|
42
|
-
this.count = 0;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
SpriteAnimation.prototype.stop = function () {
|
|
46
|
-
if (!this.animate) {
|
|
47
|
-
this.waitStop = true;
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.animate.stop();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(SpriteAnimation.prototype, "animate", {
|
|
54
|
-
get: function () {
|
|
55
|
-
return this._animate;
|
|
56
|
-
},
|
|
57
|
-
set: function (val) {
|
|
58
|
-
this._animate = val;
|
|
59
|
-
if (this.waitPlay) {
|
|
60
|
-
this.waitPlay = false;
|
|
61
|
-
this.play(this.times);
|
|
62
|
-
}
|
|
63
|
-
if (this.waitStop) {
|
|
64
|
-
this.waitStop = false;
|
|
65
|
-
this.stop();
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
SpriteAnimation.prototype.gotoAndPlay = function (frameNumber) {
|
|
72
|
-
this.animate.gotoAndPlay(frameNumber);
|
|
73
|
-
};
|
|
74
|
-
SpriteAnimation.prototype.gotoAndStop = function (frameNumber) {
|
|
75
|
-
this.animate.gotoAndStop(frameNumber);
|
|
76
|
-
};
|
|
77
|
-
SpriteAnimation.componentName = 'SpriteAnimation';
|
|
78
|
-
__decorate([
|
|
79
|
-
type('string')
|
|
80
|
-
], SpriteAnimation.prototype, "resource", void 0);
|
|
81
|
-
__decorate([
|
|
82
|
-
type('boolean')
|
|
83
|
-
], SpriteAnimation.prototype, "autoPlay", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
type('number'),
|
|
86
|
-
step(10)
|
|
87
|
-
], SpriteAnimation.prototype, "speed", void 0);
|
|
88
|
-
return SpriteAnimation;
|
|
89
|
-
}(Component));
|
|
90
|
-
var SpriteAnimation$3 = SpriteAnimation$2;
|
|
91
|
-
|
|
92
|
-
var resourceKeySplit = '_s|r|c_';
|
|
93
|
-
resource.registerInstance(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
94
|
-
var name = _a.name, data = _a.data;
|
|
95
|
-
return new Promise(function (r) {
|
|
96
|
-
var e_1, _a;
|
|
97
|
-
var textureObj = data.json;
|
|
98
|
-
var texture = BaseTexture.from(data.image);
|
|
99
|
-
var frames = textureObj.frames || {};
|
|
100
|
-
var animations = textureObj.animations || {};
|
|
101
|
-
var newFrames = {};
|
|
102
|
-
for (var key in frames) {
|
|
103
|
-
var newKey = name + resourceKeySplit + key;
|
|
104
|
-
newFrames[newKey] = frames[key];
|
|
105
|
-
}
|
|
106
|
-
for (var key in animations) {
|
|
107
|
-
var spriteList = [];
|
|
108
|
-
if (animations[key] && animations[key].length >= 0) {
|
|
109
|
-
try {
|
|
110
|
-
for (var _b = (e_1 = void 0, __values(animations[key])), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
111
|
-
var spriteName = _c.value;
|
|
112
|
-
var newSpriteName = name + resourceKeySplit + spriteName;
|
|
113
|
-
spriteList.push(newSpriteName);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
117
|
-
finally {
|
|
118
|
-
try {
|
|
119
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
120
|
-
}
|
|
121
|
-
finally { if (e_1) throw e_1.error; }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
animations[key] = spriteList;
|
|
125
|
-
}
|
|
126
|
-
textureObj.frames = newFrames;
|
|
127
|
-
var spriteSheet = new Spritesheet(texture, textureObj);
|
|
128
|
-
spriteSheet.parse(function () {
|
|
129
|
-
var textures = spriteSheet.textures;
|
|
130
|
-
var spriteFrames = [];
|
|
131
|
-
for (var key in textures) {
|
|
132
|
-
spriteFrames.push(textures[key]);
|
|
133
|
-
}
|
|
134
|
-
r(spriteFrames);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
resource.registerDestroy(RESOURCE_TYPE.SPRITE_ANIMATION, function (_a) {
|
|
139
|
-
var e_2, _b;
|
|
140
|
-
var instance = _a.instance;
|
|
141
|
-
if (!instance)
|
|
142
|
-
return;
|
|
143
|
-
try {
|
|
144
|
-
for (var instance_1 = __values(instance), instance_1_1 = instance_1.next(); !instance_1_1.done; instance_1_1 = instance_1.next()) {
|
|
145
|
-
var texture = instance_1_1.value;
|
|
146
|
-
texture.destroy(true);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
150
|
-
finally {
|
|
151
|
-
try {
|
|
152
|
-
if (instance_1_1 && !instance_1_1.done && (_b = instance_1.return)) _b.call(instance_1);
|
|
153
|
-
}
|
|
154
|
-
finally { if (e_2) throw e_2.error; }
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
var SpriteAnimation = (function (_super) {
|
|
158
|
-
__extends(SpriteAnimation, _super);
|
|
159
|
-
function SpriteAnimation() {
|
|
160
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
161
|
-
_this.name = 'SpriteAnimation';
|
|
162
|
-
_this.animates = {};
|
|
163
|
-
_this.autoPlay = {};
|
|
164
|
-
return _this;
|
|
165
|
-
}
|
|
166
|
-
SpriteAnimation.prototype.init = function () {
|
|
167
|
-
this.renderSystem = this.game.getSystem(RendererSystem);
|
|
168
|
-
this.renderSystem.rendererManager.register(this);
|
|
169
|
-
};
|
|
170
|
-
SpriteAnimation.prototype.rendererUpdate = function (gameObject) {
|
|
171
|
-
var _a = gameObject.transform.size, width = _a.width, height = _a.height;
|
|
172
|
-
if (this.animates[gameObject.id]) {
|
|
173
|
-
this.animates[gameObject.id].animatedSprite.width = width;
|
|
174
|
-
this.animates[gameObject.id].animatedSprite.height = height;
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
SpriteAnimation.prototype.componentChanged = function (changed) {
|
|
178
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
179
|
-
var component, frames_1, frames_2;
|
|
180
|
-
return __generator(this, function (_a) {
|
|
181
|
-
switch (_a.label) {
|
|
182
|
-
case 0:
|
|
183
|
-
if (!(changed.componentName === 'SpriteAnimation')) return [3, 7];
|
|
184
|
-
component = changed.component;
|
|
185
|
-
this.autoPlay[changed.gameObject.id] = component.autoPlay;
|
|
186
|
-
if (!(changed.type === OBSERVER_TYPE.ADD)) return [3, 2];
|
|
187
|
-
return [4, resource.getResource(component.resource)];
|
|
188
|
-
case 1:
|
|
189
|
-
frames_1 = (_a.sent()).instance;
|
|
190
|
-
if (!frames_1) {
|
|
191
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
192
|
-
}
|
|
193
|
-
this.add({
|
|
194
|
-
frames: frames_1,
|
|
195
|
-
id: changed.gameObject.id,
|
|
196
|
-
component: component,
|
|
197
|
-
});
|
|
198
|
-
return [3, 7];
|
|
199
|
-
case 2:
|
|
200
|
-
if (!(changed.type === OBSERVER_TYPE.CHANGE)) return [3, 6];
|
|
201
|
-
if (!(changed.prop && changed.prop.prop[0] === 'speed')) return [3, 3];
|
|
202
|
-
this.animates[changed.gameObject.id].speed = 1000 / 60 / component.speed;
|
|
203
|
-
return [3, 5];
|
|
204
|
-
case 3: return [4, resource.getResource(component.resource)];
|
|
205
|
-
case 4:
|
|
206
|
-
frames_2 = (_a.sent()).instance;
|
|
207
|
-
if (!frames_2) {
|
|
208
|
-
console.error("GameObject:" + changed.gameObject.name + "'s Img resource load error");
|
|
209
|
-
}
|
|
210
|
-
this.change({
|
|
211
|
-
frames: frames_2,
|
|
212
|
-
id: changed.gameObject.id,
|
|
213
|
-
component: component,
|
|
214
|
-
});
|
|
215
|
-
_a.label = 5;
|
|
216
|
-
case 5: return [3, 7];
|
|
217
|
-
case 6:
|
|
218
|
-
if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
219
|
-
this.remove(changed.gameObject.id);
|
|
220
|
-
}
|
|
221
|
-
_a.label = 7;
|
|
222
|
-
case 7: return [2];
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
};
|
|
227
|
-
SpriteAnimation.prototype.add = function (_a) {
|
|
228
|
-
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
229
|
-
var animate = new SpriteAnimation$4({ frames: frames });
|
|
230
|
-
this.animates[id] = animate;
|
|
231
|
-
this.containerManager.getContainer(id).addChildAt(animate.animatedSprite, 0);
|
|
232
|
-
animate.animatedSprite.onComplete = function () {
|
|
233
|
-
component.emit('complete');
|
|
234
|
-
};
|
|
235
|
-
animate.animatedSprite.onFrameChange = function () {
|
|
236
|
-
component.emit('frameChange');
|
|
237
|
-
};
|
|
238
|
-
animate.animatedSprite.onLoop = function () {
|
|
239
|
-
component.emit('loop');
|
|
240
|
-
};
|
|
241
|
-
component.animate = this.animates[id];
|
|
242
|
-
this.animates[id].speed = 1000 / 60 / component.speed;
|
|
243
|
-
if (this.autoPlay[id]) {
|
|
244
|
-
animate.animatedSprite.play();
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
SpriteAnimation.prototype.change = function (_a) {
|
|
248
|
-
var frames = _a.frames, id = _a.id, component = _a.component;
|
|
249
|
-
this.remove(id, true);
|
|
250
|
-
this.add({ frames: frames, id: id, component: component });
|
|
251
|
-
};
|
|
252
|
-
SpriteAnimation.prototype.remove = function (id, isChange) {
|
|
253
|
-
var animate = this.animates[id];
|
|
254
|
-
this.autoPlay[id] = animate.animatedSprite.playing;
|
|
255
|
-
this.containerManager.getContainer(id).removeChild(animate.animatedSprite);
|
|
256
|
-
animate.animatedSprite.destroy({ children: true });
|
|
257
|
-
delete this.animates[id];
|
|
258
|
-
if (!isChange) {
|
|
259
|
-
delete this.autoPlay[id];
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
SpriteAnimation.systemName = 'SpriteAnimation';
|
|
263
|
-
SpriteAnimation = __decorate([
|
|
264
|
-
decorators.componentObserver({
|
|
265
|
-
SpriteAnimation: ['speed', 'resource'],
|
|
266
|
-
})
|
|
267
|
-
], SpriteAnimation);
|
|
268
|
-
return SpriteAnimation;
|
|
269
|
-
}(Renderer));
|
|
270
|
-
var SpriteAnimation$1 = SpriteAnimation;
|
|
271
|
-
|
|
272
|
-
export { SpriteAnimation$3 as SpriteAnimation, SpriteAnimation$1 as SpriteAnimationSystem };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Component } from '@eva/eva.js';
|
|
2
|
-
import { ComponentChanged } from '@eva/eva.js';
|
|
3
|
-
import { ContainerManager } from '@eva/plugin-renderer';
|
|
4
|
-
import { GameObject } from '@eva/eva.js';
|
|
5
|
-
import { Renderer } from '@eva/plugin-renderer';
|
|
6
|
-
import { RendererManager } from '@eva/plugin-renderer';
|
|
7
|
-
import { RendererSystem } from '@eva/plugin-renderer';
|
|
8
|
-
import { SpriteAnimation as SpriteAnimation_2 } from '@eva/renderer-adapter';
|
|
9
|
-
|
|
10
|
-
export declare class SpriteAnimation extends Component<SpriteAnimationParams> {
|
|
11
|
-
static componentName: string;
|
|
12
|
-
resource: string;
|
|
13
|
-
autoPlay: boolean;
|
|
14
|
-
speed: number;
|
|
15
|
-
_animate: SpriteAnimation_2;
|
|
16
|
-
private waitPlay;
|
|
17
|
-
private waitStop;
|
|
18
|
-
private times;
|
|
19
|
-
private count;
|
|
20
|
-
init(obj?: SpriteAnimationParams): void;
|
|
21
|
-
play(times?: number): void;
|
|
22
|
-
stop(): void;
|
|
23
|
-
set animate(val: SpriteAnimation_2);
|
|
24
|
-
get animate(): SpriteAnimation_2;
|
|
25
|
-
gotoAndPlay(frameNumber: any): void;
|
|
26
|
-
gotoAndStop(frameNumber: any): void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export declare interface SpriteAnimationParams {
|
|
30
|
-
resource: string;
|
|
31
|
-
autoPlay: boolean;
|
|
32
|
-
speed: number;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export declare class SpriteAnimationSystem extends Renderer {
|
|
36
|
-
static systemName: string;
|
|
37
|
-
name: string;
|
|
38
|
-
animates: {
|
|
39
|
-
[propName: number]: SpriteAnimation_2;
|
|
40
|
-
};
|
|
41
|
-
autoPlay: {
|
|
42
|
-
[propName: number]: boolean;
|
|
43
|
-
};
|
|
44
|
-
renderSystem: RendererSystem;
|
|
45
|
-
rendererManager: RendererManager;
|
|
46
|
-
containerManager: ContainerManager;
|
|
47
|
-
init(): void;
|
|
48
|
-
rendererUpdate(gameObject: GameObject): void;
|
|
49
|
-
componentChanged(changed: ComponentChanged): Promise<void>;
|
|
50
|
-
add({ frames, id, component }: {
|
|
51
|
-
frames: any;
|
|
52
|
-
id: any;
|
|
53
|
-
component: any;
|
|
54
|
-
}): void;
|
|
55
|
-
change({ frames, id, component }: {
|
|
56
|
-
frames: any;
|
|
57
|
-
id: any;
|
|
58
|
-
component: any;
|
|
59
|
-
}): void;
|
|
60
|
-
remove(id: any, isChange?: boolean): void;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { }
|