代码:
this.init = function(x, y, size, angle, speed, life, startColor, endColor, startAlpha, endAlpha, endSize)
{
console.log("particle init called");
this.x = x;
this.y = y;
this.size = size;
this.motionX = speed * Math.sin(angle);
this.motionY = speed * Math.cos(angle);
this.life = life;
this.timer = 0;
this.startColor = startColor;
this.endColor = endColor;
this.startAlpha = startAlpha;
this.endAlpha = endAlpha;
this.endSize = endSize;
console.log("here's what i just set stuff to: timer=" + this.timer);
console.log(this);
};
当我实际致电init()
时,日志显示:
here's what i just set stuff to: timer=0
随后是objct的转储,内容为:
timer: 54
那么,为什么timer
的值读出为0,然后立即神奇地将其设置为某个随机数?