@cc-component/cc-ex-component 1.3.0 → 1.3.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.
@@ -0,0 +1,80 @@
1
+ import { UIOpacity, tween, Vec3 } from 'cc';
2
+ import { _decorator, Component, Node } from 'cc';
3
+ import { BaseReference } from './BaseReference';
4
+ const { ccclass, property } = _decorator;
5
+
6
+ @ccclass('BaseWindow')
7
+ export class BaseWindow extends BaseReference {
8
+ maskOpacity: UIOpacity;
9
+ root: Node;
10
+ /**关闭事件-当系统级关闭所有打开的界面时。如果关闭界面时需要执行自己的业务逻辑,使用此属性
11
+ * eventName:关闭方法名称
12
+ * param:参数
13
+ */
14
+ closeEvent: { eventName: string, param?: any };
15
+ /**参数*/
16
+ param: any;
17
+ /**关闭参数 */
18
+ paramClose: { is_anim?: boolean, param?: any, finish?: Function };
19
+
20
+ protected onLoad(): void {
21
+ this.maskOpacity = this.node.getChildByName('mask')?.getComponent(UIOpacity)
22
+ this.root = this.node.getChildByName('root')
23
+ }
24
+
25
+ /**
26
+ * 显示弹窗特效(主动调用)
27
+ */
28
+ public open() {
29
+ if (!this.root || !this.maskOpacity) { return }
30
+ this.showAnim()
31
+ }
32
+ public close(param?: { is_anim?: boolean, param?: any, finish?: Function }) {
33
+ this.paramClose = param;
34
+ this.param?.callBack?.(param?.param)//回调方法
35
+ if (param?.is_anim && this.root && this.maskOpacity) {
36
+ this.hideAnim()
37
+ } else {
38
+ param?.finish()
39
+ this.destroyWindow()
40
+ }
41
+ }
42
+
43
+ destroyWindow() { this.node.destroy(); }
44
+
45
+ /**打开动画-可重写动画*/
46
+ public showAnim() {
47
+ this.root.setScale(0.001, 0.001);
48
+ this.maskOpacity.opacity = 0;
49
+ tween(this.maskOpacity).to(0.2, { opacity: 255 }).start()
50
+ tween(this.root)
51
+ .to(0.068, { scale: new Vec3(1.15, 1.15, 1.15) })
52
+ .to(0.088, { scale: new Vec3(0.88, 0.88, 0.88) })
53
+ .to(0.088, { scale: new Vec3(1, 1, 1) })
54
+ .start();
55
+ }
56
+ /**关闭动画-可重写动画*/
57
+ public hideAnim() {
58
+ tween(this.maskOpacity).to(0.2, { opacity: 0 }).start()
59
+ //销毁动画
60
+ tween(this.root)
61
+ .to(0.1, { scale: new Vec3(1.028, 1.028, 1.028) })
62
+ .to(0.1, { scale: new Vec3(0.001, 0.001, 0.001) })
63
+ .call(() => {
64
+ this.paramClose.param?.finish()
65
+ setTimeout(() => { if (this.node && this.node.isValid) { this.destroyWindow() } });
66
+ })
67
+ .start();
68
+ }
69
+ }
70
+
71
+
72
+
73
+ // BaseWindow.ts
74
+ // export function BaseWindowMixin<T extends new (...args: any[]) => Component>(Base: T) {
75
+ // return class extends Base {
76
+ // show() { /* 你的显示逻辑 */ }
77
+ // close() { /* 你的关闭逻辑 */ }
78
+ // // ... 其他方法
79
+ // };
80
+ // }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "739e9cf6-12f0-43c6-93af-edd2d8705a29",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -119,6 +119,11 @@ declare module 'cc' {
119
119
  fromHEX(hex: string);
120
120
  }
121
121
  interface Node {
122
+ /**
123
+ * 禁用按钮
124
+ * @param enable
125
+ * @param time 禁用后xx秒后恢复,不传一直禁用
126
+ */
122
127
  enable(enable: boolean, time?: number): void;
123
128
  }
124
129
  interface Label {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",