UIPrivacy.ts
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import { WindowName } from "../../Global";
import { UIBase } from "../UIBase";
import { UIManager } from "../UIManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class UI_Privacy extends UIBase {
private type: number = 1;
@property(cc.Node)
imgBg: cc.Node = null;
@property(cc.Node)
Privacy: cc.Node = null;
private curTextNum: number = 0;
private privacyTextList: cc.Node[] = null;
// start() {
// }
protected onEnable(): void {
this.curTextNum = 0;
this.privacyTextList = this.Privacy.getChildByName('content').children;
this.showFirstText();
let _param = this.enableParam as number;
this.Action_FadeIn();
this.type = _param;
if (_param == 2) {
this.onEvent_ShowPrivcayText();
} else {
this.onEvent_BTN_Back();
}
cc.log('privacy')
}
showPrivacyTextForNum(curNum: number) {
for (let i = 0; i < this.privacyTextList.length; i++) {
if (i == curNum) {
this.privacyTextList[i].active = true;
} else {
this.privacyTextList[i].active = false;
}
}
}
showFirstText() {
this.privacyTextList.forEach(element => {
if (element.name == 'Label1') {
element.active = true;
} else {
element.active = false;
}
});
}
CloseUI() {
this.Action_FadeOut();
// this.showFirstText();
}
onEvent_BTN_Agree() {
this.CloseUI();
localStorage.setItem("_PRIVACY", "true");
}
onEvent_BTN_Exit() {
}
onEvent_BTN_Next() {
this.curTextNum++;
if (this.curTextNum >= this.privacyTextList.length) {
this.curTextNum = 0;
}
this.showPrivacyTextForNum(this.curTextNum)
//test
// this.privacyTextList.forEach(element => {
// console.log(element.active + ' <<<<<<<<< ' + element.name)
// });
}
onEvent_ShowPrivcayText() {
this.imgBg.active = false;
this.Privacy.active = true;
}
onEvent_BTN_Back() {
if (this.type == 2) {
this.CloseUI();
} else {
this.imgBg.active = true;
this.Privacy.active = false;
}
}
Action_SetButton_Clickable(value) {
this.node.getChildByName('touchBlocker').active = !value;
}
Action_FadeIn(_data?: any, _fadeTime: number = 0.5) {
// 动态进入的效果
this.node.getChildByName('blackFrame').opacity = 0;
cc.tween(this.node.getChildByName('blackFrame')).to(_fadeTime * 0.4, { opacity: 200 }).start();
this.node.getChildByName('panel').scale = 0
this.Action_SetButton_Clickable(false);
cc.tween(this.node.getChildByName('panel')).to(_fadeTime, { scale: 1 }, { easing: 'backOut' }).call(() => {
this.OnEvent_TweenFinished_FadeIn(_data);
}).start();
}
OnEvent_TweenFinished_FadeIn(_data: any) {
this.Action_SetButton_Clickable(true);
}
Action_FadeOut(_fadeTime: number = 0.3) {
this.Action_SetButton_Clickable(false);
cc.tween(this.node.getChildByName('blackFrame')).to(_fadeTime, { opacity: 0 }).start();
cc.tween(this.node.getChildByName('panel')).to(_fadeTime, { scale: 0 }, { easing: 'backIn' }).call(() => {
this.OnEvent_TweenFinished_FadeOut();
}).start();
}
OnEvent_TweenFinished_FadeOut() {
// this.node.active = false;
UIManager.ins.closeWindow(WindowName.PRIVACY);
}
}