为什么把aliveUpdate里更新的内容在update内效果就不好呢?
如果把代码修改为这样
starObj.prototype.update = function() { // body... this.timer += deltaTime; this.x += this.xSpd*deltaTime*0.002; this.y += this.ySpd*deltaTime*0.002; //判断是否出了canvas边界,如果出了边界就重置 if(this.x < 100 || this.x > 700 || this.y < 150 || this.y > 450){ this.init(); return; } if(this.timer > 100){ this.picNo += 1; this.picNo = this.picNo%7; this.timer = 0; } if(switchy){ life += 0.03*deltaTime*0.05; if(life>1){ life = 1; } }else{ life -= 0.03*deltaTime*0.05; if (life<0) { life = 0; } }};function aliveUpdte(){}
效果会差很多,想知道为什么