@cc-component/cc-ex-component 1.7.4 → 1.7.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.
- package/assets/core/BaseWindow.ts +23 -3
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { UIOpacity, tween, Vec3 } from 'cc';
|
|
2
2
|
import { _decorator, Component, Node } from 'cc';
|
|
3
3
|
import { BaseReference } from './BaseReference';
|
|
4
|
+
import { UITransform } from 'cc';
|
|
5
|
+
import { view } from 'cc';
|
|
6
|
+
import { Widget } from 'cc';
|
|
4
7
|
const { ccclass, property } = _decorator;
|
|
5
8
|
|
|
6
9
|
@ccclass('BaseWindow')
|
|
@@ -27,6 +30,9 @@ export class BaseWindow extends BaseReference {
|
|
|
27
30
|
protected onLoad(): void {
|
|
28
31
|
this.maskOpacity = this.node.getChildByName('mask')?.getComponent(UIOpacity)
|
|
29
32
|
this.root = this.node.getChildByName('root')
|
|
33
|
+
this.resetMaskSize()
|
|
34
|
+
this.maskAinm(true)
|
|
35
|
+
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
/**
|
|
@@ -46,6 +52,7 @@ export class BaseWindow extends BaseReference {
|
|
|
46
52
|
* @param param.time 关闭的按钮的时间
|
|
47
53
|
*/
|
|
48
54
|
public pop(param?: { is_anim?: boolean, param?: any, finish?: Function }) {
|
|
55
|
+
//this.maskAinm(false)
|
|
49
56
|
this.paramClose = param;
|
|
50
57
|
this.param?.callBack?.(param?.param)//回调方法
|
|
51
58
|
if (param?.is_anim && this.root && this.maskOpacity) {
|
|
@@ -61,8 +68,6 @@ export class BaseWindow extends BaseReference {
|
|
|
61
68
|
/**打开动画-可重写动画*/
|
|
62
69
|
public showAnim() {
|
|
63
70
|
this.root.setScale(0.001, 0.001);
|
|
64
|
-
this.maskOpacity.opacity = 0;
|
|
65
|
-
tween(this.maskOpacity).to(0.2, { opacity: 255 }).start()
|
|
66
71
|
tween(this.root)
|
|
67
72
|
.to(0.068, { scale: new Vec3(1.15, 1.15, 1.15) })
|
|
68
73
|
.to(0.088, { scale: new Vec3(0.88, 0.88, 0.88) })
|
|
@@ -71,7 +76,6 @@ export class BaseWindow extends BaseReference {
|
|
|
71
76
|
}
|
|
72
77
|
/**关闭动画-可重写动画*/
|
|
73
78
|
public hideAnim() {
|
|
74
|
-
tween(this.maskOpacity).to(0.2, { opacity: 0 }).start()
|
|
75
79
|
//销毁动画
|
|
76
80
|
tween(this.root)
|
|
77
81
|
.to(0.1, { scale: new Vec3(1.028, 1.028, 1.028) })
|
|
@@ -86,11 +90,27 @@ export class BaseWindow extends BaseReference {
|
|
|
86
90
|
this.paramClose?.param?.finish()
|
|
87
91
|
setTimeout(() => { if (this.node && this.node.isValid) { this.destroyWindow() } });
|
|
88
92
|
}
|
|
93
|
+
maskAinm(show: boolean) {
|
|
94
|
+
if (!this.maskOpacity) return
|
|
95
|
+
if (show) {
|
|
96
|
+
this.maskOpacity.opacity = 0;
|
|
97
|
+
tween(this.maskOpacity).to(0.2, { opacity: 255 }).start()
|
|
98
|
+
} else {
|
|
99
|
+
tween(this.maskOpacity).to(0.2, { opacity: 0 }).start()
|
|
100
|
+
}
|
|
101
|
+
}
|
|
89
102
|
/**关闭事件-当系统级关闭所有打开的界面时。如果关闭界面时需要执行自己的业务逻辑,重写此方法
|
|
90
103
|
* eventName:关闭方法名称
|
|
91
104
|
* param:参数
|
|
92
105
|
*/
|
|
93
106
|
closeEvent(): { eventName: string, param?: any } { return null }
|
|
107
|
+
|
|
108
|
+
resetMaskSize() {
|
|
109
|
+
if (!this.maskOpacity) return
|
|
110
|
+
const widget = this.maskOpacity.node.getComponent(Widget);
|
|
111
|
+
widget.left = -view.getVisibleSize().width
|
|
112
|
+
widget.right = -view.getVisibleSize().width
|
|
113
|
+
}
|
|
94
114
|
}
|
|
95
115
|
|
|
96
116
|
|