@safe-engine/cocos 1.6.5 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/AnimationComponent.d.ts +1 -1
- package/dist/animation/AnimationComponent.d.ts.map +1 -1
- package/dist/animation/AnimationComponent.js +2 -2
- package/dist/animation/AnimationSystem.js +1 -1
- package/dist/app.d.ts +2 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +39 -29
- package/dist/box2d-wasm/PhysicsComponent.d.ts +3 -1
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +17 -4
- package/dist/box2d-wasm/PhysicsSprite.d.ts +1 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSprite.js +3 -4
- package/dist/box2d-wasm/PhysicsSystem.d.ts +1 -2
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +33 -29
- package/dist/collider/CollideComponent.d.ts +1 -1
- package/dist/collider/CollideComponent.d.ts.map +1 -1
- package/dist/collider/CollideComponent.js +1 -1
- package/dist/collider/CollideSystem.js +1 -1
- package/dist/collider/index.d.ts +1 -0
- package/dist/collider/index.d.ts.map +1 -1
- package/dist/collider/index.js +1 -0
- package/dist/dragonbones/index.d.ts +1 -1
- package/dist/dragonbones/index.d.ts.map +1 -1
- package/dist/dragonbones/index.js +2 -2
- package/dist/gui/GUIComponent.d.ts +93 -0
- package/dist/gui/GUIComponent.d.ts.map +1 -0
- package/dist/gui/GUIComponent.js +77 -0
- package/dist/gui/GUISystem.d.ts +15 -0
- package/dist/gui/GUISystem.d.ts.map +1 -0
- package/dist/gui/GUISystem.js +112 -0
- package/dist/gui/index.d.ts +3 -0
- package/dist/gui/index.d.ts.map +1 -0
- package/dist/gui/index.js +2 -0
- package/dist/gworld/EnhancedComponent.d.ts +22 -0
- package/dist/gworld/EnhancedComponent.d.ts.map +1 -0
- package/dist/gworld/EnhancedComponent.js +44 -0
- package/dist/gworld/NodeComp.d.ts +153 -0
- package/dist/gworld/NodeComp.d.ts.map +1 -0
- package/dist/gworld/NodeComp.js +337 -0
- package/dist/{helper → gworld}/NodePool.d.ts +1 -1
- package/dist/gworld/NodePool.d.ts.map +1 -0
- package/dist/gworld/NodePool.js +23 -0
- package/dist/gworld/Scene.d.ts +5 -0
- package/dist/gworld/Scene.d.ts.map +1 -0
- package/dist/gworld/Scene.js +14 -0
- package/dist/gworld/components/AnimationComponent.d.ts +2 -2
- package/dist/gworld/components/CollideComponent.d.ts +2 -2
- package/dist/gworld/components/EnhancedComponent.d.ts +2 -2
- package/dist/gworld/components/GUIComponent.d.ts +4 -4
- package/dist/gworld/components/NoRenderComponent.d.ts +3 -3
- package/dist/gworld/components/NodeComp.d.ts +2 -2
- package/dist/gworld/components/RenderComponent.d.ts +4 -4
- package/dist/gworld/core/NodePool.d.ts +1 -1
- package/dist/gworld/core/Scene.d.ts +1 -1
- package/dist/gworld/core/decorator.d.ts +2 -2
- package/dist/gworld/decorator.d.ts +9 -0
- package/dist/gworld/decorator.d.ts.map +1 -0
- package/dist/gworld/decorator.js +13 -0
- package/dist/gworld/index.d.ts +5 -0
- package/dist/gworld/index.d.ts.map +1 -1
- package/dist/gworld/index.js +5 -0
- 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/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -7
- package/dist/norender/NoRenderComponent.d.ts +37 -0
- package/dist/norender/NoRenderComponent.d.ts.map +1 -0
- package/dist/norender/NoRenderComponent.js +41 -0
- package/dist/norender/NoRenderSystem.d.ts +16 -0
- package/dist/norender/NoRenderSystem.d.ts.map +1 -0
- package/dist/norender/NoRenderSystem.js +75 -0
- package/dist/norender/index.d.ts +3 -0
- package/dist/norender/index.d.ts.map +1 -0
- package/dist/norender/index.js +2 -0
- package/dist/render/RenderComponent.d.ts +48 -0
- package/dist/render/RenderComponent.d.ts.map +1 -0
- package/dist/render/RenderComponent.js +80 -0
- package/dist/render/RenderSystem.d.ts +21 -0
- package/dist/render/RenderSystem.d.ts.map +1 -0
- package/dist/render/RenderSystem.js +74 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +2 -0
- package/dist/richtext/RichTextComp.d.ts +1 -1
- package/dist/richtext/RichTextComp.d.ts.map +1 -1
- package/dist/richtext/RichTextComp.js +1 -1
- package/package.json +1 -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.map +0 -1
- package/dist/helper/NodePool.js +0 -29
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ComponentX, NoRenderComponentX } from '../gworld/decorator';
|
|
2
|
+
import { Vec2 } from '../polyfills';
|
|
3
|
+
export const FillType = {
|
|
4
|
+
HORIZONTAL: 0,
|
|
5
|
+
VERTICAL: 1,
|
|
6
|
+
RADIAL: 2,
|
|
7
|
+
};
|
|
8
|
+
export class ButtonComp extends NoRenderComponentX {
|
|
9
|
+
// texType: ccui.Widget.TextureType
|
|
10
|
+
clickEvents = [];
|
|
11
|
+
setOnPress(cb) {
|
|
12
|
+
this.props.onPress = cb;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class ProgressTimerComp extends ComponentX {
|
|
16
|
+
spriteFrame;
|
|
17
|
+
fillType;
|
|
18
|
+
fillRange;
|
|
19
|
+
fillCenter;
|
|
20
|
+
isReverse;
|
|
21
|
+
getFillRange() {
|
|
22
|
+
if (this.node.instance instanceof cc.ProgressTimer) {
|
|
23
|
+
return this.node.instance.getPercentage() * 0.01;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
setFillStart(val) {
|
|
27
|
+
if (this.node.instance instanceof cc.ProgressTimer) {
|
|
28
|
+
this.node.instance.setMidpoint(Vec2(val, val));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
setFillRange(val) {
|
|
32
|
+
if (this.node.instance instanceof cc.ProgressTimer) {
|
|
33
|
+
this.node.instance.setPercentage(val * 100);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export class LabelComp extends ComponentX {
|
|
38
|
+
get string() {
|
|
39
|
+
return this.props.string;
|
|
40
|
+
}
|
|
41
|
+
set string(val) {
|
|
42
|
+
this.props.string = val;
|
|
43
|
+
if (this.node.instance instanceof ccui.Text) {
|
|
44
|
+
this.node.instance.setString(val);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class LabelOutlineComp extends NoRenderComponentX {
|
|
49
|
+
color;
|
|
50
|
+
width;
|
|
51
|
+
}
|
|
52
|
+
export class LabelShadowComp extends NoRenderComponentX {
|
|
53
|
+
color;
|
|
54
|
+
blur;
|
|
55
|
+
offset;
|
|
56
|
+
}
|
|
57
|
+
export var ScrollViewDirection;
|
|
58
|
+
(function (ScrollViewDirection) {
|
|
59
|
+
ScrollViewDirection[ScrollViewDirection["NONE"] = cc.SCROLLVIEW_DIRECTION_NONE] = "NONE";
|
|
60
|
+
ScrollViewDirection[ScrollViewDirection["HORIZONTAL"] = cc.SCROLLVIEW_DIRECTION_HORIZONTAL] = "HORIZONTAL";
|
|
61
|
+
ScrollViewDirection[ScrollViewDirection["VERTICAL"] = cc.SCROLLVIEW_DIRECTION_VERTICAL] = "VERTICAL";
|
|
62
|
+
ScrollViewDirection[ScrollViewDirection["BOTH"] = cc.SCROLLVIEW_DIRECTION_BOTH] = "BOTH";
|
|
63
|
+
})(ScrollViewDirection || (ScrollViewDirection = {}));
|
|
64
|
+
export class ScrollViewComp extends ComponentX {
|
|
65
|
+
zoom(scale) {
|
|
66
|
+
if (this.node.instance instanceof cc.ScrollView) {
|
|
67
|
+
this.node.instance.getContainer().setScale(scale);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class InputComp extends ComponentX {
|
|
72
|
+
get string() {
|
|
73
|
+
return this.node.instance.getString();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export class BlockInputEventsComp extends NoRenderComponentX {
|
|
77
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
export declare class GUISystem implements System {
|
|
3
|
+
defaultFont: string;
|
|
4
|
+
configure(event_manager: EventManager): void;
|
|
5
|
+
private onAddButtonComp;
|
|
6
|
+
private onAddProgressTimerComp;
|
|
7
|
+
private onAddLabelComp;
|
|
8
|
+
private onAddLabelOutlineComp;
|
|
9
|
+
private onAddLabelShadowComp;
|
|
10
|
+
private onAddScrollViewComp;
|
|
11
|
+
private onAddBlockInputEventsComp;
|
|
12
|
+
private onAddInputComp;
|
|
13
|
+
update(entities: EntityManager, events: EventManager, dt: number): any;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=GUISystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GUISystem.d.ts","sourceRoot":"","sources":["../../src/gui/GUISystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,EAAE,MAAM,YAAY,CAAA;AAMlG,qBAAa,SAAU,YAAW,MAAM;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,aAAa,EAAE,YAAY;IAWrC,OAAO,CAAC,eAAe,CAuBtB;IAED,OAAO,CAAC,sBAAsB,CAc7B;IAED,OAAO,CAAC,cAAc,CAMrB;IAED,OAAO,CAAC,qBAAqB,CAM5B;IAED,OAAO,CAAC,oBAAoB,CAM3B;IAED,OAAO,CAAC,mBAAmB,CAU1B;IAED,OAAO,CAAC,yBAAyB,CAOhC;IAED,OAAO,CAAC,cAAc,CAWrB;IAED,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;CAIjE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { EventTypes } from 'entityx-ts';
|
|
2
|
+
import { NodeComp } from '../gworld';
|
|
3
|
+
import { TouchEventRegister } from '../norender';
|
|
4
|
+
import { Vec2 } from '../polyfills';
|
|
5
|
+
import { BlockInputEventsComp, ButtonComp, FillType, InputComp, LabelComp, LabelOutlineComp, LabelShadowComp, ProgressTimerComp, ScrollViewComp } from './GUIComponent';
|
|
6
|
+
export class GUISystem {
|
|
7
|
+
defaultFont;
|
|
8
|
+
configure(event_manager) {
|
|
9
|
+
event_manager.subscribe(EventTypes.ComponentAdded, ButtonComp, this.onAddButtonComp);
|
|
10
|
+
event_manager.subscribe(EventTypes.ComponentAdded, ProgressTimerComp, this.onAddProgressTimerComp);
|
|
11
|
+
event_manager.subscribe(EventTypes.ComponentAdded, LabelComp, this.onAddLabelComp);
|
|
12
|
+
event_manager.subscribe(EventTypes.ComponentAdded, LabelOutlineComp, this.onAddLabelOutlineComp);
|
|
13
|
+
event_manager.subscribe(EventTypes.ComponentAdded, LabelShadowComp, this.onAddLabelShadowComp);
|
|
14
|
+
event_manager.subscribe(EventTypes.ComponentAdded, ScrollViewComp, this.onAddScrollViewComp);
|
|
15
|
+
event_manager.subscribe(EventTypes.ComponentAdded, InputComp, this.onAddInputComp);
|
|
16
|
+
event_manager.subscribe(EventTypes.ComponentAdded, BlockInputEventsComp, this.onAddBlockInputEventsComp);
|
|
17
|
+
}
|
|
18
|
+
onAddButtonComp = ({ entity, component: button }) => {
|
|
19
|
+
const nodeComp = entity.getComponent(NodeComp);
|
|
20
|
+
const { zoomScale = 1.2 } = button.props;
|
|
21
|
+
button.node = nodeComp;
|
|
22
|
+
const lastScaleX = nodeComp.scaleX;
|
|
23
|
+
const lastScaleY = nodeComp.scaleY;
|
|
24
|
+
const touchComp = entity.assign(new TouchEventRegister());
|
|
25
|
+
touchComp.props.onTouchStart = function (touch) {
|
|
26
|
+
const p = touch.getLocation();
|
|
27
|
+
// console.log('onTouchBegan', p, lastScaleX, lastScaleY)
|
|
28
|
+
const rect = nodeComp.getBoundingBox();
|
|
29
|
+
const nodeSpaceLocation = nodeComp.parent.convertToNodeSpace(p);
|
|
30
|
+
if (rect.contains(nodeSpaceLocation) && button.enabled && nodeComp.active) {
|
|
31
|
+
const scale = cc.scaleTo(0.3, zoomScale * lastScaleX, lastScaleY * zoomScale);
|
|
32
|
+
nodeComp.runAction(scale);
|
|
33
|
+
button.props.onPress(button);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
touchComp.props.onTouchEnd = function () {
|
|
37
|
+
const scale = cc.scaleTo(0.3, lastScaleX, lastScaleY);
|
|
38
|
+
nodeComp.runAction(scale);
|
|
39
|
+
};
|
|
40
|
+
touchComp.props.onTouchCancel = touchComp.props.onTouchEnd;
|
|
41
|
+
};
|
|
42
|
+
onAddProgressTimerComp = ({ entity, component: bar }) => {
|
|
43
|
+
const { spriteFrame, fillType = FillType.HORIZONTAL, fillRange = 1, fillCenter = Vec2(0, 0) } = bar.props;
|
|
44
|
+
const frame = cc.spriteFrameCache.getSpriteFrame(spriteFrame);
|
|
45
|
+
const sprite = new cc.Sprite(frame || spriteFrame);
|
|
46
|
+
const pTimer = new cc.ProgressTimer(sprite);
|
|
47
|
+
const ptt = fillType === FillType.RADIAL ? cc.ProgressTimer.TYPE_RADIAL : cc.ProgressTimer.TYPE_BAR;
|
|
48
|
+
pTimer.setType(ptt);
|
|
49
|
+
if (fillType !== FillType.RADIAL) {
|
|
50
|
+
const rate = fillType === FillType.HORIZONTAL ? cc.p(1, 0) : cc.p(0, 1);
|
|
51
|
+
pTimer.setBarChangeRate(rate);
|
|
52
|
+
}
|
|
53
|
+
pTimer.setPercentage(fillRange * 100);
|
|
54
|
+
pTimer.setMidpoint(fillCenter);
|
|
55
|
+
bar.node = entity.assign(new NodeComp(pTimer, entity));
|
|
56
|
+
};
|
|
57
|
+
onAddLabelComp = ({ entity, component: label }) => {
|
|
58
|
+
const { string = '', font = this.defaultFont, size = 64 } = label.props;
|
|
59
|
+
const fontName = cc.path.basename(font, '.ttf');
|
|
60
|
+
const node = new ccui.Text(string, fontName, size);
|
|
61
|
+
node.setTextVerticalAlignment(cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM);
|
|
62
|
+
label.node = entity.assign(new NodeComp(node, entity));
|
|
63
|
+
};
|
|
64
|
+
onAddLabelOutlineComp = ({ entity, component: outline }) => {
|
|
65
|
+
const { color, width } = outline.props;
|
|
66
|
+
const node = entity.getComponent(NodeComp);
|
|
67
|
+
if (node.instance instanceof ccui.Text) {
|
|
68
|
+
node.instance.enableOutline(color, width);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
onAddLabelShadowComp = ({ entity, component: shadow }) => {
|
|
72
|
+
const { color, blur, offset } = shadow.props;
|
|
73
|
+
const node = entity.getComponent(NodeComp);
|
|
74
|
+
if (node.instance instanceof ccui.Text) {
|
|
75
|
+
node.instance.enableShadow(color, offset, blur);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
onAddScrollViewComp = ({ entity, component: scrollView }) => {
|
|
79
|
+
const { viewSize, contentSize, direction = cc.SCROLLVIEW_DIRECTION_VERTICAL } = scrollView.props;
|
|
80
|
+
const node = new cc.ScrollView(viewSize);
|
|
81
|
+
node.setContentSize(contentSize);
|
|
82
|
+
node.setViewSize(viewSize);
|
|
83
|
+
node.setDirection(direction);
|
|
84
|
+
// node.setContentOffset(cc.p(0, viewSize.height - contentSize.height))
|
|
85
|
+
// node.setTouchEnabled(false)
|
|
86
|
+
node.setBounceable(false);
|
|
87
|
+
scrollView.node = entity.assign(new NodeComp(node, entity));
|
|
88
|
+
};
|
|
89
|
+
onAddBlockInputEventsComp = ({ entity, component: blockInput }) => {
|
|
90
|
+
const node = entity.getComponent(NodeComp);
|
|
91
|
+
if (node.instance instanceof ccui.ImageView) {
|
|
92
|
+
node.instance.setTouchEnabled(true);
|
|
93
|
+
node.instance.setScale9Enabled(true);
|
|
94
|
+
}
|
|
95
|
+
blockInput.node = node;
|
|
96
|
+
};
|
|
97
|
+
onAddInputComp = ({ entity, component: textInput }) => {
|
|
98
|
+
const { placeHolder = '', font = this.defaultFont, size = 64, maxLength = 20, isPassword = false } = textInput.props;
|
|
99
|
+
const textField = new ccui.TextField();
|
|
100
|
+
textField.setPlaceHolder(placeHolder);
|
|
101
|
+
textField.setFontName(font);
|
|
102
|
+
textField.setFontSize(size);
|
|
103
|
+
textField.setTextColor(cc.color(255, 255, 255));
|
|
104
|
+
textField.setMaxLengthEnabled(true);
|
|
105
|
+
textField.setMaxLength(maxLength);
|
|
106
|
+
textField.setPasswordEnabled(isPassword);
|
|
107
|
+
textInput.node = entity.assign(new NodeComp(textField, entity));
|
|
108
|
+
};
|
|
109
|
+
update() {
|
|
110
|
+
// throw new Error('Method not implemented.');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gui/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Constructor } from 'entityx-ts';
|
|
2
|
+
import { BaseComponentProps } from '../safex';
|
|
3
|
+
import { NodeComp } from './NodeComp';
|
|
4
|
+
export declare class EnhancedComponent<Props = object, N extends NodeComp<any> = NodeComp<any>> {
|
|
5
|
+
static hasRender: boolean;
|
|
6
|
+
props: Props;
|
|
7
|
+
node: N;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
constructor(data?: BaseComponentProps<EnhancedComponent> & Props);
|
|
10
|
+
init(data?: Props): void;
|
|
11
|
+
addComponent<T extends EnhancedComponent>(instance: T): T;
|
|
12
|
+
getComponent<T extends EnhancedComponent>(component: Constructor<T>): T;
|
|
13
|
+
schedule(callback: (arg: any) => void, interval: number, repeat?: number, delay?: number): void;
|
|
14
|
+
unschedule(callback: (arg: any) => void): void;
|
|
15
|
+
unscheduleAllCallbacks(): void;
|
|
16
|
+
scheduleOnce(callback: (arg: any) => void, delay: number, key?: string): void;
|
|
17
|
+
getComponentsInChildren<T extends ComponentType>(component: Constructor<T>): T[];
|
|
18
|
+
getComponentInChildren<T extends ComponentType>(component: Constructor<T>): T;
|
|
19
|
+
isEqual(other: EnhancedComponent): boolean;
|
|
20
|
+
}
|
|
21
|
+
export type ComponentType = EnhancedComponent | NodeComp;
|
|
22
|
+
//# sourceMappingURL=EnhancedComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnhancedComponent.d.ts","sourceRoot":"","sources":["../../src/gworld/EnhancedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA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3
|
+
props = {};
|
|
4
|
+
node;
|
|
5
|
+
enabled = true;
|
|
6
|
+
constructor(data) {
|
|
7
|
+
this.init(data);
|
|
8
|
+
}
|
|
9
|
+
init(data) {
|
|
10
|
+
if (data) {
|
|
11
|
+
// console.log('constructor', this.constructor.name, data)
|
|
12
|
+
Object.keys(data).forEach((key) => {
|
|
13
|
+
this.props[key] = data[key];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
addComponent(instance) {
|
|
18
|
+
return this.node.addComponent(instance);
|
|
19
|
+
}
|
|
20
|
+
getComponent(component) {
|
|
21
|
+
return this.node.getComponent(component);
|
|
22
|
+
}
|
|
23
|
+
schedule(callback, interval, repeat = cc.macro.REPEAT_FOREVER, delay = 0) {
|
|
24
|
+
this.node.instance.schedule(callback.bind(this), interval, repeat, delay);
|
|
25
|
+
}
|
|
26
|
+
unschedule(callback) {
|
|
27
|
+
this.node.instance.unschedule(callback.bind(this));
|
|
28
|
+
}
|
|
29
|
+
unscheduleAllCallbacks() {
|
|
30
|
+
this.node.instance.unscheduleAllCallbacks();
|
|
31
|
+
}
|
|
32
|
+
scheduleOnce(callback, delay, key) {
|
|
33
|
+
this.node.instance.scheduleOnce(callback, delay, key);
|
|
34
|
+
}
|
|
35
|
+
getComponentsInChildren(component) {
|
|
36
|
+
return this.node.getComponentsInChildren(component);
|
|
37
|
+
}
|
|
38
|
+
getComponentInChildren(component) {
|
|
39
|
+
return this.node.getComponentInChildren(component);
|
|
40
|
+
}
|
|
41
|
+
isEqual(other) {
|
|
42
|
+
return this.node.entity.id === other.node.entity.id;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
private _group;
|
|
12
|
+
private _active;
|
|
13
|
+
constructor(instance: C, entity: Entity);
|
|
14
|
+
get uuid(): number;
|
|
15
|
+
get position(): Readonly<Vec2>;
|
|
16
|
+
set position(val: Vec2);
|
|
17
|
+
set xy(val: [number, number]);
|
|
18
|
+
get posX(): number;
|
|
19
|
+
set posX(val: number);
|
|
20
|
+
get posY(): number;
|
|
21
|
+
set posY(val: number);
|
|
22
|
+
get scale(): number;
|
|
23
|
+
set scale(val: number);
|
|
24
|
+
get scaleX(): number;
|
|
25
|
+
set scaleX(val: number);
|
|
26
|
+
get scaleY(): number;
|
|
27
|
+
set scaleY(val: number);
|
|
28
|
+
get anchorX(): number;
|
|
29
|
+
set anchorX(val: number);
|
|
30
|
+
get anchorY(): number;
|
|
31
|
+
set anchorY(val: number);
|
|
32
|
+
/**
|
|
33
|
+
* Returns the angle of the node in degrees. 0 is the default rotation angle. Positive values rotate node clockwise.
|
|
34
|
+
* @function
|
|
35
|
+
* @return {Number} The rotation of the node in degrees.
|
|
36
|
+
*/
|
|
37
|
+
get rotation(): number;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* Sets the X angle of the node in degrees which performs a horizontal rotational skew.
|
|
41
|
+
* (support only in WebGL rendering mode)
|
|
42
|
+
* 0 is the default rotation angle.
|
|
43
|
+
* Positive values rotate node clockwise, and negative values for anti-clockwise.
|
|
44
|
+
*
|
|
45
|
+
* @param {Number} degrees The X rotation in degrees which performs a horizontal rotational skew.
|
|
46
|
+
*/
|
|
47
|
+
set rotation(val: number);
|
|
48
|
+
get color(): cc.Color;
|
|
49
|
+
set color(val: cc.Color);
|
|
50
|
+
get opacity(): number;
|
|
51
|
+
set opacity(val: number);
|
|
52
|
+
get active(): boolean;
|
|
53
|
+
set active(val: boolean);
|
|
54
|
+
get group(): string | number;
|
|
55
|
+
set group(val: string | number);
|
|
56
|
+
get width(): number;
|
|
57
|
+
set width(val: number);
|
|
58
|
+
get height(): number;
|
|
59
|
+
set height(val: number);
|
|
60
|
+
get zIndex(): number;
|
|
61
|
+
set zIndex(val: number);
|
|
62
|
+
get childrenCount(): number;
|
|
63
|
+
destroy(): void;
|
|
64
|
+
addComponent<T extends ComponentType>(instance: T): T;
|
|
65
|
+
getComponent<T extends ComponentType>(component: Constructor<T>): T;
|
|
66
|
+
getComponentsInChildren<T extends ComponentType>(component: Constructor<T>): T[];
|
|
67
|
+
getComponentInChildren<T extends ComponentType>(component: Constructor<T>): T;
|
|
68
|
+
hasComponentInChildren<T extends ComponentType>(component: Constructor<T>): boolean;
|
|
69
|
+
getPercent(): number;
|
|
70
|
+
setPercent(val: number): void;
|
|
71
|
+
setTouchEnabled(enabled: boolean): void;
|
|
72
|
+
addTouchEventListener(cb: any): void;
|
|
73
|
+
convertToNodeSpace(point: cc.Point): {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
equals(other: /*elided*/ any): boolean;
|
|
77
|
+
add(value: cc.Point | Vec2): /*elided*/ any;
|
|
78
|
+
addSelf(value: cc.Point | Vec2): /*elided*/ any;
|
|
79
|
+
sub(value: cc.Point | Vec2): /*elided*/ any;
|
|
80
|
+
mul(multiply: number): /*elided*/ any;
|
|
81
|
+
mulSelf(multiply: number): /*elided*/ any;
|
|
82
|
+
mag(): number;
|
|
83
|
+
normalizeSelf(): /*elided*/ any;
|
|
84
|
+
normalize(): /*elided*/ any;
|
|
85
|
+
cross(other: Vec2): number;
|
|
86
|
+
signAngle(other: Vec2): number;
|
|
87
|
+
lengthSqr(): number;
|
|
88
|
+
dot(other: Vec2): number;
|
|
89
|
+
angle(other: Vec2): number;
|
|
90
|
+
distance(other: /*elided*/ any): number;
|
|
91
|
+
};
|
|
92
|
+
convertToNodeSpaceAR(point: cc.Point): {
|
|
93
|
+
x: number;
|
|
94
|
+
y: number;
|
|
95
|
+
equals(other: /*elided*/ any): boolean;
|
|
96
|
+
add(value: cc.Point | Vec2): /*elided*/ any;
|
|
97
|
+
addSelf(value: cc.Point | Vec2): /*elided*/ any;
|
|
98
|
+
sub(value: cc.Point | Vec2): /*elided*/ any;
|
|
99
|
+
mul(multiply: number): /*elided*/ any;
|
|
100
|
+
mulSelf(multiply: number): /*elided*/ any;
|
|
101
|
+
mag(): number;
|
|
102
|
+
normalizeSelf(): /*elided*/ any;
|
|
103
|
+
normalize(): /*elided*/ any;
|
|
104
|
+
cross(other: Vec2): number;
|
|
105
|
+
signAngle(other: Vec2): number;
|
|
106
|
+
lengthSqr(): number;
|
|
107
|
+
dot(other: Vec2): number;
|
|
108
|
+
angle(other: Vec2): number;
|
|
109
|
+
distance(other: /*elided*/ any): number;
|
|
110
|
+
};
|
|
111
|
+
convertToWorldSpaceAR(point: cc.Vec2): {
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
equals(other: /*elided*/ any): boolean;
|
|
115
|
+
add(value: cc.Point | Vec2): /*elided*/ any;
|
|
116
|
+
addSelf(value: cc.Point | Vec2): /*elided*/ any;
|
|
117
|
+
sub(value: cc.Point | Vec2): /*elided*/ any;
|
|
118
|
+
mul(multiply: number): /*elided*/ any;
|
|
119
|
+
mulSelf(multiply: number): /*elided*/ any;
|
|
120
|
+
mag(): number;
|
|
121
|
+
normalizeSelf(): /*elided*/ any;
|
|
122
|
+
normalize(): /*elided*/ any;
|
|
123
|
+
cross(other: Vec2): number;
|
|
124
|
+
signAngle(other: Vec2): number;
|
|
125
|
+
lengthSqr(): number;
|
|
126
|
+
dot(other: Vec2): number;
|
|
127
|
+
angle(other: Vec2): number;
|
|
128
|
+
distance(other: /*elided*/ any): number;
|
|
129
|
+
};
|
|
130
|
+
getPosition(): cc.Point;
|
|
131
|
+
setPosition(x: number | cc.Vec2 | cc.Vec3 | cc.Point, y?: number): void;
|
|
132
|
+
setRotation(deg: number): void;
|
|
133
|
+
getRotation(): number;
|
|
134
|
+
setAnchorPoint(point: number | cc.Point, y?: number): void;
|
|
135
|
+
getAnchorPoint(): cc.Point;
|
|
136
|
+
getBoundingBox(): cc.Rect;
|
|
137
|
+
getContentSize(): cc.Size;
|
|
138
|
+
setContentSize(size: cc.Size | number, height?: number): void;
|
|
139
|
+
setColor(color: cc.Color): void;
|
|
140
|
+
setScale(scaleX: number, scaleY?: number): void;
|
|
141
|
+
runAction(atc: cc.ActionInterval): void;
|
|
142
|
+
stopAllActions(): void;
|
|
143
|
+
pauseAllActionsAndSchedule(): void;
|
|
144
|
+
resumeAllActionsAndSchedule(): void;
|
|
145
|
+
removeFromParent(cleanup?: boolean): void;
|
|
146
|
+
addChild(child: NodeComp, zOrder?: number, tag?: number): any;
|
|
147
|
+
removeAllChildren(cleanup?: any): void;
|
|
148
|
+
getData<T>(key: string): T;
|
|
149
|
+
setData<T extends Integer | Float | string>(key: string, value: T): void;
|
|
150
|
+
removeData(key: string): void;
|
|
151
|
+
resolveComponent(component: EnhancedComponent<object, NodeComp>): void;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=NodeComp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeComp.d.ts","sourceRoot":"","sources":["../../src/gworld/NodeComp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAIhD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtE,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,OAAA,KAAK,IAAI,CAAA;AACjD,qBAAa,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,CAAC,CAAA;IACX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