I am trying to create a growing/shrinking effect with WebGL.
I approached this problem by using setTimeout().
I incorporated a do-while loop so that this process can repeat
However, the growing/shrinking only occurs once.
My Code:
document.getElementById("groNShrink").onclick = function()
{
var millisecondsToWait = 500;
var max = 3; // Max times
do
{
balloonEffect++;
for (var i = 0; i < max; i++)
{
setTimeout(function ()
{
changeRadius /= 1.15;
}
, millisecondsToWait * i);
}
setTimeout(function ()
{
for (var x = max; x !== 0; x--)
{
setTimeout(function ()
{
changeRadius *= 1.15;
}
, millisecondsToWait * x);
}
}
, millisecondsToWait * max);
}
while (balloonEffect % 2 == 0);
};
This is just my for my do-while loop.
I don't see where I went wrong maybe another pair of eyes will help.