问答详情
源自:3-8 浮漂物制作

我的漂浮物出不来 不知道哪里有问题

var dustObj =function ()

{


this.x = [];

this.y = [];

this.amp = [];

this.dustNo = [];

this.alpha;

}

dustObj.prototype.num = 30;

dustObj.prototype.init =function ()

{

for (var i=0;i<this.num;i++)

{

this.x[i] = Math.random() * canWidth;

this.x[i] = Math.random() * canHeight;

this.amp[i] = 20 + Math.random() * 30;

this.dustNo[i] = Math.floor(Math.random() * 7 );

}

this.alpha = 0;

}


dustObj.prototype.draw = function()

{

this.alpha += deltaTime * 0.0007;

var len = Math.sin(this.alpha);

for (var i=0;i<this.num;i++)

{

var no = this.dustNo[i];

cxt1.drawImage(dustPic[no], this.x[i] + this.amp[i] * len, this.y[i]);

}

}


提问者:差太多 2016-10-18 12:02

个回答

  • 差太多
    2016-10-18 12:56:03

    找到了 有个地方this,y写成了this.x