import { _decorator, Component, Label, Node } from 'cc'; import { userDataManager } from '../../manager/userDataManager'; import { Util } from '../../util'; const { ccclass, property } = _decorator; @ccclass('home_bottom_countdown') export class home_bottom_countdown extends Component { @property(Node) lab_countdown_time:Node = null private seconds:number = 0 startTime() { this.seconds = userDataManager.getUserFreeAdsData() if(this.seconds==-1) { this.unscheduleAllCallbacks() this.node.active = false return } this.node.active = true this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds) this.unscheduleAllCallbacks() this.schedule(()=>{ this.seconds -- if(this.seconds<=0) { userDataManager.is_free_ads = false this.unscheduleAllCallbacks() this.node.active = false return } this.lab_countdown_time.getComponent(Label).string = Util.formatTimeForSecond(this.seconds) },1) } }