From 589e348662d34914f4fd5c97b72bfccffb20da0f Mon Sep 17 00:00:00 2001 From: mumuy Date: Fri, 28 Oct 2022 09:45:58 +0800 Subject: [PATCH] =?UTF-8?q?updated=20=E5=B1=8F=E5=B9=95=E9=AB=98=E5=88=B7?= =?UTF-8?q?=E9=A2=91=E7=8E=87=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/game.js b/game.js index 0e2489e..4d428d6 100644 --- a/game.js +++ b/game.js @@ -323,7 +323,14 @@ function Game(id,params){ //动画开始 this.start = function() { var f = 0; //帧数计算 + var timestamp = (new Date()).getTime(); var fn = function(){ + var now = (new Date()).getTime(); + if(now-timestamp<16){ // 限频,防止高刷屏幕动画过快 + _hander = requestAnimationFrame(fn); + return false; + } + timestamp = now; var stage = _stages[_index]; _context.clearRect(0,0,_.width,_.height); //清除画布 _context.fillStyle = '#000000';