• 计时器


    /**************11111************************/

    private timeName: number;
    private isCanClick: boolean;
    private timeNum: number = 10;

    private clickFun(): void {
    let s = this;
    if (s.isCanClick) {
    s.isCanClick = false;

    s.timeName = loopMgr.setInterval(s.timeFun, s, 1000);
    }
    }

    private timeFun(): void {
    let s = this;

    if (s.timeNum <= 0) {
    s.clearTime();
    return;
    }
    s.timeNum--;

    }

    private clearTime(): void {
    let s = this;

    s.timeNum = 10;
    loopMgr.clearInterval(s.timeName);
    s.isCanClick = true;
    }

    /**************222************************/

    private timeIdx: number;

    private times: number = 10000;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    loopMgr.clearTimeOut(s.timeIdx);
    s.timeIdx = null;
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setTimeOut(s.setStatus, s, s.times);
    }

    private setStatus(): void {
    let s = this;
    s.isCanClick = true;
    s.clearTime();
    }

    /**************333************************/

    private timeIdx: number;

    private times: number = 10;

    private isCanClick: boolean;

    private checkStatus(): boolean {
    let s = this;
    return s.isCanClick;
    }

    private clearTime(): void {
    let s = this;
    if (s.timeIdx)
    s.timeIdx = null;
    loopMgr.clearInterval(s.timeIdx);
    }

    private timeFun(): void {
    let s = this;
    s.isCanClick = false;
    s.timeIdx = loopMgr.setInterval(s.setStatus, s, 1000);
    /**执行的方法 */
    }

    private setStatus(): void {
    let s = this;
    if (s.times <= 0) {
    s.clearTime();
    s.isCanClick = true;
    s.times = 10;
    return;
    } else {
    s.times--;
    }
    }

  • 相关阅读:
    bzoj1568: [JSOI2008]Blue Mary开公司
    bzoj3301: [USACO2011 Feb] Cow Line
    bzoj4745: [Usaco2016 Dec]Cow Checklist
    bzoj4746: [Usaco2016 Dec]Lasers and Mirrors
    bzoj2982: combination
    bzoj1822: [JSOI2010]Frozen Nova 冷冻波
    bzoj1027: [JSOI2007]合金
    bzoj 2004
    bzoj 3110&&codevs 1616
    bzoj 2134
  • 原文地址:https://www.cnblogs.com/youziwulala/p/11550472.html
Copyright © 2020-2023  润新知