HTML and CSS Reference
In-Depth Information
newParticle
.
y
=
y
;
newParticle
.
type
=
type
;
//ConsoleLog.log("newParticle.life=" + newParticle.life);
particles
.
push
(
newParticle
);
}
}
}
The
updateParticles()
function will loop through the
particles
instances, update the at-
tributes of each, and then check whether the particle's life has been exhausted. If it has, the
function places the particle back in the pool. Here is the code we add to
updateParticles()
to replenish the pool:
iif
(
remove
) {
particlePool
.
push
(
tempParticle
)
particles
.
splice
(
particleCtr
,
1
)
}