@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.
- package/dist/animation/AnimationComponent.d.ts +63 -0
- package/dist/animation/AnimationComponent.d.ts.map +1 -0
- package/dist/animation/AnimationComponent.js +119 -0
- package/dist/animation/AnimationSystem.d.ts +6 -0
- package/dist/animation/AnimationSystem.d.ts.map +1 -0
- package/dist/animation/AnimationSystem.js +22 -0
- package/dist/animation/index.d.ts +2 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +40 -65
- package/dist/box2d-wasm/ContactListener.d.ts +12 -0
- package/dist/box2d-wasm/ContactListener.d.ts.map +1 -0
- package/dist/box2d-wasm/ContactListener.js +64 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts +50 -0
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsComponent.js +16 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts +12 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSprite.js +51 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts +15 -0
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -0
- package/dist/box2d-wasm/PhysicsSystem.js +139 -0
- package/dist/box2d-wasm/debugDraw.d.ts +66 -0
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -0
- package/dist/box2d-wasm/debugDraw.js +210 -0
- package/dist/box2d-wasm/index.d.ts +6 -0
- package/dist/box2d-wasm/index.d.ts.map +1 -0
- package/dist/box2d-wasm/index.js +10 -0
- package/dist/collider/CollideComponent.js +98 -159
- package/dist/collider/CollideSystem.js +63 -79
- package/dist/collider/index.d.ts +1 -1
- package/dist/collider/index.d.ts.map +1 -1
- package/dist/collider/index.js +11 -9
- package/dist/dragonbones/PixiDragonBonesSprite.js +15 -19
- package/dist/dragonbones/index.js +38 -68
- package/dist/gworld/components/AnimationComponent.d.ts +2 -2
- package/dist/gworld/components/CollideComponent.d.ts +3 -3
- package/dist/gworld/components/EnhancedComponent.js +29 -36
- package/dist/gworld/components/GUIComponent.js +50 -118
- package/dist/gworld/components/NoRenderComponent.js +25 -65
- package/dist/gworld/components/NodeComp.d.ts.map +1 -1
- package/dist/gworld/components/NodeComp.js +237 -317
- package/dist/gworld/components/RenderComponent.js +46 -104
- package/dist/gworld/core/NodePool.js +13 -20
- package/dist/gworld/core/Scene.js +11 -35
- package/dist/gworld/core/decorator.js +12 -42
- package/dist/gworld/index.js +13 -42
- package/dist/gworld/systems/CollideSystem.d.ts +1 -2
- package/dist/gworld/systems/CollideSystem.d.ts.map +1 -1
- package/dist/gworld/systems/CollideSystem.js +2 -12
- package/dist/gworld/systems/GUISystem.js +105 -120
- package/dist/gworld/systems/NoRenderSystem.d.ts.map +1 -1
- package/dist/gworld/systems/NoRenderSystem.js +70 -80
- package/dist/gworld/systems/RenderSystem.js +64 -78
- package/dist/helper/Intersection.js +33 -40
- package/dist/helper/action.js +8 -21
- package/dist/helper/director.js +2 -6
- package/dist/helper/math.js +9 -15
- package/dist/helper/utils.js +28 -37
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -31
- package/dist/polyfills.js +69 -97
- package/dist/richtext/RichTextComp.js +27 -55
- package/dist/richtext/RichTextSystem.js +17 -25
- package/dist/richtext/html-text-parser.js +36 -40
- package/dist/richtext/index.js +5 -8
- package/dist/safex.js +1 -2
- package/dist/spine/CCSkeleton.d.ts.map +1 -1
- package/dist/spine/CCSkeleton.js +25 -61
- package/dist/spine/CCSkeletonAnimation.js +18 -54
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.d.ts.map +1 -1
- package/dist/spine/CCSkeletonCanvasRenderCmd.js +39 -43
- package/dist/spine/CCSkeletonTexture.js +4 -40
- package/dist/spine/CCSkeletonWebGLRenderCmd.js +56 -92
- package/dist/spine/index.js +37 -63
- package/package.json +4 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts +0 -77
- package/dist/dragonbones/cocos/CocosArmatureDisplay.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosArmatureDisplay.js +0 -227
- package/dist/dragonbones/cocos/CocosFactory.d.ts +0 -128
- package/dist/dragonbones/cocos/CocosFactory.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosFactory.js +0 -231
- package/dist/dragonbones/cocos/CocosSlot.d.ts +0 -49
- package/dist/dragonbones/cocos/CocosSlot.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosSlot.js +0 -385
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts +0 -53
- package/dist/dragonbones/cocos/CocosTextureAtlasData.d.ts.map +0 -1
- package/dist/dragonbones/cocos/CocosTextureAtlasData.js +0 -158
- package/dist/dragonbones/dragonBones.d.ts +0 -3
- package/dist/dragonbones/dragonBones.d.ts.map +0 -1
- package/dist/dragonbones/dragonBones.js +0 -4788
- package/dist/helper/NodePool.d.ts +0 -9
- package/dist/helper/NodePool.d.ts.map +0 -1
- package/dist/helper/NodePool.js +0 -29
|
@@ -1,365 +1,287 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
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
|
-
|
|
152
|
+
}
|
|
153
|
+
addComponent(instance) {
|
|
228
154
|
return this.entity.assign(instance);
|
|
229
|
-
}
|
|
230
|
-
|
|
155
|
+
}
|
|
156
|
+
getComponent(component) {
|
|
231
157
|
return this.entity.getComponent(component);
|
|
232
|
-
}
|
|
233
|
-
|
|
158
|
+
}
|
|
159
|
+
getComponentsInChildren(component) {
|
|
234
160
|
if (!this.children.length) {
|
|
235
161
|
return [];
|
|
236
162
|
}
|
|
237
|
-
|
|
163
|
+
const listHave = this.children.filter((child) => {
|
|
238
164
|
return child.getComponent(component);
|
|
239
165
|
});
|
|
240
|
-
return listHave.map(
|
|
241
|
-
}
|
|
242
|
-
|
|
166
|
+
return listHave.map((node) => node.getComponent(component));
|
|
167
|
+
}
|
|
168
|
+
getComponentInChildren(component) {
|
|
243
169
|
return this.getComponentsInChildren(component)[0];
|
|
244
|
-
}
|
|
245
|
-
|
|
170
|
+
}
|
|
171
|
+
hasComponentInChildren(component) {
|
|
246
172
|
if (!this.children.length) {
|
|
247
173
|
return false;
|
|
248
174
|
}
|
|
249
|
-
return this.children.some(
|
|
175
|
+
return this.children.some((child) => {
|
|
250
176
|
return child.getComponent(component);
|
|
251
177
|
});
|
|
252
|
-
}
|
|
253
|
-
|
|
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
|
-
|
|
184
|
+
}
|
|
185
|
+
setPercent(val) {
|
|
260
186
|
if (this.instance instanceof ccui.LoadingBar) {
|
|
261
187
|
return this.instance.setPercent(val);
|
|
262
188
|
}
|
|
263
|
-
}
|
|
264
|
-
|
|
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
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
return
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
return
|
|
291
|
-
}
|
|
292
|
-
|
|
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
|
-
|
|
220
|
+
}
|
|
221
|
+
setPosition(x, y) {
|
|
296
222
|
this.instance.setPosition(x, y);
|
|
297
|
-
}
|
|
298
|
-
|
|
223
|
+
}
|
|
224
|
+
setRotation(deg) {
|
|
299
225
|
this.instance.setRotation(deg);
|
|
300
|
-
}
|
|
301
|
-
|
|
226
|
+
}
|
|
227
|
+
getRotation() {
|
|
302
228
|
return this.instance.getRotation();
|
|
303
|
-
}
|
|
304
|
-
|
|
229
|
+
}
|
|
230
|
+
setAnchorPoint(point, y) {
|
|
305
231
|
this.instance.setAnchorPoint(point, y);
|
|
306
|
-
}
|
|
307
|
-
|
|
232
|
+
}
|
|
233
|
+
getAnchorPoint() {
|
|
308
234
|
return this.instance.getAnchorPoint();
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
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
|
-
|
|
242
|
+
}
|
|
243
|
+
getContentSize() {
|
|
318
244
|
return this.instance.getContentSize();
|
|
319
|
-
}
|
|
320
|
-
|
|
245
|
+
}
|
|
246
|
+
setContentSize(size, height) {
|
|
321
247
|
this.instance.setContentSize(size, height);
|
|
322
248
|
if (this.instance instanceof cc.ClippingNode) {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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
|
-
|
|
257
|
+
}
|
|
258
|
+
setColor(color) {
|
|
333
259
|
this.instance.setColor(color);
|
|
334
|
-
}
|
|
335
|
-
|
|
260
|
+
}
|
|
261
|
+
setScale(scaleX, scaleY) {
|
|
336
262
|
this.instance.setScale(scaleX, scaleY || scaleX);
|
|
337
|
-
}
|
|
338
|
-
|
|
263
|
+
}
|
|
264
|
+
runAction(atc) {
|
|
339
265
|
this.instance.runAction(atc);
|
|
340
|
-
}
|
|
341
|
-
|
|
266
|
+
}
|
|
267
|
+
stopAllActions() {
|
|
342
268
|
this.instance.stopAllActions();
|
|
343
|
-
}
|
|
344
|
-
|
|
269
|
+
}
|
|
270
|
+
pauseAllActionsAndSchedule() {
|
|
345
271
|
this.instance.pause();
|
|
346
272
|
this.instance.unscheduleUpdate();
|
|
347
|
-
}
|
|
348
|
-
|
|
273
|
+
}
|
|
274
|
+
resumeAllActionsAndSchedule() {
|
|
349
275
|
this.instance.resume();
|
|
350
276
|
this.instance.scheduleUpdate();
|
|
351
|
-
}
|
|
352
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
382
|
-
this.children.forEach(
|
|
302
|
+
}
|
|
303
|
+
removeAllChildren(cleanup) {
|
|
304
|
+
this.children.forEach((child) => {
|
|
383
305
|
child.removeFromParent(cleanup);
|
|
384
306
|
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
|
|
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
|
-
|
|
393
|
-
|
|
313
|
+
}
|
|
314
|
+
setData(key, value) {
|
|
315
|
+
const data = this.getComponent(ExtraDataComp);
|
|
394
316
|
if (!data) {
|
|
395
|
-
this.addComponent(
|
|
317
|
+
this.addComponent(instantiate(ExtraDataComp, { key, value }));
|
|
396
318
|
}
|
|
397
319
|
else {
|
|
398
320
|
data.setData(key, value);
|
|
399
321
|
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
322
|
+
}
|
|
323
|
+
removeData(key) {
|
|
324
|
+
const data = this.getComponent(ExtraDataComp);
|
|
403
325
|
if (data) {
|
|
404
326
|
data.removeData(key);
|
|
405
327
|
}
|
|
406
|
-
}
|
|
407
|
-
|
|
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
|
-
|
|
416
|
-
}());
|
|
417
|
-
exports.NodeComp = NodeComp;
|
|
336
|
+
}
|
|
337
|
+
}
|