array moves contains just a couple of move I wanna draw on canvas. basically a deltaTime to sleep and a draw command.
This simply doesn’t work 🙁
for (var i=0; i< parsed.moves.length; i++)
{
var e = parsed.moves[i];
setTimeout(function(){drawCmd(context,e)}, e.deltaTime*1000);
//deltaTime are values btn 0-1, the sleep time i need to set btw commands
}
function drawCmd(canvasctx, e)
{
switch(e.type)
{
//case ...
}
}
it did nothing at all, not even calling drawCmd function
You code only delays all the
drawCmdbye.deltaTime*1000and executes them all at once afterwards, all ati = 10If you meant to “draw and wait, draw and wait”, try this: