想要实现一个分数增长效果,游戏结束后让玩家分数在规定的时间内跳动增长
比如说1秒时间内从0增长到1000(或更大值),我用的是schedule定时器,间隔执行去实现,在模拟器上效果是正常的,但改为游览器上,就不对了,增长效果是有,但并不是在规定时间内,不知道是不是Bug,或者提供一下其他思考方案,谢谢~~
附上代码:
playScoreAnimation(){
// 假设玩家分数 500
this.totalScore = 500;
this.showScore = 0;
// // 定时器
// 1秒
var interval = 1.0 / this.totalScore ;
// // 重复次数
var repeat = this.totalScore;
cc.log(" this.totalScore ="+ this.totalScore +",interval = " + interval + ",repeat = " + repeat);
// 重复次数
this.ScoreAnimation = function () {
this.scoreLabel.string = this.showScore;
this.showScore ++;
};
// 开始一个计时器
this.schedule(this.ScoreAnimation, interval,repeat);
},