如何停止html5画布的移动功能?

时间:2014-04-18 01:12:39

标签: html5 canvas

如果我使用这样的代码

  

if(this.x> 650)

     

this.x + = this.speed;

     

}

     

否则if(this.x = 650){

     

this.x =(停止移动);

     

}

对象将移动

  

if(this.x> 650)

     

this.x + = this.speed;

     

}

当对象位于x = 650时,我该如何获得。此函数' this.x + = this.speed;'会停止吗?

1 个答案:

答案 0 :(得分:0)

好像你需要从this.x中减去this.speed,因为你的if语句说this.x超过650然后将this.speed添加到this.x,但如果你要去加速,你永远不会到达其他地方,因为你的this.x总是会更大。