@safe-engine/cocos 1.5.2 → 1.5.5

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.
Files changed (97) hide show
  1. package/dist/animation/AnimationComponent.d.ts +63 -0
  2. package/dist/animation/AnimationComponent.d.ts.map +1 -0
  3. package/dist/animation/AnimationComponent.js +119 -0
  4. package/dist/animation/AnimationSystem.d.ts +6 -0
  5. package/dist/animation/AnimationSystem.d.ts.map +1 -0
  6. package/dist/animation/AnimationSystem.js +22 -0
  7. package/dist/animation/index.d.ts +2 -0
  8. package/dist/animation/index.d.ts.map +1 -0
  9. package/dist/animation/index.js +7 -0
  10. package/dist/app.d.ts.map +1 -1
  11. package/dist/app.js +40 -65
  12. package/dist/box2d-wasm/ContactListener.d.ts +12 -0
  13. package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
  14. package/dist/box2d-wasm/ContactListener.js +64 -0
  15. package/dist/box2d-wasm/PhysicsComponent.d.ts +50 -0
  16. package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
  17. package/dist/box2d-wasm/PhysicsComponent.js +16 -0
  18. package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
  19. package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
  20. package/dist/box2d-wasm/PhysicsSprite.js +51 -0
  21. package/dist/box2d-wasm/PhysicsSystem.d.ts +15 -0
  22. package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
  23. package/dist/box2d-wasm/PhysicsSystem.js +139 -0
  24. package/dist/box2d-wasm/debugDraw.d.ts +66 -0
  25. package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
  26. package/dist/box2d-wasm/debugDraw.js +210 -0
  27. package/dist/box2d-wasm/index.d.ts +6 -0
  28. package/dist/box2d-wasm/index.d.ts.map +1 -0
  29. package/dist/box2d-wasm/index.js +10 -0
  30. package/dist/collider/CollideComponent.js +98 -159
  31. package/dist/collider/CollideSystem.js +63 -79
  32. package/dist/collider/index.d.ts +1 -1
  33. package/dist/collider/index.d.ts.map +1 -1
  34. package/dist/collider/index.js +11 -9
  35. package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
  36. package/dist/dragonbones/index.js +38 -68
  37. package/dist/gworld/components/AnimationComponent.d.ts +2 -2
  38. package/dist/gworld/components/CollideComponent.d.ts +3 -3
  39. package/dist/gworld/components/EnhancedComponent.js +29 -36
  40. package/dist/gworld/components/GUIComponent.js +50 -118
  41. package/dist/gworld/components/NoRenderComponent.js +25 -65
  42. package/dist/gworld/components/NodeComp.d.ts.map +1 -1
  43. package/dist/gworld/components/NodeComp.js +237 -317
  44. package/dist/gworld/components/RenderComponent.js +46 -104
  45. package/dist/gworld/core/NodePool.js +13 -20
  46. package/dist/gworld/core/Scene.js +11 -35
  47. package/dist/gworld/core/decorator.js +12 -42
  48. package/dist/gworld/index.js +13 -42
  49. package/dist/gworld/systems/CollideSystem.d.ts +1 -2
  50. package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
  51. package/dist/gworld/systems/CollideSystem.js +2 -12
  52. package/dist/gworld/systems/GUISystem.js +105 -120
  53. package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
  54. package/dist/gworld/systems/NoRenderSystem.js +70 -80
  55. package/dist/gworld/systems/RenderSystem.js +64 -78
  56. package/dist/helper/Intersection.js +33 -40
  57. package/dist/helper/action.js +8 -21
  58. package/dist/helper/director.js +2 -6
  59. package/dist/helper/math.js +9 -15
  60. package/dist/helper/utils.js +28 -37
  61. package/dist/index.d.ts +5 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +20 -31
  64. package/dist/polyfills.js +69 -97
  65. package/dist/richtext/RichTextComp.js +27 -55
  66. package/dist/richtext/RichTextSystem.js +17 -25
  67. package/dist/richtext/html-text-parser.js +36 -40
  68. package/dist/richtext/index.js +5 -8
  69. package/dist/safex.js +1 -2
  70. package/dist/spine/CCSkeleton.d.ts.map +1 -1
  71. package/dist/spine/CCSkeleton.js +25 -61
  72. package/dist/spine/CCSkeletonAnimation.js +18 -54
  73. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
  74. package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
  75. package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
  76. package/dist/spine/CCSkeletonTexture.js +4 -40
  77. package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
  78. package/dist/spine/index.js +37 -63
  79. package/package.json +4 -1
  80. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
  81. package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
  82. package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
  83. package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
  84. package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
  85. package/dist/dragonbones/cocos/CocosFactory.js +0 -231
  86. package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
  87. package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
  88. package/dist/dragonbones/cocos/CocosSlot.js +0 -385
  89. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
  90. package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
  91. package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
  92. package/dist/dragonbones/dragonBones.d.ts +0 -3
  93. package/dist/dragonbones/dragonBones.d.ts.map +0 -1
  94. package/dist/dragonbones/dragonBones.js +0 -4788
  95. package/dist/helper/NodePool.d.ts +0 -9
  96. package/dist/helper/NodePool.d.ts.map +0 -1
  97. package/dist/helper/NodePool.js +0 -29
@@ -1,365 +1,287 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeComp = void 0;
4
- var utils_1 = require("../../helper/utils");
5
- var polyfills_1 = require("../../polyfills");
6
- var NoRenderComponent_1 = require("./NoRenderComponent");
7
- var NodeComp = /** @class */ (function () {
8
- function NodeComp(instance, entity) {
9
- this.children = [];
10
- this._active = true;
1
+ import { instantiate } from '../../helper/utils';
2
+ import { Vec2 } from '../../polyfills';
3
+ import { ExtraDataComp } from './NoRenderComponent';
4
+ export class NodeComp {
5
+ entity;
6
+ instance;
7
+ parent;
8
+ children = [];
9
+ name;
10
+ _group;
11
+ _active = true;
12
+ constructor(instance, entity) {
11
13
  this.entity = entity;
12
14
  this.instance = instance;
13
15
  }
14
- Object.defineProperty(NodeComp.prototype, "uuid", {
15
- get: function () {
16
- return this.entity.id;
17
- },
18
- enumerable: false,
19
- configurable: true
20
- });
21
- Object.defineProperty(NodeComp.prototype, "position", {
22
- get: function () {
23
- return (0, polyfills_1.Vec2)(this.instance.getPosition());
24
- },
25
- set: function (val) {
26
- this.instance.setPosition(val.x, val.y);
27
- },
28
- enumerable: false,
29
- configurable: true
30
- });
31
- Object.defineProperty(NodeComp.prototype, "xy", {
32
- set: function (val) {
33
- this.instance.setPosition(val[0], val[1]);
34
- },
35
- enumerable: false,
36
- configurable: true
37
- });
38
- Object.defineProperty(NodeComp.prototype, "posX", {
39
- get: function () {
40
- return this.instance.getPositionX();
41
- },
42
- set: function (val) {
43
- this.instance.setPositionX(val);
44
- },
45
- enumerable: false,
46
- configurable: true
47
- });
48
- Object.defineProperty(NodeComp.prototype, "posY", {
49
- get: function () {
50
- return this.instance.getPositionY();
51
- },
52
- set: function (val) {
53
- this.instance.setPositionY(val);
54
- },
55
- enumerable: false,
56
- configurable: true
57
- });
58
- Object.defineProperty(NodeComp.prototype, "scale", {
59
- get: function () {
60
- return this.instance.getScale();
61
- },
62
- set: function (val) {
63
- this.instance.setScale(val, val);
64
- },
65
- enumerable: false,
66
- configurable: true
67
- });
68
- Object.defineProperty(NodeComp.prototype, "scaleX", {
69
- get: function () {
70
- return this.instance.getScaleX();
71
- },
72
- set: function (val) {
73
- this.instance.setScaleX(val);
74
- },
75
- enumerable: false,
76
- configurable: true
77
- });
78
- Object.defineProperty(NodeComp.prototype, "scaleY", {
79
- get: function () {
80
- return this.instance.getScaleY();
81
- },
82
- set: function (val) {
83
- this.instance.setScaleY(val);
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(NodeComp.prototype, "anchorX", {
89
- get: function () {
90
- return this.instance.anchorX;
91
- },
92
- set: function (val) {
93
- this.instance.anchorX = val;
94
- },
95
- enumerable: false,
96
- configurable: true
97
- });
98
- Object.defineProperty(NodeComp.prototype, "anchorY", {
99
- get: function () {
100
- return this.instance.anchorY;
101
- },
102
- set: function (val) {
103
- this.instance.anchorY = val;
104
- },
105
- enumerable: false,
106
- configurable: true
107
- });
108
- Object.defineProperty(NodeComp.prototype, "rotation", {
109
- /**
110
- * Returns the angle of the node in degrees. 0 is the default rotation angle. Positive values rotate node clockwise.
111
- * @function
112
- * @return {Number} The rotation of the node in degrees.
113
- */
114
- get: function () {
115
- return this.instance.getRotation();
116
- },
117
- /**
118
- *
119
- * Sets the X angle of the node in degrees which performs a horizontal rotational skew.
120
- * (support only in WebGL rendering mode)
121
- * 0 is the default rotation angle.
122
- * Positive values rotate node clockwise, and negative values for anti-clockwise.
123
- *
124
- * @param {Number} degrees The X rotation in degrees which performs a horizontal rotational skew.
125
- */
126
- set: function (val) {
127
- this.instance.setRotation(val);
128
- },
129
- enumerable: false,
130
- configurable: true
131
- });
132
- Object.defineProperty(NodeComp.prototype, "color", {
133
- get: function () {
134
- return this.instance.getColor();
135
- },
136
- set: function (val) {
137
- this.instance.setColor(val);
138
- },
139
- enumerable: false,
140
- configurable: true
141
- });
142
- Object.defineProperty(NodeComp.prototype, "opacity", {
143
- get: function () {
144
- return this.instance.getOpacity();
145
- },
146
- set: function (val) {
147
- this.instance.setOpacity(val);
148
- },
149
- enumerable: false,
150
- configurable: true
151
- });
152
- Object.defineProperty(NodeComp.prototype, "active", {
153
- get: function () {
154
- if (!cc.sys.isObjectValid(this.instance) || !this._active)
16
+ get uuid() {
17
+ return this.entity.id;
18
+ }
19
+ get position() {
20
+ return Vec2(this.instance.getPosition());
21
+ }
22
+ set position(val) {
23
+ this.instance.setPosition(val.x, val.y);
24
+ }
25
+ set xy(val) {
26
+ this.instance.setPosition(val[0], val[1]);
27
+ }
28
+ get posX() {
29
+ return this.instance.getPositionX();
30
+ }
31
+ set posX(val) {
32
+ this.instance.setPositionX(val);
33
+ }
34
+ get posY() {
35
+ return this.instance.getPositionY();
36
+ }
37
+ set posY(val) {
38
+ this.instance.setPositionY(val);
39
+ }
40
+ get scale() {
41
+ return this.instance.getScale();
42
+ }
43
+ set scale(val) {
44
+ this.instance.setScale(val, val);
45
+ }
46
+ get scaleX() {
47
+ return this.instance.getScaleX();
48
+ }
49
+ set scaleX(val) {
50
+ this.instance.setScaleX(val);
51
+ }
52
+ get scaleY() {
53
+ return this.instance.getScaleY();
54
+ }
55
+ set scaleY(val) {
56
+ this.instance.setScaleY(val);
57
+ }
58
+ get anchorX() {
59
+ return this.instance.anchorX;
60
+ }
61
+ set anchorX(val) {
62
+ this.instance.anchorX = val;
63
+ }
64
+ get anchorY() {
65
+ return this.instance.anchorY;
66
+ }
67
+ set anchorY(val) {
68
+ this.instance.anchorY = val;
69
+ }
70
+ /**
71
+ * Returns the angle of the node in degrees. 0 is the default rotation angle. Positive values rotate node clockwise.
72
+ * @function
73
+ * @return {Number} The rotation of the node in degrees.
74
+ */
75
+ get rotation() {
76
+ return this.instance.getRotation();
77
+ }
78
+ /**
79
+ *
80
+ * Sets the X angle of the node in degrees which performs a horizontal rotational skew.
81
+ * (support only in WebGL rendering mode)
82
+ * 0 is the default rotation angle.
83
+ * Positive values rotate node clockwise, and negative values for anti-clockwise.
84
+ *
85
+ * @param {Number} degrees The X rotation in degrees which performs a horizontal rotational skew.
86
+ */
87
+ set rotation(val) {
88
+ this.instance.setRotation(val);
89
+ }
90
+ get color() {
91
+ return this.instance.getColor();
92
+ }
93
+ set color(val) {
94
+ this.instance.setColor(val);
95
+ }
96
+ get opacity() {
97
+ return this.instance.getOpacity();
98
+ }
99
+ set opacity(val) {
100
+ this.instance.setOpacity(val);
101
+ }
102
+ get active() {
103
+ if (!cc.sys.isObjectValid(this.instance) || !this._active)
104
+ return false;
105
+ let p = this.parent;
106
+ while (p) {
107
+ if (!p.active)
155
108
  return false;
156
- var p = this.parent;
157
- while (p) {
158
- if (!p.active)
159
- return false;
160
- p = p.parent;
161
- }
162
- return true;
163
- },
164
- set: function (val) {
165
- if (!cc.sys.isObjectValid(this.instance)) {
166
- return;
167
- }
168
- this._active = val;
169
- if (this.instance instanceof ccui.Widget) {
170
- this.instance.setEnabled(val);
171
- }
172
- this.instance.setVisible(val);
173
- },
174
- enumerable: false,
175
- configurable: true
176
- });
177
- Object.defineProperty(NodeComp.prototype, "group", {
178
- get: function () {
179
- return this._group;
180
- },
181
- set: function (val) {
182
- this._group = val;
183
- },
184
- enumerable: false,
185
- configurable: true
186
- });
187
- Object.defineProperty(NodeComp.prototype, "width", {
188
- get: function () {
189
- return this.instance.width;
190
- },
191
- set: function (val) {
192
- this.instance.setContentSize(val, this.height);
193
- },
194
- enumerable: false,
195
- configurable: true
196
- });
197
- Object.defineProperty(NodeComp.prototype, "height", {
198
- get: function () {
199
- return this.instance.height;
200
- },
201
- set: function (val) {
202
- this.instance.setContentSize(val, this.width);
203
- },
204
- enumerable: false,
205
- configurable: true
206
- });
207
- Object.defineProperty(NodeComp.prototype, "zIndex", {
208
- get: function () {
209
- return this.instance.zIndex;
210
- },
211
- set: function (val) {
212
- this.instance.zIndex = val;
213
- },
214
- enumerable: false,
215
- configurable: true
216
- });
217
- Object.defineProperty(NodeComp.prototype, "childrenCount", {
218
- get: function () {
219
- return this.children.length;
220
- },
221
- enumerable: false,
222
- configurable: true
223
- });
224
- NodeComp.prototype.destroy = function () {
109
+ p = p.parent;
110
+ }
111
+ return true;
112
+ }
113
+ set active(val) {
114
+ if (!cc.sys.isObjectValid(this.instance)) {
115
+ return;
116
+ }
117
+ this._active = val;
118
+ if (this.instance instanceof ccui.Widget) {
119
+ this.instance.setEnabled(val);
120
+ }
121
+ this.instance.setVisible(val);
122
+ }
123
+ get group() {
124
+ return this._group;
125
+ }
126
+ set group(val) {
127
+ this._group = val;
128
+ }
129
+ get width() {
130
+ return this.instance.width;
131
+ }
132
+ set width(val) {
133
+ this.instance.setContentSize(val, this.height);
134
+ }
135
+ get height() {
136
+ return this.instance.height;
137
+ }
138
+ set height(val) {
139
+ this.instance.setContentSize(val, this.width);
140
+ }
141
+ get zIndex() {
142
+ return this.instance.zIndex;
143
+ }
144
+ set zIndex(val) {
145
+ this.instance.zIndex = val;
146
+ }
147
+ get childrenCount() {
148
+ return this.children.length;
149
+ }
150
+ destroy() {
225
151
  this.removeFromParent(true);
226
- };
227
- NodeComp.prototype.addComponent = function (instance) {
152
+ }
153
+ addComponent(instance) {
228
154
  return this.entity.assign(instance);
229
- };
230
- NodeComp.prototype.getComponent = function (component) {
155
+ }
156
+ getComponent(component) {
231
157
  return this.entity.getComponent(component);
232
- };
233
- NodeComp.prototype.getComponentsInChildren = function (component) {
158
+ }
159
+ getComponentsInChildren(component) {
234
160
  if (!this.children.length) {
235
161
  return [];
236
162
  }
237
- var listHave = this.children.filter(function (child) {
163
+ const listHave = this.children.filter((child) => {
238
164
  return child.getComponent(component);
239
165
  });
240
- return listHave.map(function (node) { return node.getComponent(component); });
241
- };
242
- NodeComp.prototype.getComponentInChildren = function (component) {
166
+ return listHave.map((node) => node.getComponent(component));
167
+ }
168
+ getComponentInChildren(component) {
243
169
  return this.getComponentsInChildren(component)[0];
244
- };
245
- NodeComp.prototype.hasComponentInChildren = function (component) {
170
+ }
171
+ hasComponentInChildren(component) {
246
172
  if (!this.children.length) {
247
173
  return false;
248
174
  }
249
- return this.children.some(function (child) {
175
+ return this.children.some((child) => {
250
176
  return child.getComponent(component);
251
177
  });
252
- };
253
- NodeComp.prototype.getPercent = function () {
178
+ }
179
+ getPercent() {
254
180
  if (this.instance instanceof ccui.LoadingBar) {
255
181
  return this.instance.getPercent();
256
182
  }
257
183
  return 0;
258
- };
259
- NodeComp.prototype.setPercent = function (val) {
184
+ }
185
+ setPercent(val) {
260
186
  if (this.instance instanceof ccui.LoadingBar) {
261
187
  return this.instance.setPercent(val);
262
188
  }
263
- };
264
- NodeComp.prototype.setTouchEnabled = function (enabled) {
189
+ }
190
+ setTouchEnabled(enabled) {
265
191
  if (!cc.sys.isObjectValid(this.instance)) {
266
192
  return;
267
193
  }
268
194
  if (this.instance instanceof ccui.Widget) {
269
195
  this.instance.setTouchEnabled(enabled);
270
196
  }
271
- };
272
- NodeComp.prototype.addTouchEventListener = function (cb) {
197
+ }
198
+ addTouchEventListener(cb) {
273
199
  if (!cc.sys.isObjectValid(this.instance)) {
274
200
  return;
275
201
  }
276
202
  if (this.instance instanceof ccui.Widget) {
277
203
  this.instance.addTouchEventListener(cb);
278
204
  }
279
- };
280
- NodeComp.prototype.convertToNodeSpace = function (point) {
281
- var _a = this.instance.convertToNodeSpace(point), x = _a.x, y = _a.y;
282
- return (0, polyfills_1.Vec2)(x, y);
283
- };
284
- NodeComp.prototype.convertToNodeSpaceAR = function (point) {
285
- var _a = this.instance.convertToNodeSpaceAR(point), x = _a.x, y = _a.y;
286
- return (0, polyfills_1.Vec2)(x, y);
287
- };
288
- NodeComp.prototype.convertToWorldSpaceAR = function (point) {
289
- var _a = this.instance.convertToWorldSpaceAR(point), x = _a.x, y = _a.y;
290
- return (0, polyfills_1.Vec2)(x, y);
291
- };
292
- NodeComp.prototype.getPosition = function () {
205
+ }
206
+ convertToNodeSpace(point) {
207
+ const { x, y } = this.instance.convertToNodeSpace(point);
208
+ return Vec2(x, y);
209
+ }
210
+ convertToNodeSpaceAR(point) {
211
+ const { x, y } = this.instance.convertToNodeSpaceAR(point);
212
+ return Vec2(x, y);
213
+ }
214
+ convertToWorldSpaceAR(point) {
215
+ const { x, y } = this.instance.convertToWorldSpaceAR(point);
216
+ return Vec2(x, y);
217
+ }
218
+ getPosition() {
293
219
  return this.instance.getPosition();
294
- };
295
- NodeComp.prototype.setPosition = function (x, y) {
220
+ }
221
+ setPosition(x, y) {
296
222
  this.instance.setPosition(x, y);
297
- };
298
- NodeComp.prototype.setRotation = function (deg) {
223
+ }
224
+ setRotation(deg) {
299
225
  this.instance.setRotation(deg);
300
- };
301
- NodeComp.prototype.getRotation = function () {
226
+ }
227
+ getRotation() {
302
228
  return this.instance.getRotation();
303
- };
304
- NodeComp.prototype.setAnchorPoint = function (point, y) {
229
+ }
230
+ setAnchorPoint(point, y) {
305
231
  this.instance.setAnchorPoint(point, y);
306
- };
307
- NodeComp.prototype.getAnchorPoint = function () {
232
+ }
233
+ getAnchorPoint() {
308
234
  return this.instance.getAnchorPoint();
309
- };
310
- NodeComp.prototype.getBoundingBox = function () {
311
- var box = this.instance.getBoundingBox();
235
+ }
236
+ getBoundingBox() {
237
+ const box = this.instance.getBoundingBox();
312
238
  box.contains = function (point) {
313
239
  return this.x <= point.x && this.x + this.width >= point.x && this.y <= point.y && this.y + this.height >= point.y;
314
240
  };
315
241
  return box;
316
- };
317
- NodeComp.prototype.getContentSize = function () {
242
+ }
243
+ getContentSize() {
318
244
  return this.instance.getContentSize();
319
- };
320
- NodeComp.prototype.setContentSize = function (size, height) {
245
+ }
246
+ setContentSize(size, height) {
321
247
  this.instance.setContentSize(size, height);
322
248
  if (this.instance instanceof cc.ClippingNode) {
323
- var hw = (size.width || size) * 0.5;
324
- var hh = (size.height || height) * 0.5;
325
- var stencil = new cc.DrawNode();
326
- var rectangle = [cc.p(-hw, -hh), cc.p(hw, -hh), cc.p(hw, hh), cc.p(-hw, hh)];
249
+ const hw = (size.width || size) * 0.5;
250
+ const hh = (size.height || height) * 0.5;
251
+ const stencil = new cc.DrawNode();
252
+ const rectangle = [cc.p(-hw, -hh), cc.p(hw, -hh), cc.p(hw, hh), cc.p(-hw, hh)];
327
253
  stencil.drawPoly(rectangle, cc.Color.WHITE, 0, cc.Color.WHITE);
328
254
  // stencil.drawDot(cc.p(-height * 0.5, -height * 0.5), height, cc.Color.WHITE);
329
255
  this.instance.stencil = stencil;
330
256
  }
331
- };
332
- NodeComp.prototype.setColor = function (color) {
257
+ }
258
+ setColor(color) {
333
259
  this.instance.setColor(color);
334
- };
335
- NodeComp.prototype.setScale = function (scaleX, scaleY) {
260
+ }
261
+ setScale(scaleX, scaleY) {
336
262
  this.instance.setScale(scaleX, scaleY || scaleX);
337
- };
338
- NodeComp.prototype.runAction = function (atc) {
263
+ }
264
+ runAction(atc) {
339
265
  this.instance.runAction(atc);
340
- };
341
- NodeComp.prototype.stopAllActions = function () {
266
+ }
267
+ stopAllActions() {
342
268
  this.instance.stopAllActions();
343
- };
344
- NodeComp.prototype.pauseAllActionsAndSchedule = function () {
269
+ }
270
+ pauseAllActionsAndSchedule() {
345
271
  this.instance.pause();
346
272
  this.instance.unscheduleUpdate();
347
- };
348
- NodeComp.prototype.resumeAllActionsAndSchedule = function () {
273
+ }
274
+ resumeAllActionsAndSchedule() {
349
275
  this.instance.resume();
350
276
  this.instance.scheduleUpdate();
351
- };
352
- NodeComp.prototype.removeFromParent = function (cleanup) {
353
- var _this = this;
277
+ }
278
+ removeFromParent(cleanup) {
354
279
  this.active = false;
355
280
  if (this.parent) {
356
- this.parent.children = this.parent.children.filter(function (_a) {
357
- var entity = _a.entity;
358
- return entity.id !== _this.entity.id;
359
- });
281
+ this.parent.children = this.parent.children.filter(({ entity }) => entity.id !== this.entity.id);
360
282
  }
361
283
  if (cleanup) {
362
- this.children.forEach(function (child) {
284
+ this.children.forEach((child) => {
363
285
  child.destroy();
364
286
  });
365
287
  this.parent = null;
@@ -371,47 +293,45 @@ var NodeComp = /** @class */ (function () {
371
293
  this.stopAllActions();
372
294
  this.instance.removeFromParent();
373
295
  }
374
- };
375
- NodeComp.prototype.addChild = function (child) {
296
+ }
297
+ addChild(child) {
376
298
  child._active = true;
377
299
  child.parent = this;
378
300
  this.children.push(child);
379
301
  this.instance.addChild(child.instance);
380
- };
381
- NodeComp.prototype.removeAllChildren = function (cleanup) {
382
- this.children.forEach(function (child) {
302
+ }
303
+ removeAllChildren(cleanup) {
304
+ this.children.forEach((child) => {
383
305
  child.removeFromParent(cleanup);
384
306
  });
385
- };
386
- NodeComp.prototype.getData = function (key) {
387
- var data = this.getComponent(NoRenderComponent_1.ExtraDataComp);
307
+ }
308
+ getData(key) {
309
+ const data = this.getComponent(ExtraDataComp);
388
310
  if (!data)
389
311
  throw Error('need add ExtraDataComp to Node');
390
312
  return data.getData(key);
391
- };
392
- NodeComp.prototype.setData = function (key, value) {
393
- var data = this.getComponent(NoRenderComponent_1.ExtraDataComp);
313
+ }
314
+ setData(key, value) {
315
+ const data = this.getComponent(ExtraDataComp);
394
316
  if (!data) {
395
- this.addComponent((0, utils_1.instantiate)(NoRenderComponent_1.ExtraDataComp, { key: key, value: value }));
317
+ this.addComponent(instantiate(ExtraDataComp, { key, value }));
396
318
  }
397
319
  else {
398
320
  data.setData(key, value);
399
321
  }
400
- };
401
- NodeComp.prototype.removeData = function (key) {
402
- var data = this.getComponent(NoRenderComponent_1.ExtraDataComp);
322
+ }
323
+ removeData(key) {
324
+ const data = this.getComponent(ExtraDataComp);
403
325
  if (data) {
404
326
  data.removeData(key);
405
327
  }
406
- };
407
- NodeComp.prototype.resolveComponent = function (component) {
328
+ }
329
+ resolveComponent(component) {
408
330
  if (component.constructor.hasRender) {
409
331
  this.addChild(component.node);
410
332
  }
411
333
  else {
412
334
  this.addComponent(component);
413
335
  }
414
- };
415
- return NodeComp;
416
- }());
417
- exports.NodeComp = NodeComp;
336
+ }
337
+ }