我正在尝试模拟烟雾canvas
。我想创建一个新的烟熏并将其推入 puffs 数组,但我不断收到"Uncaught TypeError: Type error"
错误消息。
有人知道我错过了什么吗?
var puffs = [];
this.tick = function() {
var puffLength = puffs.length;
if ( addPuffs && ( puffLength < maxParticles )) {
puffs.push({ //THIS ONE IT WHAT GIVES ME THE ERROR
posX: oPoint.x,
posY: oPoint.y,
scale: .1,
age: 0
});
}
for(var i = 0; i < puffLength; i++) {
var currentPuff = puffs[i];
if(currentPuff.age == maxLife) {
puffs.splice(i, 1);
} else {
currentPuff.posX += windX,
currentPuff.posY += windY,
currentPuff.scale += growingSpeed,
currentPuff.age++;
}
}
this.render();
}