Angular 2 - 倒计时

时间:2016-07-14 15:13:43

标签: angular

My Angular 2应用允许玩家互相争斗。

每个玩家可以轮流玩,每个回合都有 60秒的限制。

我尝试使用服务器数据进行60秒倒计时,不使用使用计算机时钟(当玩家使用不同的时区或时钟设置时可能会误导)。

这是最后一个转弯时间:this.future = new Date(this.battleData.last_turn_time);

这是我的倒计时方法,有两个问题:

  1. 使用计算机时间..(为什么我不应该使用上面解释过的)
  2. 每3秒更新一次(当我执行API CALL时,每3秒钟一次)。
  3. countDown() {
    //Countdown this.future = new Date(this.battleData.last_turn_time);

               let date1 = Math.floor(new Date().getTime()/1000);
               let date2 =  Math.floor(this.future.getTime()/1000)+(this.TURN_TIME);
                this.diff = date2 - date1;
                this.secondsLeft = this.diff;
    
    }
    

0 个答案:

没有答案
相关问题