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