@safe-engine/pixi 1.0.2 → 7.0.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/.github/workflows/npm-publish.yml +35 -0
- package/README.md +4 -4
- package/dist/app.d.ts +3 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +41 -81
- package/dist/components/GUIComponent.d.ts +15 -14
- package/dist/components/GUIComponent.d.ts.map +1 -1
- package/dist/components/GUIComponent.js +68 -138
- package/dist/components/NodeComp.d.ts +6 -5
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +223 -305
- package/dist/components/RenderComponent.d.ts +8 -7
- package/dist/components/RenderComponent.d.ts.map +1 -1
- package/dist/components/RenderComponent.js +25 -56
- package/dist/core/Color.js +1 -1
- package/dist/core/LoadingBar.d.ts +9 -1
- package/dist/core/LoadingBar.d.ts.map +1 -1
- package/dist/core/LoadingBar.js +50 -46
- package/dist/core/Size.js +3 -6
- package/dist/core/Vec2.d.ts +20 -0
- package/dist/core/Vec2.d.ts.map +1 -0
- package/dist/core/Vec2.js +70 -0
- package/dist/helper/html-text-parser.js +34 -34
- package/dist/helper/utils.d.ts +1 -1
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +20 -24
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -18
- package/dist/systems/GUISystem.d.ts +2 -2
- package/dist/systems/GUISystem.d.ts.map +1 -1
- package/dist/systems/GUISystem.js +39 -40
- package/dist/systems/RenderSystem.d.ts +0 -1
- package/dist/systems/RenderSystem.d.ts.map +1 -1
- package/dist/systems/RenderSystem.js +24 -35
- package/package.json +4 -3
- package/src/app.ts +53 -0
- package/src/components/GUIComponent.ts +141 -0
- package/src/components/NodeComp.ts +416 -0
- package/src/components/RenderComponent.ts +66 -0
- package/src/core/Color.ts +3 -0
- package/src/core/LoadingBar.ts +63 -0
- package/src/core/Size.ts +21 -0
- package/src/helper/html-text-parser.ts +364 -0
- package/src/index.ts +7 -0
- package/src/systems/GUISystem.ts +80 -0
- package/src/systems/RenderSystem.ts +70 -0
- package/tsconfig.json +24 -0
|
@@ -4,12 +4,40 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.NodeComp = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const remove_1 = __importDefault(require("lodash/remove"));
|
|
8
|
+
const pixi_js_1 = require("pixi.js");
|
|
9
|
+
const pixi_action_ease_1 = require("pixi-action-ease");
|
|
10
|
+
const GUIComponent_1 = require("./GUIComponent");
|
|
11
|
+
class NodeComp {
|
|
12
|
+
setOnTouchStart(cb) {
|
|
13
|
+
this.onTouchStart = cb;
|
|
14
|
+
this.instance.on('touchstart', (event) => {
|
|
15
|
+
const { global } = event;
|
|
16
|
+
this.onTouchStart({ location: global });
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
setOnTouchMove(cb) {
|
|
20
|
+
this.onTouchMove = cb;
|
|
21
|
+
this.instance.on('touchmove', (event) => {
|
|
22
|
+
const { global } = event;
|
|
23
|
+
this.onTouchMove({ location: global });
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
setOnTouchEnd(cb) {
|
|
27
|
+
this.onTouchEnd = cb;
|
|
28
|
+
this.instance.on('touchend', (event) => {
|
|
29
|
+
const { global } = event;
|
|
30
|
+
this.onTouchEnd({ location: global });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
setOnTouchCancel(cb) {
|
|
34
|
+
this.onTouchCancel = cb;
|
|
35
|
+
this.instance.on('touchcancel', (event) => {
|
|
36
|
+
const { global } = event;
|
|
37
|
+
this.onTouchCancel({ location: global });
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
constructor(instance, entity) {
|
|
13
41
|
this.events = {};
|
|
14
42
|
this.data = {};
|
|
15
43
|
this.children = [];
|
|
@@ -19,260 +47,158 @@ var NodeComp = /** @class */ (function () {
|
|
|
19
47
|
this.instance = instance;
|
|
20
48
|
this.instance.eventMode = 'static';
|
|
21
49
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.instance.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return this.getPosition();
|
|
64
|
-
},
|
|
65
|
-
set: function (val) {
|
|
66
|
-
this.setPosition(val.x, val.y);
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(NodeComp.prototype, "x", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return this.instance.x;
|
|
74
|
-
},
|
|
75
|
-
set: function (val) {
|
|
76
|
-
this.instance.x = val;
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(NodeComp.prototype, "y", {
|
|
82
|
-
get: function () {
|
|
83
|
-
return this.instance.y;
|
|
84
|
-
},
|
|
85
|
-
set: function (val) {
|
|
86
|
-
this.instance.y = val;
|
|
87
|
-
},
|
|
88
|
-
enumerable: false,
|
|
89
|
-
configurable: true
|
|
90
|
-
});
|
|
91
|
-
Object.defineProperty(NodeComp.prototype, "scale", {
|
|
92
|
-
// get scale() {
|
|
93
|
-
// return this.instance.scale
|
|
94
|
-
// }
|
|
95
|
-
set: function (val) {
|
|
96
|
-
this.instance.scale = new pixi_js_1.Point(val, val);
|
|
97
|
-
},
|
|
98
|
-
enumerable: false,
|
|
99
|
-
configurable: true
|
|
100
|
-
});
|
|
101
|
-
Object.defineProperty(NodeComp.prototype, "scaleX", {
|
|
102
|
-
get: function () {
|
|
103
|
-
return this.instance.scale.x;
|
|
104
|
-
},
|
|
105
|
-
set: function (val) {
|
|
106
|
-
this.instance.scale.x = val;
|
|
107
|
-
},
|
|
108
|
-
enumerable: false,
|
|
109
|
-
configurable: true
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(NodeComp.prototype, "scaleY", {
|
|
112
|
-
get: function () {
|
|
113
|
-
return this.instance.y;
|
|
114
|
-
},
|
|
115
|
-
set: function (val) {
|
|
116
|
-
this.instance.y = val;
|
|
117
|
-
},
|
|
118
|
-
enumerable: false,
|
|
119
|
-
configurable: true
|
|
120
|
-
});
|
|
121
|
-
Object.defineProperty(NodeComp.prototype, "anchorX", {
|
|
122
|
-
get: function () {
|
|
50
|
+
get uuid() {
|
|
51
|
+
return this.entity.id;
|
|
52
|
+
}
|
|
53
|
+
get position() {
|
|
54
|
+
return this.getPosition();
|
|
55
|
+
}
|
|
56
|
+
set position(val) {
|
|
57
|
+
this.setPosition(val.x, val.y);
|
|
58
|
+
}
|
|
59
|
+
get x() {
|
|
60
|
+
return this.instance.x;
|
|
61
|
+
}
|
|
62
|
+
set x(val) {
|
|
63
|
+
this.instance.x = val;
|
|
64
|
+
}
|
|
65
|
+
get y() {
|
|
66
|
+
return this.instance.y;
|
|
67
|
+
}
|
|
68
|
+
set y(val) {
|
|
69
|
+
this.instance.y = val;
|
|
70
|
+
}
|
|
71
|
+
// get scale() {
|
|
72
|
+
// return this.instance.scale
|
|
73
|
+
// }
|
|
74
|
+
set scale(val) {
|
|
75
|
+
this.instance.scale = new pixi_js_1.Point(val, val);
|
|
76
|
+
}
|
|
77
|
+
get scaleX() {
|
|
78
|
+
return this.instance.scale.x;
|
|
79
|
+
}
|
|
80
|
+
set scaleX(val) {
|
|
81
|
+
this.instance.scale.x = val;
|
|
82
|
+
}
|
|
83
|
+
get scaleY() {
|
|
84
|
+
return this.instance.y;
|
|
85
|
+
}
|
|
86
|
+
set scaleY(val) {
|
|
87
|
+
this.instance.y = val;
|
|
88
|
+
}
|
|
89
|
+
get anchorX() {
|
|
90
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
123
91
|
return this.instance.anchor.x;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Object.defineProperty(NodeComp.prototype, "anchorY", {
|
|
133
|
-
get: function () {
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
set anchorX(val) {
|
|
95
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
96
|
+
this.instance.anchor.x = val;
|
|
97
|
+
}
|
|
98
|
+
get anchorY() {
|
|
99
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
134
100
|
return this.instance.anchor.y;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
/** angle is in degrees. */
|
|
161
|
-
set: function (val) {
|
|
162
|
-
this.instance.angle = val;
|
|
163
|
-
},
|
|
164
|
-
enumerable: false,
|
|
165
|
-
configurable: true
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(NodeComp.prototype, "color", {
|
|
168
|
-
get: function () {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
set anchorY(val) {
|
|
104
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
105
|
+
this.instance.anchor.y = val;
|
|
106
|
+
}
|
|
107
|
+
/** rotation is in radians */
|
|
108
|
+
get rotation() {
|
|
109
|
+
return this.instance.rotation;
|
|
110
|
+
}
|
|
111
|
+
/** rotation is in radians */
|
|
112
|
+
set rotation(val) {
|
|
113
|
+
this.instance.rotation = val;
|
|
114
|
+
}
|
|
115
|
+
/** angle is in degrees. */
|
|
116
|
+
get angle() {
|
|
117
|
+
return this.instance.angle;
|
|
118
|
+
}
|
|
119
|
+
/** angle is in degrees. */
|
|
120
|
+
set angle(val) {
|
|
121
|
+
this.instance.angle = val;
|
|
122
|
+
}
|
|
123
|
+
get color() {
|
|
124
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
169
125
|
return this.instance.tint;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
configurable: true
|
|
217
|
-
});
|
|
218
|
-
Object.defineProperty(NodeComp.prototype, "height", {
|
|
219
|
-
get: function () {
|
|
220
|
-
return this.instance.height;
|
|
221
|
-
},
|
|
222
|
-
set: function (val) {
|
|
223
|
-
this.instance.height = val;
|
|
224
|
-
},
|
|
225
|
-
enumerable: false,
|
|
226
|
-
configurable: true
|
|
227
|
-
});
|
|
228
|
-
Object.defineProperty(NodeComp.prototype, "zIndex", {
|
|
229
|
-
get: function () {
|
|
230
|
-
return this.instance.zIndex;
|
|
231
|
-
},
|
|
232
|
-
set: function (val) {
|
|
233
|
-
this.instance.zIndex = val;
|
|
234
|
-
},
|
|
235
|
-
enumerable: false,
|
|
236
|
-
configurable: true
|
|
237
|
-
});
|
|
238
|
-
Object.defineProperty(NodeComp.prototype, "childrenCount", {
|
|
239
|
-
get: function () {
|
|
240
|
-
return this.children.length;
|
|
241
|
-
},
|
|
242
|
-
enumerable: false,
|
|
243
|
-
configurable: true
|
|
244
|
-
});
|
|
245
|
-
NodeComp.prototype.addComponent = function (instance) {
|
|
126
|
+
return 0xffffff;
|
|
127
|
+
}
|
|
128
|
+
set color(val) {
|
|
129
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
130
|
+
this.instance.tint = val;
|
|
131
|
+
}
|
|
132
|
+
get opacity() {
|
|
133
|
+
return this.instance.alpha;
|
|
134
|
+
}
|
|
135
|
+
set opacity(val) {
|
|
136
|
+
this.instance.alpha = val;
|
|
137
|
+
}
|
|
138
|
+
get active() {
|
|
139
|
+
return this.instance.visible && !this.instance.destroyed;
|
|
140
|
+
}
|
|
141
|
+
set active(val) {
|
|
142
|
+
this.instance.visible = val;
|
|
143
|
+
}
|
|
144
|
+
get group() {
|
|
145
|
+
return this._group;
|
|
146
|
+
}
|
|
147
|
+
set group(val) {
|
|
148
|
+
this._group = val;
|
|
149
|
+
}
|
|
150
|
+
get width() {
|
|
151
|
+
return this.instance.width;
|
|
152
|
+
}
|
|
153
|
+
set width(val) {
|
|
154
|
+
this.instance.width = val;
|
|
155
|
+
}
|
|
156
|
+
get height() {
|
|
157
|
+
return this.instance.height;
|
|
158
|
+
}
|
|
159
|
+
set height(val) {
|
|
160
|
+
this.instance.height = val;
|
|
161
|
+
}
|
|
162
|
+
get zIndex() {
|
|
163
|
+
return this.instance.zIndex;
|
|
164
|
+
}
|
|
165
|
+
set zIndex(val) {
|
|
166
|
+
this.instance.zIndex = val;
|
|
167
|
+
}
|
|
168
|
+
get childrenCount() {
|
|
169
|
+
return this.children.length;
|
|
170
|
+
}
|
|
171
|
+
addComponent(instance) {
|
|
246
172
|
return this.entity.assign(instance);
|
|
247
|
-
}
|
|
248
|
-
|
|
173
|
+
}
|
|
174
|
+
getComponent(component) {
|
|
249
175
|
return this.entity.getComponent(component);
|
|
250
|
-
}
|
|
251
|
-
|
|
176
|
+
}
|
|
177
|
+
getComponentsInChildren(component) {
|
|
252
178
|
if (!this.children.length) {
|
|
253
179
|
return [];
|
|
254
180
|
}
|
|
255
|
-
|
|
181
|
+
const listHave = this.children.filter((child) => {
|
|
256
182
|
return child.getComponent(component);
|
|
257
183
|
});
|
|
258
|
-
return listHave.map(
|
|
259
|
-
}
|
|
260
|
-
|
|
184
|
+
return listHave.map((node) => node.getComponent(component));
|
|
185
|
+
}
|
|
186
|
+
getComponentInChildren(component) {
|
|
261
187
|
return this.getComponentsInChildren(component)[0];
|
|
262
|
-
}
|
|
263
|
-
|
|
188
|
+
}
|
|
189
|
+
convertToNodeSpace(point) {
|
|
264
190
|
return this.instance.toLocal(point);
|
|
265
|
-
}
|
|
266
|
-
|
|
191
|
+
}
|
|
192
|
+
convertToNodeSpaceAR(point) {
|
|
267
193
|
return this.instance.toLocal(point);
|
|
268
|
-
}
|
|
269
|
-
|
|
194
|
+
}
|
|
195
|
+
convertToWorldSpaceAR(point) {
|
|
270
196
|
return this.instance.toGlobal(point);
|
|
271
|
-
}
|
|
272
|
-
|
|
197
|
+
}
|
|
198
|
+
getPosition() {
|
|
273
199
|
return this.instance.position;
|
|
274
|
-
}
|
|
275
|
-
|
|
200
|
+
}
|
|
201
|
+
setPosition(x, y) {
|
|
276
202
|
if (typeof x !== 'number') {
|
|
277
203
|
this.x = x.x;
|
|
278
204
|
this.y = x.y;
|
|
@@ -281,13 +207,13 @@ var NodeComp = /** @class */ (function () {
|
|
|
281
207
|
this.x = x;
|
|
282
208
|
this.y = y;
|
|
283
209
|
}
|
|
284
|
-
}
|
|
285
|
-
|
|
210
|
+
}
|
|
211
|
+
setRotation(deg) {
|
|
286
212
|
this.instance.rotation = deg;
|
|
287
|
-
}
|
|
288
|
-
|
|
213
|
+
}
|
|
214
|
+
getRotation() {
|
|
289
215
|
return this.instance.rotation;
|
|
290
|
-
}
|
|
216
|
+
}
|
|
291
217
|
// setAnchorPoint(point: number | cc.Point, y?: number) {
|
|
292
218
|
// this.instance.setAnchorPoint(point, y)
|
|
293
219
|
// }
|
|
@@ -301,9 +227,9 @@ var NodeComp = /** @class */ (function () {
|
|
|
301
227
|
// }
|
|
302
228
|
// return box
|
|
303
229
|
// }
|
|
304
|
-
|
|
305
|
-
return this.instance.
|
|
306
|
-
}
|
|
230
|
+
getContentSize() {
|
|
231
|
+
return this.instance.getBounds();
|
|
232
|
+
}
|
|
307
233
|
// setContentSize(size: cc.Size | number, height?: number) {
|
|
308
234
|
// this.instance.setContentSize(size, height)
|
|
309
235
|
// if (this.instance instanceof cc.ClippingNode) {
|
|
@@ -316,89 +242,82 @@ var NodeComp = /** @class */ (function () {
|
|
|
316
242
|
// this.instance.stencil = stencil
|
|
317
243
|
// }
|
|
318
244
|
// }
|
|
319
|
-
|
|
320
|
-
this.instance
|
|
321
|
-
|
|
322
|
-
|
|
245
|
+
setColor(color) {
|
|
246
|
+
if (this.instance instanceof pixi_js_1.Sprite)
|
|
247
|
+
this.instance.tint = color;
|
|
248
|
+
}
|
|
249
|
+
setScale(scaleX, scaleY) {
|
|
323
250
|
this.instance.scale.x = scaleX;
|
|
324
251
|
this.instance.scale.x = scaleY || scaleX;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
252
|
+
}
|
|
253
|
+
runAction(act) {
|
|
254
|
+
const animation = pixi_action_ease_1.actionManager.runAction(this.instance, act);
|
|
328
255
|
this.actionsList.push(animation);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
this.actionsList.forEach(
|
|
256
|
+
}
|
|
257
|
+
stopAllActions() {
|
|
258
|
+
this.actionsList.forEach((act) => {
|
|
332
259
|
pixi_action_ease_1.actionManager.cancelAction(act);
|
|
333
260
|
});
|
|
334
261
|
this.actionsList = [];
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
this.actionsList.forEach(
|
|
262
|
+
}
|
|
263
|
+
pauseAllActions() {
|
|
264
|
+
this.actionsList.forEach((anim) => {
|
|
338
265
|
anim.isPause = true;
|
|
339
266
|
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
this.actionsList.forEach(
|
|
267
|
+
}
|
|
268
|
+
resumeAllActions() {
|
|
269
|
+
this.actionsList.forEach((anim) => {
|
|
343
270
|
anim.isPause = false;
|
|
344
271
|
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var _this = this;
|
|
272
|
+
}
|
|
273
|
+
destroy() {
|
|
348
274
|
if (this.parent) {
|
|
349
|
-
(0, remove_1.default)(this.parent.children,
|
|
350
|
-
var entity = _a.entity;
|
|
351
|
-
return entity.id === _this.entity.id;
|
|
352
|
-
});
|
|
275
|
+
(0, remove_1.default)(this.parent.children, ({ entity }) => entity.id === this.entity.id);
|
|
353
276
|
}
|
|
354
|
-
this.children.forEach(
|
|
277
|
+
this.children.forEach((child) => {
|
|
355
278
|
child.destroy();
|
|
356
279
|
});
|
|
357
280
|
this.parent = null;
|
|
358
281
|
this.entity.destroy();
|
|
359
282
|
this.stopAllActions();
|
|
360
283
|
this.instance.destroy();
|
|
361
|
-
}
|
|
362
|
-
|
|
284
|
+
}
|
|
285
|
+
removeFromParent() {
|
|
363
286
|
this.active = false;
|
|
364
287
|
this.stopAllActions();
|
|
365
288
|
this.instance.removeFromParent();
|
|
366
|
-
}
|
|
367
|
-
|
|
289
|
+
}
|
|
290
|
+
addChild(child, zOrder) {
|
|
368
291
|
child.parent = this;
|
|
369
292
|
child.active = true;
|
|
370
293
|
this.children.push(child);
|
|
371
294
|
this.instance.addChild(child.instance);
|
|
372
295
|
if (zOrder)
|
|
373
296
|
child.zIndex = zOrder;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
this.children.forEach(
|
|
297
|
+
}
|
|
298
|
+
destroyAllChildren() {
|
|
299
|
+
this.children.forEach((child) => {
|
|
377
300
|
child.destroy();
|
|
378
301
|
});
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
|
|
302
|
+
}
|
|
303
|
+
on(name, callback, target) {
|
|
304
|
+
const bound = target ? callback.bind(target) : callback;
|
|
382
305
|
if (this.events[name]) {
|
|
383
306
|
this.events[name].push(bound);
|
|
384
307
|
}
|
|
385
308
|
else {
|
|
386
309
|
this.events[name] = [bound];
|
|
387
310
|
}
|
|
388
|
-
}
|
|
389
|
-
|
|
311
|
+
}
|
|
312
|
+
off(name) {
|
|
390
313
|
this.events[name] = undefined;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var params = [];
|
|
394
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
395
|
-
params[_i - 1] = arguments[_i];
|
|
396
|
-
}
|
|
314
|
+
}
|
|
315
|
+
emit(name, ...params) {
|
|
397
316
|
if (this.events[name]) {
|
|
398
|
-
this.events[name].forEach(
|
|
317
|
+
this.events[name].forEach((fc) => fc(...params));
|
|
399
318
|
}
|
|
400
|
-
}
|
|
401
|
-
|
|
319
|
+
}
|
|
320
|
+
resolveComponent(component) {
|
|
402
321
|
if (component.constructor.hasRender) {
|
|
403
322
|
this.addChild(component.node);
|
|
404
323
|
}
|
|
@@ -408,13 +327,12 @@ var NodeComp = /** @class */ (function () {
|
|
|
408
327
|
this.addChild(component.node);
|
|
409
328
|
}
|
|
410
329
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
330
|
+
}
|
|
331
|
+
getData(key) {
|
|
413
332
|
return this.data[key];
|
|
414
|
-
}
|
|
415
|
-
|
|
333
|
+
}
|
|
334
|
+
setData(key, val) {
|
|
416
335
|
this.data[key] = val;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
}());
|
|
336
|
+
}
|
|
337
|
+
}
|
|
420
338
|
exports.NodeComp = NodeComp;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ComponentX } from '@safe-engine/core';
|
|
2
|
+
import { ColorSource, Graphics, Point, Sprite, TextureSource } from 'pixi.js';
|
|
3
3
|
import { LoadingBar, LoadingBarMode } from '../core/LoadingBar';
|
|
4
4
|
import { SpriteTypes } from '../systems/RenderSystem';
|
|
5
|
-
|
|
5
|
+
import { NodeComp } from './NodeComp';
|
|
6
|
+
export declare class NodeRender extends ComponentX<NodeComp> {
|
|
6
7
|
nodeName?: string;
|
|
7
8
|
}
|
|
8
|
-
export declare class SpriteRender extends ComponentX {
|
|
9
|
+
export declare class SpriteRender extends ComponentX<NodeComp<Sprite>> {
|
|
9
10
|
spriteFrame: TextureSource;
|
|
10
11
|
type: SpriteTypes;
|
|
11
12
|
fillType: LoadingBarMode;
|
|
@@ -13,15 +14,15 @@ export declare class SpriteRender extends ComponentX {
|
|
|
13
14
|
fillCenter: Point;
|
|
14
15
|
loadingBar: LoadingBar;
|
|
15
16
|
setFillRange(val: number): void;
|
|
16
|
-
getSpriteFrame(): TextureSource
|
|
17
|
+
getSpriteFrame(): TextureSource;
|
|
17
18
|
setSpriteFrame(frame: any): void;
|
|
18
19
|
}
|
|
19
|
-
export declare class GraphicsRender extends ComponentX {
|
|
20
|
+
export declare class GraphicsRender extends ComponentX<NodeComp<Graphics>> {
|
|
20
21
|
lineWidth: number;
|
|
21
22
|
strokeColor: ColorSource;
|
|
22
23
|
fillColor: ColorSource;
|
|
23
24
|
}
|
|
24
|
-
export declare class MaskRender extends ComponentX {
|
|
25
|
+
export declare class MaskRender extends ComponentX<NodeComp> {
|
|
25
26
|
type: number;
|
|
26
27
|
segments: number;
|
|
27
28
|
inverted: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/components/RenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAW,aAAa,EAAE,MAAM,SAAS,CAAA;AAEtF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qBAAa,UAAW,SAAQ,UAAU,CAAC,QAAQ,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACrD,WAAW,EAAE,aAAa,CAAA;IAC1B,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,cAAc,CAAqB;IAC7C,SAAS,SAAI;IACb,UAAU,EAAE,KAAK,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IAQtB,YAAY,CAAC,GAAG,EAAE,MAAM;IAMxB,cAAc;IAId,cAAc,CAAC,KAAK,KAAA;CAkBrB;AAED,qBAAa,cAAe,SAAQ,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChE,SAAS,SAAI;IACb,WAAW,EAAE,WAAW,CAAA;IACxB,SAAS,EAAE,WAAW,CAAA;CACvB;AAED,qBAAa,UAAW,SAAQ,UAAU,CAAC,QAAQ,CAAC;IAClD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,OAAO,CAAA;CAClB"}
|