49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
const { ccclass, property } = cc._decorator;
|
||
|
||
@ccclass
|
||
export default class buyActivate extends cc.Component {
|
||
@property(cc.Button)
|
||
qiutBtn: cc.Button = null;
|
||
|
||
@property(cc.Button)
|
||
buyBtn: cc.Button = null;
|
||
|
||
@property(cc.Label)
|
||
countdown: cc.Label = null;
|
||
|
||
private callback: Function = null;
|
||
|
||
|
||
start() {
|
||
|
||
}
|
||
init(callback: Function, timeStr: string) {
|
||
// 初始化回调函数
|
||
this.callback = callback;
|
||
|
||
// 添加按钮事件监听
|
||
this.qiutBtn.node.on('click', this.onQuitBtnClick, this);
|
||
this.buyBtn.node.on('click', this.onBuyBtnClick, this);
|
||
|
||
this.countdown.string = timeStr;
|
||
}
|
||
// updateCountdown(str: string) {
|
||
// this.countdown.string = str;
|
||
// }
|
||
onQuitBtnClick() {
|
||
|
||
// 移除界面
|
||
this.node.destroy();
|
||
}
|
||
|
||
onBuyBtnClick() {
|
||
// 调用回调函数,触发passCheck中的购买逻辑
|
||
if (this.callback && typeof this.callback === 'function') {
|
||
this.callback();
|
||
}
|
||
|
||
// 移除界面
|
||
this.node.destroy();
|
||
}
|
||
}
|