猫史档案馆


【box3】tick计时器

用户:卫道士32_32*2没了卫道士32_32*2没了查看:0 回复:5 评论:0 创建时间:2020-05-05T12:51:34


防止喵线------------------------------------------------------------------------------------------------------------------

class timer{
  public var ticks = 0;
  public ansyc function startTimer(){
    while (True){
      self.ticks += 1
      await sleep(1)
    }
  }
  public function resetTimer(){
    self.ticks = 0
  }
}
//使用
var timer = new timer()
timer.startTimer()
await sleep(13)
console.log(timer.ticks)

划重点!!!

1.

public function startTimer(){  //”public“方便程序获取

2.

var timer = new timer()  //实例化

🆗


回复

上一页1 页 / 共 1下一页
cool-creepercool-creeper

不懂

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

class timer{
  public var ticks = 0;
  public ansyc function startTimer(){
    while (True){
      self.ticks += 1
      await sleep(1)
    }
  }
  public function resetTimer(){
    self.ticks = 0
  }
}
//使用
var timer = new timer()
timer.startTimer()
await sleep(13)
console.log(timer.ticks)
//存代码ing……

点赞0


评论


屑三芙化氮awa~屑三芙化氮awa~

self.ticks += 1

这个改成下面那个不是更香吗()狗头()

self.ticks ++

点赞0


评论


islptng128islptng128

async
ansyc

你看看区别吧

 

点赞0


评论


企鹅vItY企鹅vItY

ddd

点赞1


评论