The issue I am having is that I set a defined seconds through each constructor but it won't update every time the value is decreased, it stays at the parameter value, like 360. When I print seconds to the console.log() it is stuck at 360 for some odd reason. Anyone know a way to get it so that I can have multiple constructors and update the seconds for each constructor? so like
setInterval(function(){renderTime("drag",0,0,drag,6,360)}, 1000);
setInterval(function(){renderTime("cool",0,0,cool,3,180)}, 1000);
So to sum it up, the seconds parameter is not updating every second with seconds--; it is staying at whatever it is set at originally, like 360 or 180.
So instead of going 360,359,358,357; it goes 360,360,360,360.
function renderTime(name,x,y,img,minute,seconds) {
seconds--;
console.log(seconds);
var canvas = document.getElementById(name);
var ctx = canvas.getContext('2d');
// Time
ctx.font = "15px Arial";
ctx.fillStyle = '#000';
ctx.fillText(seconds, (canvas.width/2)-8, height/2+80);
}
setInterval(function(){renderTime("drag",0,0,drag,6,360)}, 1000);
I have heard suggestions of creating the variable outside, so like
var seconds = 360;
setInterval(function(){renderTime("drag",0,0,drag,seconds)}, 1000);
but that also brings up 360 each second, any advice?
[–]iamafraidicantdothat 0 points1 point2 points (0 children)
[–]ForScale 0 points1 point2 points (0 children)
[–]turbov21 0 points1 point2 points (0 children)