用于精灵表动画的 Javascript 画布 setInverval

问题描述

我需要帮助设置精灵表动画的间隔而不影响 movePlayer() 函数,这会导致玩家移动,顺便说一句,你可以看到我的代码非常笨拙,因此任何有关这方面的建议也可能有所帮助。

>
setInterval(function(){
  ctx.clearRect(0,2315,700);
  ctx.drawImage(background,700);
  if(isRight == true && isWalking == false){
    player.width  = 61;
    player.height = 75;
    drawStandR(standR,player.width * player.frameX,player.height * player.frameY,player.width,player.height,player.x,player.y,player.height);
    movePlayer(); //Move character
    handlePlayerFrame(); //Starts the animation
  }else if(isRight == true && isWalking == true){
    player.width  = 93;
    player.height = 71;
    drawWalkR(walkR,player.height);
    movePlayer(); //Move character
    handlePlayerFrame(); //Starts the animation 
  }else if(isLeft == true && isWalking == true){
    player.width  = 93;
    player.height = 71;
    drawWalkL(walkL,player.x-40,player.height);
    movePlayer(); //Move character
    handlePlayerFrame(); //Starts the animation             
  }else if(isLeft == true){
    player.width  = 61;
    player.height = 75;
    drawStandL(standL,player.height);
    movePlayer(); //Move character
    handlePlayerFrame(); //Starts the animation     
  }
},50);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)