drgame-cc 1.0.45 → 1.0.46

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 (121) hide show
  1. package/drres/focus/focus_1/gesture.atlas +34 -0
  2. package/drres/focus/focus_1/gesture.atlas.meta +6 -0
  3. package/drres/focus/focus_1/gesture.json +1 -0
  4. package/drres/focus/focus_1/gesture.json.meta +10 -0
  5. package/drres/focus/focus_1/gesture.png +0 -0
  6. package/drres/{icons/pointer-yellow-60.png.meta → focus/focus_1/gesture.png.meta} +14 -14
  7. package/drres/focus/focus_1.meta +13 -0
  8. package/drres/focus/focus_2/gesture.atlas +41 -0
  9. package/drres/focus/focus_2/gesture.atlas.meta +6 -0
  10. package/drres/focus/focus_2/gesture.json +1 -0
  11. package/drres/focus/focus_2/gesture.json.meta +10 -0
  12. package/drres/focus/focus_2/gesture.png +0 -0
  13. package/drres/{icons/pointer-blue-60.png.meta → focus/focus_2/gesture.png.meta} +13 -13
  14. package/drres/focus/focus_2.meta +13 -0
  15. package/drres/focus/focus_3/gesture.atlas +34 -0
  16. package/drres/focus/focus_3/gesture.atlas.meta +6 -0
  17. package/drres/focus/focus_3/gesture.json +1 -0
  18. package/drres/focus/focus_3/gesture.json.meta +10 -0
  19. package/drres/focus/focus_3/gesture.png +0 -0
  20. package/drres/{icons/pointer-pink-60.png.meta → focus/focus_3/gesture.png.meta} +12 -12
  21. package/drres/focus/focus_3.meta +13 -0
  22. package/drres/focus/focus_4/gesture.atlas +20 -0
  23. package/drres/focus/focus_4/gesture.atlas.meta +6 -0
  24. package/drres/focus/focus_4/gesture.json +1 -0
  25. package/drres/focus/focus_4/gesture.json.meta +10 -0
  26. package/drres/focus/focus_4/gesture.png +0 -0
  27. package/drres/focus/focus_4/gesture.png.meta +38 -0
  28. package/drres/focus/focus_4.meta +13 -0
  29. package/drres/focus.meta +13 -0
  30. package/drres/prefab/ExitWin.prefab +2 -2
  31. package/drres/prefab/Toast.prefab +378 -378
  32. package/drscript/{ad/AdManager.ts.meta → BtnExtra.ts.meta} +1 -1
  33. package/drscript/Define.ts +17 -2
  34. package/drscript/{ad/AdSlot.ts.meta → Define.ts.meta} +1 -1
  35. package/drscript/{ad/AggregateAdProvider.ts.meta → ExitWin.ts.meta} +1 -1
  36. package/drscript/GameAnalytics.ts +37 -118
  37. package/drscript/{ad/IAdProvider.ts.meta → GameAnalytics.ts.meta} +1 -1
  38. package/drscript/HelperWin.ts.meta +10 -0
  39. package/drscript/Info.ts.meta +10 -0
  40. package/drscript/InternalUitl.ts.meta +10 -0
  41. package/drscript/KeyAdapter.ts +133 -0
  42. package/drscript/KeyAdapter.ts.meta +10 -0
  43. package/drscript/Loader.ts.meta +10 -0
  44. package/drscript/PlatformAdapter.ts +178 -192
  45. package/drscript/PlatformAdapter.ts.meta +10 -0
  46. package/drscript/README.md +91 -805
  47. package/drscript/README.md.meta +6 -0
  48. package/drscript/UIAdapter.ts +324 -0
  49. package/drscript/UIAdapter.ts.meta +10 -0
  50. package/drscript/WebBridge.ts +1 -1
  51. package/drscript/WebBridge.ts.meta +10 -0
  52. package/drscript/ad-sdk/reporters/superset-lewo.js +6 -0
  53. package/drscript/ad-sdk/types/enums.d.ts +1 -0
  54. package/drscript/ad-sdk.meta +13 -0
  55. package/drscript/ad.meta +13 -0
  56. package/drscript/component/AlertTip.ts +25 -0
  57. package/drscript/component/AlertTip.ts.meta +10 -0
  58. package/drscript/component/BtnExtra.ts +17 -0
  59. package/drscript/component/BtnExtra.ts.meta +10 -0
  60. package/drscript/{ExitWin.ts → component/ExitWin.ts} +6 -8
  61. package/drscript/component/ExitWin.ts.meta +10 -0
  62. package/drscript/{HelperWin.ts → component/HelperWin.ts} +5 -19
  63. package/drscript/component/HelperWin.ts.meta +10 -0
  64. package/drscript/component.meta +13 -0
  65. package/drscript/config.meta +13 -0
  66. package/drscript/core.meta +13 -0
  67. package/drscript/focus/FocusItem.ts +1 -19
  68. package/drscript/focus/FocusManager.ts +132 -170
  69. package/drscript/focus/FocusVisualLayer.ts +74 -163
  70. package/drscript/focus.meta +13 -0
  71. package/drscript/input/KeyboardMove.ts +40 -11
  72. package/drscript/input/KeyboardMove.ts.meta +10 -0
  73. package/drscript/input.meta +13 -0
  74. package/drscript/interface.meta +13 -0
  75. package/drscript/pinyin.meta +13 -0
  76. package/drscript/toast.meta +13 -0
  77. package/drscript/virtualgamepad.meta +13 -0
  78. package/package.json +1 -1
  79. package/drres/config/default.json +0 -108
  80. package/drres/config/default.json.meta +0 -6
  81. package/drres/icons/pointer-blue-60.png +0 -0
  82. package/drres/icons/pointer-pink-60.png +0 -0
  83. package/drres/icons/pointer-white-60.png +0 -0
  84. package/drres/icons/pointer-yellow-60.png +0 -0
  85. package/drscript/Info.ts +0 -78
  86. package/drscript/InternalUitl.ts +0 -65
  87. package/drscript/ad/AdManager.ts +0 -174
  88. package/drscript/ad/AdSlot.ts +0 -44
  89. package/drscript/ad/AggregateAdProvider.ts +0 -149
  90. package/drscript/ad/IAdProvider.ts +0 -39
  91. package/drscript/ad/MockAdProvider.ts +0 -36
  92. package/drscript/ad/MockAdProvider.ts.meta +0 -10
  93. package/drscript/ad/SelfAdProvider.ts +0 -41
  94. package/drscript/ad/SelfAdProvider.ts.meta +0 -10
  95. package/drscript/config/TvUiConfig.ts +0 -155
  96. package/drscript/config/TvUiConfig.ts.meta +0 -10
  97. package/drscript/config/TvUiConfigManager.ts +0 -133
  98. package/drscript/config/TvUiConfigManager.ts.meta +0 -10
  99. package/drscript/core/BackManager.ts +0 -38
  100. package/drscript/core/BackManager.ts.meta +0 -10
  101. package/drscript/core/NativeBridge.ts +0 -137
  102. package/drscript/core/NativeBridge.ts.meta +0 -10
  103. package/drscript/core/TvUi.ts +0 -69
  104. package/drscript/core/TvUi.ts.meta +0 -10
  105. package/drscript/core/TvUiRoot.ts +0 -137
  106. package/drscript/core/TvUiRoot.ts.meta +0 -10
  107. package/drscript/icon/IconConfig.ts +0 -7
  108. package/drscript/icon/IconConfig.ts.meta +0 -10
  109. package/drscript/icon/IconManager.ts +0 -97
  110. package/drscript/icon/IconManager.ts.meta +0 -10
  111. package/drscript/input/KeyCodeAdapter.ts +0 -23
  112. package/drscript/input/RemoteInputManager.ts +0 -105
  113. package/drscript/interface/ILobbyBridge.ts +0 -5
  114. package/drscript/toast/ToastComponent.ts +0 -35
  115. package/drscript/toast/ToastComponent.ts.meta +0 -10
  116. package/drscript/toast/ToastManager.ts +0 -66
  117. package/drscript/toast/ToastManager.ts.meta +0 -10
  118. package/drscript/toast/TvExitConfirmDialog.ts +0 -334
  119. package/drscript/toast/TvExitConfirmDialog.ts.meta +0 -10
  120. package/drscript/toast/UIFunctions.ts +0 -150
  121. package/drscript/toast/UIFunctions.ts.meta +0 -10
@@ -1,66 +0,0 @@
1
- import ToastComponent from "./ToastComponent";
2
-
3
- const { ccclass, property } = cc._decorator;
4
-
5
- @ccclass
6
- export default class ToastManager {
7
- public static readonly Inst = new ToastManager();
8
-
9
- private toastPool: cc.NodePool;
10
- private prefab: cc.Prefab;
11
-
12
- async init() {
13
- this.toastPool = new cc.NodePool();
14
- this.prefab = await this.loadSpriteFrame('drres/prefab/Toast');
15
- }
16
- // 封装为 Promise
17
- private loadSpriteFrame(path: string): Promise<cc.Prefab> {
18
- return new Promise((resolve, reject) => {
19
- cc.loader.loadRes(path, cc.Prefab, (err, spriteFrame) => {
20
- if (err) {
21
- reject(err);
22
- } else {
23
- resolve(spriteFrame as cc.Prefab);
24
- }
25
- });
26
- });
27
- }
28
- onDestroy() {
29
- this.toastPool.clear();
30
- }
31
-
32
- make(text, dur = 1500) {
33
- //show toast
34
- let node = this.toastPool.get();
35
- let toastComp: any = null;
36
- if (node == null) {
37
- node = cc.instantiate(this.prefab);
38
- toastComp = node.getComponent(ToastComponent);
39
- if (toastComp == null) {
40
- console.warn("Toast.make : Toast Prefab must contains ToastComponent")
41
- }
42
- // ToastManager.toastPool.put(node);
43
- // node = ToastManager.toastPool.get();
44
- } else {
45
- toastComp = node.getComponent(ToastComponent);
46
- }
47
- if (node.parent == null)
48
- cc.director.getScene().addChild(node, cc.macro.MAX_ZINDEX);
49
- node.setPosition(cc.v2(cc.winSize.width / 2, cc.winSize.height / 2));
50
-
51
- this.show(toastComp, text, dur)
52
- return toastComp;
53
- }
54
-
55
- private show(toastComp: ToastComponent, text, dur) {
56
- toastComp.show(text)
57
- setTimeout(_ => {
58
- toastComp.hide(_ => {
59
- this.toastPool.put(toastComp.node)
60
- console.log("Toast.hide toastpool size:", this.toastPool.size())
61
- });
62
- }, dur)
63
- }
64
-
65
- // update (dt) {}
66
- }
@@ -1,10 +0,0 @@
1
- {
2
- "ver": "1.1.0",
3
- "uuid": "79b137e4-1e9b-4600-934c-62ef306b5e46",
4
- "importer": "typescript",
5
- "isPlugin": false,
6
- "loadPluginInWeb": true,
7
- "loadPluginInNative": true,
8
- "loadPluginInEditor": false,
9
- "subMetas": {}
10
- }
@@ -1,334 +0,0 @@
1
- import TvUi from "../core/TvUi";
2
-
3
-
4
- const { ccclass } = cc._decorator;
5
-
6
- interface TvExitSprites {
7
- title: cc.SpriteFrame;
8
- frame: cc.SpriteFrame;
9
- cancelNormal: cc.SpriteFrame;
10
- cancelSelected: cc.SpriteFrame;
11
- confirmNormal: cc.SpriteFrame;
12
- confirmSelected: cc.SpriteFrame;
13
- }
14
-
15
- interface TvExitButtonState {
16
- node: cc.Node;
17
- sprite: cc.Sprite;
18
- normal: cc.SpriteFrame;
19
- selected: cc.SpriteFrame;
20
- hovered: boolean;
21
- pressed: boolean;
22
- focused: boolean;
23
- }
24
-
25
- @ccclass
26
- export default class TvExitConfirmDialog extends cc.Component {
27
- private static pendingPromise: Promise<boolean>;
28
- private static currentDialog: TvExitConfirmDialog;
29
- private static spriteCache: TvExitSprites;
30
-
31
- private resolver: any = null;
32
- private closed: boolean = false;
33
- private tvBackHandler: any;
34
- private tvFocusScopeId: string = "modal:drres/tv_exit_confirm";
35
- private cancelState: any;
36
- private confirmState: any;
37
- private onExitCallback: any;
38
-
39
- static show(onExitCallback: (confirmed: boolean) => void = null) {
40
- // if (TvExitConfirmDialog.pendingPromise) {
41
- // return TvExitConfirmDialog.pendingPromise;
42
- // }
43
-
44
- let resolveDialog: any;
45
- let promise = new Promise<boolean>((resolve) => {
46
- resolveDialog = resolve;
47
- });
48
- TvExitConfirmDialog.pendingPromise = promise;
49
-
50
- let parent = TvExitConfirmDialog.getDialogParent();
51
- if (!parent) {
52
- // TvExitConfirmDialog.pendingPromise = null;
53
- resolveDialog(false);
54
- return promise;
55
- }
56
-
57
- let node = new cc.Node("TvExitConfirmDialog");
58
- let size = TvExitConfirmDialog.getParentSize(parent);
59
- node.setContentSize(size);
60
- node.setPosition(0, 0);
61
- node.zIndex = 5000;
62
- node.addComponent(cc.BlockInputEvents);
63
- parent.addChild(node, 5000);
64
-
65
- let dialog = node.addComponent(TvExitConfirmDialog);
66
- TvExitConfirmDialog.currentDialog = dialog;
67
- dialog.open(resolveDialog);
68
- dialog.onExitCallback = onExitCallback;
69
- return promise;
70
- }
71
-
72
- private static getDialogParent(): cc.Node {
73
- let canvas = cc.find("Canvas");
74
- if (canvas) return canvas;
75
- let scene = cc.director.getScene();
76
- return scene as any;
77
- }
78
-
79
- private static getParentSize(parent: cc.Node): cc.Size {
80
- let width = parent && parent.width ? parent.width : cc.winSize.width;
81
- let height = parent && parent.height ? parent.height : cc.winSize.height;
82
- return cc.size(width || 1920, height || 1080);
83
- }
84
-
85
- private static clearPending(dialog: TvExitConfirmDialog) {
86
- if (TvExitConfirmDialog.currentDialog == dialog) {
87
- // TvExitConfirmDialog.currentDialog = null;
88
- // TvExitConfirmDialog.pendingPromise = null;
89
- }
90
- }
91
-
92
- private open(resolveDialog: (confirmed: boolean) => void) {
93
- this.resolver = resolveDialog;
94
- this.loadSprites((sprites: TvExitSprites) => {
95
- if (this.closed || !this.node || !this.node.isValid) return;
96
- this.buildView(sprites);
97
- this.registerTvControls();
98
- }, () => {
99
- this.close(false);
100
- });
101
- }
102
-
103
- private loadSprites(onComplete: (sprites: TvExitSprites) => void, onError: () => void) {
104
- if (TvExitConfirmDialog.spriteCache) {
105
- onComplete(TvExitConfirmDialog.spriteCache);
106
- return;
107
- }
108
-
109
- let result: any = {};
110
- let paths = [
111
- { key: "title", path: "drres/tv_exit/退出游戏" },
112
- { key: "frame", path: "drres/tv_exit/框" },
113
- { key: "cancelNormal", path: "drres/tv_exit/取消按钮_普通" },
114
- { key: "cancelSelected", path: "drres/tv_exit/取消按钮_选中" },
115
- { key: "confirmNormal", path: "drres/tv_exit/确认按钮_普通" },
116
- { key: "confirmSelected", path: "drres/tv_exit/确认按钮_选中" }
117
- ];
118
- let waiting = paths.length;
119
- let failed = false;
120
-
121
- for (let i = 0; i < paths.length; i++) {
122
- let item = paths[i];
123
- cc.loader.loadRes(item.path, cc.SpriteFrame, (error, frame: cc.SpriteFrame) => {
124
- if (failed) return;
125
- if (error || !frame) {
126
- failed = true;
127
- console.warn("[TvExitConfirmDialog] load sprite failed:", item.path, error);
128
- onError();
129
- return;
130
- }
131
-
132
- result[item.key] = frame;
133
- waiting--;
134
- if (waiting <= 0) {
135
- TvExitConfirmDialog.spriteCache = result as TvExitSprites;
136
- onComplete(TvExitConfirmDialog.spriteCache);
137
- }
138
- });
139
- }
140
- }
141
-
142
- private buildView(sprites: TvExitSprites) {
143
- let size = TvExitConfirmDialog.getParentSize(this.node.parent);
144
- this.node.setContentSize(size);
145
- this.createMask(size);
146
-
147
- let frameY = 30;
148
- let titleY = frameY + 100;
149
- let buttonY = -150;
150
- let buttonOffsetX = 195;
151
- let frameNode = this.createSpriteNode("frame", sprites.frame, 959, 552);
152
- this.node.addChild(frameNode, 1);
153
- frameNode.setPosition(0, frameY);
154
-
155
- // let titleNode = this.createSpriteNode("title", sprites.title, 395, 78);
156
- // this.node.addChild(titleNode, 2);
157
- // titleNode.setPosition(0, titleY);
158
-
159
- this.confirmState = this.createDialogButton("confirm", sprites.confirmNormal, sprites.confirmSelected, -buttonOffsetX, buttonY, true);
160
- this.cancelState = this.createDialogButton("cancel", sprites.cancelNormal, sprites.cancelSelected, buttonOffsetX, buttonY, false);
161
-
162
- frameNode.addChild(this.confirmState.node, 2);
163
- frameNode.addChild(this.cancelState.node, 2);
164
- }
165
-
166
- private createMask(size: cc.Size) {
167
- let mask = new cc.Node("mask");
168
- mask.setContentSize(size);
169
- mask.addComponent(cc.BlockInputEvents);
170
- let graphics = mask.addComponent(cc.Graphics);
171
- graphics.fillColor = cc.color(0, 0, 0, 165);
172
- graphics.rect(-size.width * 0.5, -size.height * 0.5, size.width, size.height);
173
- graphics.fill();
174
- this.node.addChild(mask, 0);
175
- }
176
-
177
- private createSpriteNode(name: string, frame: cc.SpriteFrame, width: number, height: number): cc.Node {
178
- let node = new cc.Node(name);
179
- node.setContentSize(width, height);
180
- let sprite = node.addComponent(cc.Sprite);
181
- sprite.sizeMode = cc.Sprite.SizeMode.CUSTOM;
182
- sprite.spriteFrame = frame;
183
- return node;
184
- }
185
-
186
- private createDialogButton(name: string, normal: cc.SpriteFrame, selected: cc.SpriteFrame, x: number, y: number, result: boolean): TvExitButtonState {
187
- let node = this.createSpriteNode(name, normal, 208, 96);
188
- node.setPosition(x, y);
189
-
190
- let button = node.addComponent(cc.Button);
191
- button.transition = cc.Button.Transition.NONE;
192
-
193
- let state: TvExitButtonState = {
194
- node: node,
195
- sprite: node.getComponent(cc.Sprite),
196
- normal: normal,
197
- selected: selected,
198
- hovered: false,
199
- pressed: false,
200
- focused: false
201
- };
202
-
203
- node.on(cc.Node.EventType.MOUSE_ENTER, () => {
204
- state.hovered = true;
205
- this.refreshButtonState(state);
206
- }, this);
207
- node.on(cc.Node.EventType.MOUSE_LEAVE, () => {
208
- state.hovered = false;
209
- this.refreshButtonState(state);
210
- }, this);
211
- node.on(cc.Node.EventType.TOUCH_START, () => {
212
- state.pressed = true;
213
- this.refreshButtonState(state);
214
- }, this);
215
- node.on(cc.Node.EventType.TOUCH_CANCEL, () => {
216
- state.pressed = false;
217
- this.refreshButtonState(state);
218
- }, this);
219
- node.on(cc.Node.EventType.TOUCH_END, () => {
220
- state.pressed = false;
221
- this.refreshButtonState(state);
222
- this.close(result);
223
- }, this);
224
-
225
- return state;
226
- }
227
-
228
- private refreshButtonState(state: TvExitButtonState) {
229
- if (!state || !state.sprite) return;
230
- let selected = state.focused || state.hovered || state.pressed;
231
- state.sprite.spriteFrame = selected ? state.selected : state.normal;
232
- }
233
-
234
- private registerTvControls() {
235
- if (!this.tvBackHandler) {
236
- this.tvBackHandler = () => {
237
- this.close(false);
238
- return true;
239
- };
240
- }
241
-
242
- TvUi.back.push(this.tvBackHandler);
243
- if ((TvUi.focus as any).pushScope) {
244
- (TvUi.focus as any).pushScope(this.tvFocusScopeId, this.node);
245
- }
246
- this.registerFocus(this.confirmState, true);
247
- this.registerFocus(this.cancelState, false);
248
- if (this.cancelState && this.cancelState.node) {
249
- (TvUi.focus as any).focusNode(this.cancelState.node);
250
- }
251
- this.refreshAllButtonStates();
252
- }
253
-
254
- private registerFocus(state: TvExitButtonState, result: boolean) {
255
- if (!state || !state.node) return;
256
- TvUi.focus.register(state.node, {
257
- root: this.node,
258
- focusScale: 1,
259
- onClick: () => {
260
- this.close(result);
261
- },
262
- onFocus: () => {
263
- this.setFocusedState(state);
264
- },
265
- onBlur: () => {
266
- state.focused = false;
267
- this.refreshAllButtonStates();
268
- }
269
- });
270
- }
271
-
272
- private setFocusedState(focusedState: TvExitButtonState) {
273
- if (this.confirmState) this.confirmState.focused = this.confirmState == focusedState;
274
- if (this.cancelState) this.cancelState.focused = this.cancelState == focusedState;
275
- this.refreshAllButtonStates();
276
- }
277
-
278
- private refreshAllButtonStates() {
279
- this.refreshButtonState(this.confirmState);
280
- this.refreshButtonState(this.cancelState);
281
- }
282
-
283
- private unregisterTvControls() {
284
- TvUi.focus.unregisterByRoot(this.node);
285
- if ((TvUi.focus as any).popScope) {
286
- (TvUi.focus as any).popScope(this.tvFocusScopeId);
287
- }
288
- if (this.tvBackHandler) {
289
- TvUi.back.remove(this.tvBackHandler);
290
- this.tvBackHandler = null;
291
- }
292
- }
293
-
294
- private close(confirmed: boolean) {
295
- if (this.closed) return;
296
- this.finish(confirmed);
297
- if (this.node && this.node.isValid) {
298
- this.node.destroy();
299
- }
300
- }
301
-
302
- private finish(confirmed: boolean) {
303
- if (this.closed) return;
304
- this.closed = true;
305
- this.unregisterTvControls();
306
- TvExitConfirmDialog.clearPending(this);
307
- if (this.onExitCallback && confirmed) {
308
- this.onExitCallback(confirmed);
309
- return;
310
- }
311
- let resolveDialog = this.resolver;
312
- this.resolver = null;
313
- // if (resolveDialog) {
314
- // resolveDialog(confirmed);
315
- // }
316
- if (confirmed) {
317
- if (TvUi.api.hasBridge()) {
318
- TvUi.api.onExitGame();
319
- return;
320
- }
321
- if (!TvUi.api.hasBridge() && cc.game && cc.game.end) {
322
- cc.game.end();
323
- }
324
- }
325
- }
326
-
327
- onDestroy() {
328
- if (!this.closed) {
329
- this.finish(false);
330
- return;
331
- }
332
- this.unregisterTvControls();
333
- }
334
- }
@@ -1,10 +0,0 @@
1
- {
2
- "ver": "1.1.0",
3
- "uuid": "6c9f95ac-d028-48f6-8348-78136886589c",
4
- "importer": "typescript",
5
- "isPlugin": false,
6
- "loadPluginInWeb": true,
7
- "loadPluginInNative": true,
8
- "loadPluginInEditor": false,
9
- "subMetas": {}
10
- }
@@ -1,150 +0,0 @@
1
- export default class UIFunctions {
2
-
3
- static getChildrenAnimations(node): cc.Animation[] {
4
- let animations: cc.Animation[] = []
5
- var anim = node.getComponent(cc.Animation)
6
- if (anim)
7
- animations.push(anim)
8
- for (var i = 0; i < node.childrenCount; i++) {
9
- let child = node.children[i];
10
- var anim = child.getComponent(cc.Animation)
11
- if (anim)
12
- animations.push(anim)
13
- }
14
- return animations
15
- }
16
-
17
- static stopAnimations(animations) {
18
- animations.forEach((anim: cc.Animation) => {
19
- anim.stop();
20
- })
21
- }
22
-
23
- static doShowAnimations(animations, finishCallback?: Function, target?) {
24
- let maxDuration = 0;
25
- let maxDurationAnimation: any = null;
26
- animations.forEach((anim: cc.Animation) => {
27
- let clips = anim.getClips()
28
- if (clips.length > 0) {
29
- let clip = clips[0]
30
- let animState = anim.play(clip.name)
31
- animState.wrapMode = cc.WrapMode.Normal
32
- if (clip.duration > maxDuration) {
33
- maxDuration = clip.duration;
34
- maxDurationAnimation = anim;
35
- }
36
- }
37
- })
38
- if (finishCallback) {
39
- let func = function () {
40
- // console.log("finish animations")
41
- if (maxDurationAnimation)
42
- maxDurationAnimation.off("finished", func);
43
- finishCallback.call(target);
44
- }
45
- if (maxDurationAnimation)
46
- maxDurationAnimation.on("finished", func);
47
- else
48
- finishCallback.call(target);
49
-
50
- }
51
- }
52
-
53
- // static getLongestAnimation(animations)
54
- // {
55
- // animations.forEach((anim:cc.Animation)=>{
56
- // let clips = anim.getClips()
57
- // for (clips)
58
-
59
- // //以最长的为准
60
- // }
61
- // }
62
-
63
- //TODO:还未实现
64
- static isAnimationRunning(animations: cc.Animation[]): any {
65
- return false;
66
- }
67
-
68
- static doHideAnimations(animations, finishCallback?: Function, target?) {
69
- let hasHideAnimation = false;
70
- let maxDuration = 0;
71
- let maxDurationAnimation: any = null;
72
- animations.forEach((anim: cc.Animation) => {
73
- let clips = anim.getClips()
74
- if (clips.length == 2) {
75
- let clip = clips[clips.length - 1]
76
- // anim.on("finished",onHideAnimationFinished)
77
- hasHideAnimation = true;
78
- anim.play(clip.name)
79
- if (clip.duration > maxDuration) {
80
- maxDuration = clip.duration;
81
- maxDurationAnimation = anim;
82
- }
83
- } else if (clips.length == 1) {
84
- let clip = clips[0];
85
- // clip.wrapMode = cc.WrapMode.Reverse;
86
- hasHideAnimation = true;
87
- let animState = anim.play(clip.name)
88
- animState.wrapMode = cc.WrapMode.Reverse
89
- if (clip.duration > maxDuration) {
90
- maxDuration = clip.duration;
91
- maxDurationAnimation = anim;
92
- }
93
- }
94
- })
95
- if (maxDurationAnimation && finishCallback) {
96
- let func = function () {
97
- // console.log("finish animations")
98
- maxDurationAnimation.off("finished", func);
99
- finishCallback.call(target);
100
- }
101
- maxDurationAnimation.on("finished", func);
102
- }
103
- return hasHideAnimation;
104
- }
105
-
106
- static getToggleIndex(toggle: cc.Toggle) {
107
- let container = toggle.node.parent;
108
- for (var i = 0; i < container.childrenCount; i++) {
109
- let child = container.children[i]
110
- if (toggle.node == child) {
111
- return i;
112
- }
113
- }
114
- return -1;
115
- }
116
-
117
- static selectToggleIndex(toggleContainer: cc.Node, index) {
118
- if (toggleContainer == null) {
119
- console.warn("[UIFunction.selectToggleIndex] : invalid toggleContainer :")
120
- return;
121
- }
122
- let toggleNode = toggleContainer.children[index]
123
- if (toggleNode) {
124
- let toggle = toggleNode.getComponent(cc.Toggle)
125
- if (toggle) {
126
- console.log("[UIFunction.selectToggleIndex] :" + index)
127
- toggle.check()
128
- }
129
- } else {
130
- console.warn("[UIFunction.selectToggleIndex] :cannot find toggle with index:" + index)
131
- }
132
- }
133
-
134
- // set btn
135
- static setTouchEnabled(node, b) {
136
- // g.foreachNode(node, child => {
137
- // let btn: cc.Button = child.getComponent(cc.Button)
138
- // if (btn) {
139
- // console.log("[UIFunction] " + child.name + " touch : " + b)
140
- // btn.interactable = b;
141
- // }
142
- // })
143
- }
144
-
145
- static setButtonEnabled(btn, b) {
146
- btn.node.opacity = b ? 255 : 155;
147
- btn.interactable = b
148
- }
149
-
150
- }
@@ -1,10 +0,0 @@
1
- {
2
- "ver": "1.1.0",
3
- "uuid": "cdde37c0-adfc-4c88-80c6-6a47cf8f6018",
4
- "importer": "typescript",
5
- "isPlugin": false,
6
- "loadPluginInWeb": true,
7
- "loadPluginInNative": true,
8
- "loadPluginInEditor": false,
9
- "subMetas": {}
10
- }