|
|
@@ -1,10 +1,6 @@
|
|
|
-// Learn TypeScript:
|
|
|
-// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
|
|
|
-// Learn Attribute:
|
|
|
-// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
|
|
|
-// Learn life-cycle callbacks:
|
|
|
-// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
-
|
|
|
+/**
|
|
|
+ * 5s自动关闭
|
|
|
+ */
|
|
|
import BaseUI from "../../../MOKA/component/BaseUI";
|
|
|
import GameController from "../../GameController";
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
@@ -30,6 +26,11 @@ export default class GeneralUpStarUI extends BaseUI {
|
|
|
private img_box_1: cc.Sprite = null!;
|
|
|
@property({ type: cc.Sprite, displayName: '头像框2' })
|
|
|
private img_box_2: cc.Sprite = null!;
|
|
|
+ /** 自动关闭时间 */
|
|
|
+ @property({ displayName: '自动关闭时间' })
|
|
|
+ private life_time: number = 5;
|
|
|
+ @property({ type: cc.Label, displayName: '自动关闭描述' })
|
|
|
+ private txt_time: cc.Label = null!;
|
|
|
|
|
|
/** 数据 */
|
|
|
private my_data = {
|
|
|
@@ -44,15 +45,20 @@ export default class GeneralUpStarUI extends BaseUI {
|
|
|
fragment: 0,
|
|
|
star: 0,
|
|
|
attack: 0,
|
|
|
- }
|
|
|
+ },
|
|
|
+ /** 关闭回调 */
|
|
|
+ close_call: null
|
|
|
}
|
|
|
+ /** 当前时间s */
|
|
|
+ private cur_time = 0;
|
|
|
onLoad() {
|
|
|
-
|
|
|
+ this.schedule(this.upTextClose, 1);
|
|
|
}
|
|
|
|
|
|
start() {
|
|
|
this.my_data.old_data = this.ui_data.old_data;
|
|
|
this.my_data.new_data = this.ui_data.new_data;
|
|
|
+ this.my_data.close_call = this.ui_data.close_call;
|
|
|
cc.log(this.ui_data)
|
|
|
this.initStyle();
|
|
|
}
|
|
|
@@ -100,5 +106,19 @@ export default class GeneralUpStarUI extends BaseUI {
|
|
|
this.img_box_2.spriteFrame = asset;
|
|
|
})
|
|
|
}
|
|
|
+ /** 关闭倒计时显示 */
|
|
|
+ private upTextClose() {
|
|
|
+ this.cur_time++;
|
|
|
+ if (this.cur_time >= this.life_time) {
|
|
|
+ this.unschedule(this.upTextClose);
|
|
|
+ this.close();
|
|
|
+ }
|
|
|
+ let gap = this.life_time - this.cur_time;
|
|
|
+ this.txt_time.string = gap + '秒后自动关闭';
|
|
|
+ }
|
|
|
+ onDestroy() {
|
|
|
+ this.my_data.close_call && this.my_data.close_call();
|
|
|
+ super.onDestroy()
|
|
|
+ }
|
|
|
// update (dt) {}
|
|
|
}
|