@cc-component/cc-ex-component 1.6.3 → 1.6.4
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/assets/ex/ExCommon.ts +469 -16
- package/package.json +1 -1
package/assets/ex/ExCommon.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { sp } from "cc";
|
|
2
|
-
import {
|
|
3
|
-
import { UITransform } from "cc";
|
|
4
|
-
import { Tween, Node } from 'cc';
|
|
1
|
+
import { UITransform, Tween, sp, director, Slider, ProgressBar, tween, Sprite, view, v3, Button, Label, Color, EventTouch, TransformBit, UISkew, Component, Widget, TweenSystem, TweenAction, misc, Node, Animation } from "cc";
|
|
2
|
+
import { EDITOR_NOT_IN_PREVIEW, JSB } from "cc/env";
|
|
5
3
|
import { TweenManager } from "./ExTween";
|
|
6
|
-
|
|
7
|
-
import { ProgressBar, tween, Sprite, view, v3, Button, Label, Animation } from "cc";
|
|
8
|
-
import { Color } from "cc";
|
|
9
|
-
import { EventTouch } from "cc";
|
|
4
|
+
|
|
10
5
|
|
|
11
6
|
declare global {
|
|
12
7
|
interface String {
|
|
@@ -69,6 +64,65 @@ declare module 'cc' {
|
|
|
69
64
|
}
|
|
70
65
|
|
|
71
66
|
interface Node {
|
|
67
|
+
/**
|
|
68
|
+
* 通过名称获取节点的子节点
|
|
69
|
+
*/
|
|
70
|
+
getChildsByName(name: string): Node[];
|
|
71
|
+
/**
|
|
72
|
+
* 通过名字在当前节点下任意层级查找节点(广度优先查找)
|
|
73
|
+
*/
|
|
74
|
+
findNode(name: string): Node;
|
|
75
|
+
/**
|
|
76
|
+
* 通过名字在当前节点下任意层级查找节点(广度优先查找)
|
|
77
|
+
*/
|
|
78
|
+
findNodes(name: string): Node[];
|
|
79
|
+
/**
|
|
80
|
+
* 从任意父节点上获取组件
|
|
81
|
+
* @param includeSlef 是否包含自身所在节点 默认为true
|
|
82
|
+
*/
|
|
83
|
+
getComponentInParent<T extends Component>(ctor: (new (...args: any[]) => T), includeSlef?: boolean);
|
|
84
|
+
/**
|
|
85
|
+
* 从任意父节点上获取组件
|
|
86
|
+
* @param includeSlef 是否包含自身所在节点 默认为true
|
|
87
|
+
*/
|
|
88
|
+
getComponentInParent<T extends Component>(className: string, includeSlef?: boolean): T;
|
|
89
|
+
/** 确保组件存在 不存在则添加 */
|
|
90
|
+
ensureComponent<T extends Component>(ctor: new (...args: any[]) => T): T;
|
|
91
|
+
/** 确保组件存在 不存在则添加 */
|
|
92
|
+
ensureComponent<T extends Component>(className: string): T;
|
|
93
|
+
/**
|
|
94
|
+
* 节点尺寸匹配父节点大小(通过widget组件来完成)
|
|
95
|
+
* @param immediately 是否立即生效,只有当你需要在当前帧结束前生效才传true,默认为false
|
|
96
|
+
*/
|
|
97
|
+
matchParent(immediately?: boolean): void;
|
|
98
|
+
/** 获取节点在场景树的路径 */
|
|
99
|
+
getPath(): void;
|
|
100
|
+
/** 根据zIndex的值更新子节点的SiblingIndex */
|
|
101
|
+
regularSiblingIndex(): void;
|
|
102
|
+
/** 2d节点的UITransform组件 */
|
|
103
|
+
get transform(): UITransform;
|
|
104
|
+
/** 模拟2.x中zIndex,刷新层级需要调用父节点的regularSiblingIndex方法 */
|
|
105
|
+
zIndex: number;
|
|
106
|
+
/** 在子节点zIndex值改变时修改父节点此属性为true,表示需要更新子节点的SiblingIndex */
|
|
107
|
+
childrenSiblingIndexDirty: boolean;
|
|
108
|
+
/** 世界坐标X */
|
|
109
|
+
wpX: number;
|
|
110
|
+
/** 世界坐标Y */
|
|
111
|
+
wpY: number;
|
|
112
|
+
/** 世界坐标Z */
|
|
113
|
+
wpZ: number;
|
|
114
|
+
/** 本地坐标X */
|
|
115
|
+
lpX: number;
|
|
116
|
+
/** 本地坐标Y */
|
|
117
|
+
lpY: number;
|
|
118
|
+
/** 本地坐标Z */
|
|
119
|
+
lpZ: number;
|
|
120
|
+
scaleX: number;
|
|
121
|
+
scaleY: number;
|
|
122
|
+
skewX: number;
|
|
123
|
+
skewY: number;
|
|
124
|
+
|
|
125
|
+
//资源路径
|
|
72
126
|
asset_path: string;
|
|
73
127
|
/**暂停所有spine动画 */
|
|
74
128
|
pauseSpines(): void;
|
|
@@ -87,6 +141,71 @@ declare module 'cc' {
|
|
|
87
141
|
original_color: Color;
|
|
88
142
|
/**原始颜色进度--私有 */
|
|
89
143
|
original_pro: number;
|
|
144
|
+
/**
|
|
145
|
+
* 禁用按钮
|
|
146
|
+
* @param enable
|
|
147
|
+
* @param time 禁用后xx秒后恢复,不传一直禁用
|
|
148
|
+
*/
|
|
149
|
+
enable(enable: boolean, time?: number): void;
|
|
150
|
+
}
|
|
151
|
+
interface Component {
|
|
152
|
+
/**
|
|
153
|
+
* 从任意父节点上获取组件
|
|
154
|
+
* @param includeSlef 是否包含自身所在节点 默认为true
|
|
155
|
+
*/
|
|
156
|
+
getComponentInParent<T extends Component>(ctor: (new (...args: any[]) => T) | string, includeSlef?: boolean): T;
|
|
157
|
+
/**
|
|
158
|
+
* 从任意父节点上获取组件
|
|
159
|
+
* @param includeSlef 是否包含自身所在节点 默认为true
|
|
160
|
+
*/
|
|
161
|
+
getComponentInParent<T extends Component>(className: string, includeSlef?: boolean): T;
|
|
162
|
+
/**
|
|
163
|
+
* 确保组件存在 不存在则添加
|
|
164
|
+
*/
|
|
165
|
+
ensureComponent<T extends Component>(ctor: new (...args: any[]) => T): T;
|
|
166
|
+
/**
|
|
167
|
+
* 确保组件存在 不存在则添加
|
|
168
|
+
*/
|
|
169
|
+
ensureComponent<T extends Component>(className: string): T;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface Animation {
|
|
173
|
+
/**
|
|
174
|
+
* 修改动画播放的速度 (注意调用时机,应当在组件onLoad完成后调用)
|
|
175
|
+
* @param speed 速度缩放
|
|
176
|
+
* @param name 动画名字,若未指定则修改所有动画的速度
|
|
177
|
+
*/
|
|
178
|
+
setSpeed(speed: number, name?: string): void;
|
|
179
|
+
/**
|
|
180
|
+
* 动画未播放前,将动画控制的属性处于第一帧状态 (注意调用时机,应当在组件onLoad完成后调用)
|
|
181
|
+
* @param name 动画名字,若未指定则表示默认动画
|
|
182
|
+
*/
|
|
183
|
+
setAtFirstFrame(name?: string): void;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
namespace Tween {
|
|
187
|
+
/**
|
|
188
|
+
* 修改指定tag的所有缓动的速度缩放(已执行start方法的缓动才会生效)
|
|
189
|
+
*/
|
|
190
|
+
function setTimeScaleByTag(tag: number, timeScale: number): void;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface Tween<T> {
|
|
194
|
+
/**
|
|
195
|
+
* 缓动开始后的动作对象
|
|
196
|
+
*/
|
|
197
|
+
get finalAction(): TweenAction;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 立即完成缓动(已经start并且非永久重复的才有效)
|
|
201
|
+
*/
|
|
202
|
+
finish(): void;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* 立即将缓动跳到指定时间(已经start的才有效)
|
|
206
|
+
* @param time [0,duration]
|
|
207
|
+
*/
|
|
208
|
+
setTime(time: number): void;
|
|
90
209
|
}
|
|
91
210
|
|
|
92
211
|
interface UITransform {
|
|
@@ -119,14 +238,6 @@ declare module 'cc' {
|
|
|
119
238
|
/**颜色 */
|
|
120
239
|
fromHEX(hex: string);
|
|
121
240
|
}
|
|
122
|
-
interface Node {
|
|
123
|
-
/**
|
|
124
|
-
* 禁用按钮
|
|
125
|
-
* @param enable
|
|
126
|
-
* @param time 禁用后xx秒后恢复,不传一直禁用
|
|
127
|
-
*/
|
|
128
|
-
enable(enable: boolean, time?: number): void;
|
|
129
|
-
}
|
|
130
241
|
interface Label {
|
|
131
242
|
/**动画播放 */
|
|
132
243
|
play(param: {
|
|
@@ -642,6 +753,348 @@ Button.prototype["_onTouchEnded"] = function (event: EventTouch) {
|
|
|
642
753
|
return originalOnTouchEnded.call(this, event);
|
|
643
754
|
};
|
|
644
755
|
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
if (!EDITOR_NOT_IN_PREVIEW) {//非编辑器模式才生效
|
|
760
|
+
|
|
761
|
+
Object.defineProperty(Node.prototype, "transform", {
|
|
762
|
+
get: function () {
|
|
763
|
+
let self: Node = this;
|
|
764
|
+
let transform = self['_transform'];
|
|
765
|
+
if (!transform) {
|
|
766
|
+
transform = self.getComponent(UITransform);
|
|
767
|
+
self['_transform'] = transform;
|
|
768
|
+
}
|
|
769
|
+
return transform;
|
|
770
|
+
}
|
|
771
|
+
})
|
|
772
|
+
|
|
773
|
+
Object.defineProperty(Node.prototype, "zIndex", {
|
|
774
|
+
get() {
|
|
775
|
+
return this._zIndex || 0;
|
|
776
|
+
},
|
|
777
|
+
set(val: number) {
|
|
778
|
+
let zIndex = this._zIndex;//这不给默认值 避免赋予值等于默认值时不生效
|
|
779
|
+
if (val == zIndex) return;
|
|
780
|
+
this._zIndex = val;
|
|
781
|
+
let self: Node = this;
|
|
782
|
+
if (self.parent?.isValid) {
|
|
783
|
+
self.parent.childrenSiblingIndexDirty = true;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
})
|
|
787
|
+
|
|
788
|
+
Object.defineProperty(Node.prototype, "wpX", {
|
|
789
|
+
get() {
|
|
790
|
+
let self: Node = this;
|
|
791
|
+
return self.worldPosition.x;
|
|
792
|
+
},
|
|
793
|
+
set(val: number) {
|
|
794
|
+
let self: Node = this;
|
|
795
|
+
let worldPosition = self.worldPosition;
|
|
796
|
+
self.setWorldPosition(val, worldPosition.y, worldPosition.z);
|
|
797
|
+
}
|
|
798
|
+
})
|
|
799
|
+
|
|
800
|
+
Object.defineProperty(Node.prototype, "wpY", {
|
|
801
|
+
get() {
|
|
802
|
+
let self: Node = this;
|
|
803
|
+
return self.worldPosition.y;
|
|
804
|
+
},
|
|
805
|
+
set(val: number) {
|
|
806
|
+
let self: Node = this;
|
|
807
|
+
let worldPosition = self.worldPosition;
|
|
808
|
+
self.setWorldPosition(worldPosition.x, val, worldPosition.z);
|
|
809
|
+
}
|
|
810
|
+
})
|
|
811
|
+
|
|
812
|
+
Object.defineProperty(Node.prototype, "wpZ", {
|
|
813
|
+
get() {
|
|
814
|
+
let self: Node = this;
|
|
815
|
+
return self.worldPosition.z;
|
|
816
|
+
},
|
|
817
|
+
set(val: number) {
|
|
818
|
+
let self: Node = this;
|
|
819
|
+
let worldPosition = self.worldPosition;
|
|
820
|
+
self.setWorldPosition(worldPosition.x, worldPosition.y, val);
|
|
821
|
+
}
|
|
822
|
+
})
|
|
823
|
+
|
|
824
|
+
Object.defineProperty(Node.prototype, "lpX", {
|
|
825
|
+
get() {
|
|
826
|
+
let self: Node = this;
|
|
827
|
+
return self.position.x;
|
|
828
|
+
},
|
|
829
|
+
set(val: number) {
|
|
830
|
+
let self: Node = this;
|
|
831
|
+
let position = self.position;
|
|
832
|
+
self.setPosition(val, position.y, position.z);
|
|
833
|
+
}
|
|
834
|
+
})
|
|
835
|
+
|
|
836
|
+
Object.defineProperty(Node.prototype, "lpY", {
|
|
837
|
+
get() {
|
|
838
|
+
let self: Node = this;
|
|
839
|
+
return self.position.y;
|
|
840
|
+
},
|
|
841
|
+
set(val: number) {
|
|
842
|
+
let self: Node = this;
|
|
843
|
+
let position = self.position;
|
|
844
|
+
self.setPosition(position.x, val, position.z);
|
|
845
|
+
}
|
|
846
|
+
})
|
|
847
|
+
|
|
848
|
+
Object.defineProperty(Node.prototype, "lpZ", {
|
|
849
|
+
get() {
|
|
850
|
+
let self: Node = this;
|
|
851
|
+
return self.position.z;
|
|
852
|
+
},
|
|
853
|
+
set(val: number) {
|
|
854
|
+
let self: Node = this;
|
|
855
|
+
let position = self.position;
|
|
856
|
+
self.setPosition(position.x, position.y, val);
|
|
857
|
+
}
|
|
858
|
+
})
|
|
859
|
+
|
|
860
|
+
Object.defineProperty(Node.prototype, 'scaleX', {
|
|
861
|
+
get() { return this._lscale.x; },
|
|
862
|
+
set(val) {
|
|
863
|
+
if (JSB) {
|
|
864
|
+
this.setScale(val, this._lscale.y, this._lscale.z);
|
|
865
|
+
} else {
|
|
866
|
+
this._lscale.x = val;
|
|
867
|
+
this.invalidateChildren(TransformBit.SCALE);
|
|
868
|
+
}
|
|
869
|
+
},
|
|
870
|
+
});
|
|
871
|
+
|
|
872
|
+
Object.defineProperty(Node.prototype, 'scaleY', {
|
|
873
|
+
get() { return this._lscale.y; },
|
|
874
|
+
set(val) {
|
|
875
|
+
if (JSB) {
|
|
876
|
+
this.setScale(this._lscale.x, val, this._lscale.z);
|
|
877
|
+
} else {
|
|
878
|
+
this._lscale.y = val;
|
|
879
|
+
this.invalidateChildren(TransformBit.SCALE);
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
})
|
|
883
|
+
|
|
884
|
+
Object.defineProperty(Node.prototype, 'skewX', {
|
|
885
|
+
get: function (): number { return this.getComponent(UISkew)?._skew.x ?? 0; },
|
|
886
|
+
set: JSB ? function (val) {
|
|
887
|
+
let us = this.getComponent(UISkew) ?? this.addComponent(UISkew);
|
|
888
|
+
this._setSkewX(us._skew.x = val);
|
|
889
|
+
us._updateNodeTransformFlags();
|
|
890
|
+
} : function (val) {
|
|
891
|
+
let us = this.getComponent(UISkew) ?? this.addComponent(UISkew);
|
|
892
|
+
us._skew.x = val;
|
|
893
|
+
us._updateNodeTransformFlags();
|
|
894
|
+
},
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
Object.defineProperty(Node.prototype, 'skewY', {
|
|
898
|
+
get: function (): number { return this.getComponent(UISkew)?._skew.y ?? 0; },
|
|
899
|
+
set: JSB ? function (val) {
|
|
900
|
+
let us = this.getComponent(UISkew) ?? this.addComponent(UISkew);
|
|
901
|
+
this._setSkewY(us._skew.y = val);
|
|
902
|
+
us._updateNodeTransformFlags();
|
|
903
|
+
} : function (val) {
|
|
904
|
+
let us = this.getComponent(UISkew) ?? this.addComponent(UISkew);
|
|
905
|
+
us._skew.y = val;
|
|
906
|
+
us._updateNodeTransformFlags();
|
|
907
|
+
},
|
|
908
|
+
});
|
|
909
|
+
|
|
910
|
+
Node.prototype.getChildsByName = function (name: string) {
|
|
911
|
+
let self: Node = this;
|
|
912
|
+
let result: Node[] = [];
|
|
913
|
+
for (const child of self.children) {
|
|
914
|
+
if (child.name == name) result.push(child);
|
|
915
|
+
}
|
|
916
|
+
return result;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
Node.prototype.findNode = function (name: string) {
|
|
920
|
+
let self: Node = this;
|
|
921
|
+
let list: Node[] = self.children;
|
|
922
|
+
let list2: Node[];
|
|
923
|
+
|
|
924
|
+
while (list.length > 0) {
|
|
925
|
+
list2 = [];
|
|
926
|
+
for (const child of list) {
|
|
927
|
+
if (child.name == name) {
|
|
928
|
+
return child;
|
|
929
|
+
} else if (child.children.length > 0) {
|
|
930
|
+
list2.push(...child.children);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
list = list2;
|
|
934
|
+
}
|
|
935
|
+
return undefined;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
Node.prototype.findNodes = function (name: string) {
|
|
939
|
+
let self: Node = this;
|
|
940
|
+
let result: Node[] = [];
|
|
941
|
+
let list: Node[] = self.children;
|
|
942
|
+
let list2: Node[];
|
|
943
|
+
|
|
944
|
+
while (list.length > 0) {
|
|
945
|
+
list2 = [];
|
|
946
|
+
for (const child of list) {
|
|
947
|
+
if (child.name == name) {
|
|
948
|
+
result.push(child);
|
|
949
|
+
}
|
|
950
|
+
if (child.children.length > 0) {
|
|
951
|
+
list2.push(...child.children);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
list = list2;
|
|
955
|
+
}
|
|
956
|
+
return result;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
Node.prototype.getComponentInParent = function <T extends Component>(ctorOrClassName: (new (...args: any[]) => T) | string, includeSlef = true) {
|
|
961
|
+
let self: Node = this;
|
|
962
|
+
let node = includeSlef ? self : self.parent;
|
|
963
|
+
while (node?.isValid) {
|
|
964
|
+
let comp = node.getComponent(ctorOrClassName as any);
|
|
965
|
+
if (comp) return comp;
|
|
966
|
+
node = node.parent;
|
|
967
|
+
}
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
Node.prototype.ensureComponent = function <T extends Component>(ctorOrClassName: (new (...args: any[]) => T) | string): T {
|
|
972
|
+
let self: Node = this;
|
|
973
|
+
let comp = self.getComponent(ctorOrClassName as any);
|
|
974
|
+
if (!comp?.isValid) {
|
|
975
|
+
comp = self.addComponent(ctorOrClassName as any);
|
|
976
|
+
}
|
|
977
|
+
return comp as T;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
Node.prototype.matchParent = function (immediately?: boolean) {
|
|
981
|
+
let self: Node = this;
|
|
982
|
+
if (!self.getComponent(UITransform)) {
|
|
983
|
+
console.warn("仅2D节点可以使用此方法");
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
let widget = self.ensureComponent(Widget);
|
|
987
|
+
widget.isAlignTop = true;
|
|
988
|
+
widget.top = 0;
|
|
989
|
+
widget.isAlignBottom = true;
|
|
990
|
+
widget.bottom = 0;
|
|
991
|
+
widget.isAlignLeft = true;
|
|
992
|
+
widget.left = 0;
|
|
993
|
+
widget.isAlignRight = true;
|
|
994
|
+
widget.right = 0;
|
|
995
|
+
if (immediately) widget.updateAlignment();
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
Node.prototype.getPath = function () {
|
|
999
|
+
let arr: string[] = [];
|
|
1000
|
+
let n: Node = this;
|
|
1001
|
+
while (n) {
|
|
1002
|
+
arr.push(n.name);
|
|
1003
|
+
n = n.parent;
|
|
1004
|
+
}
|
|
1005
|
+
return arr.reverse().join("/");
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
Node.prototype.regularSiblingIndex = function () {
|
|
1009
|
+
let self: Node = this;
|
|
1010
|
+
if (!self.childrenSiblingIndexDirty) return;
|
|
1011
|
+
(this._children as Node[]).sort((a, b) => a.zIndex - b.zIndex);
|
|
1012
|
+
this._updateSiblingIndex();
|
|
1013
|
+
self.childrenSiblingIndexDirty = false;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
Component.prototype.getComponentInParent = function <T extends Component>(ctorOrClassName: (new (...args: any[]) => T) | string, includeSlef = true) {
|
|
1017
|
+
return this.node.getComponentInParent(ctorOrClassName as any, includeSlef);
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
Component.prototype.ensureComponent = function <T extends Component>(ctorOrClassName: (new (...args: any[]) => T) | string) {
|
|
1021
|
+
return this.node.ensureComponent(ctorOrClassName as any);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
Animation.prototype.setSpeed = function (speed: number, name?: string) {
|
|
1025
|
+
let self: Animation = this;
|
|
1026
|
+
if (name) {
|
|
1027
|
+
let state = self.getState(name);
|
|
1028
|
+
if (state) {
|
|
1029
|
+
state.speed = speed;
|
|
1030
|
+
} else {
|
|
1031
|
+
console.warn(`动画不存在: ${name}`);
|
|
1032
|
+
}
|
|
1033
|
+
} else {
|
|
1034
|
+
for (const clip of self.clips) {
|
|
1035
|
+
let state = self.getState(clip.name);
|
|
1036
|
+
if (state) {
|
|
1037
|
+
state.speed = speed;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
Animation.prototype.setAtFirstFrame = function (name?: string) {
|
|
1044
|
+
let self: Animation = this;
|
|
1045
|
+
name = name || self.defaultClip?.name;
|
|
1046
|
+
if (!name) {
|
|
1047
|
+
console.warn(`未指定动画且默认动画不存在`);
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
let state = self.getState(name);
|
|
1051
|
+
if (state) {
|
|
1052
|
+
state.update(0);
|
|
1053
|
+
} else {
|
|
1054
|
+
console.warn(`动画不存在: ${name}`);
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
Tween.setTimeScaleByTag = function (tag: number, timeScale: number) {
|
|
1060
|
+
const hashTargets: Map<unknown, { actions: any[] }> = TweenSystem.instance.ActionManager['_hashTargets'];
|
|
1061
|
+
hashTargets.forEach((element) => {
|
|
1062
|
+
for (let i = element.actions.length - 1; i >= 0; --i) {
|
|
1063
|
+
const action = element.actions[i];
|
|
1064
|
+
if (action && action.getTag() === tag) {
|
|
1065
|
+
action.setSpeed(timeScale);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
Object.defineProperty(Tween.prototype, "finalAction", {
|
|
1072
|
+
get: function () {
|
|
1073
|
+
return this['_finalAction'];
|
|
1074
|
+
}
|
|
1075
|
+
})
|
|
1076
|
+
|
|
1077
|
+
Tween.prototype.finish = function () {
|
|
1078
|
+
let finalAction: TweenAction = this['_finalAction'];
|
|
1079
|
+
if (finalAction) {
|
|
1080
|
+
if (finalAction['_repeatForever']) return;
|
|
1081
|
+
this.setTime(finalAction.getDuration());
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
Tween.prototype.setTime = function (time: number) {
|
|
1086
|
+
let finalAction: TweenAction = this['_finalAction'];
|
|
1087
|
+
if (finalAction) {
|
|
1088
|
+
let dur = finalAction.getDuration();
|
|
1089
|
+
time = misc.clampf(time, 0, dur);
|
|
1090
|
+
finalAction['_elapsed'] = time;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
|
|
645
1098
|
export { };
|
|
646
1099
|
|
|
647
1100
|
|